switch to spdlog
This commit is contained in:
		| @@ -32,7 +32,7 @@ E_SIMPLE3(fuse_event, debug, true, | ||||
|   int, result, res, E_FROM_INT32 | ||||
| ); | ||||
|  | ||||
| E_SIMPLE1(fuse_args_parsed, normal, true, | ||||
| E_SIMPLE1(fuse_args_parsed, info, true, | ||||
|   std::string, arguments, args, E_STRING | ||||
| ); | ||||
| // clang-format on | ||||
|   | ||||
| @@ -28,7 +28,7 @@ | ||||
|  | ||||
| namespace repertory { | ||||
| // clang-format off | ||||
| E_SIMPLE2(curl_error, normal, true, | ||||
| E_SIMPLE2(curl_error, info, true, | ||||
|   std::string, url, url, E_STRING, | ||||
|   CURLcode, res, res, E_FROM_CURL_CODE  | ||||
| ); | ||||
| @@ -39,7 +39,7 @@ E_SIMPLE3(debug_log, debug, true, | ||||
|   std::string, data, data, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE1(directory_removed, normal, true, | ||||
| E_SIMPLE1(directory_removed, info, true, | ||||
|   std::string, api_path, ap, E_STRING | ||||
| ); | ||||
|  | ||||
| @@ -58,23 +58,23 @@ E_SIMPLE2(drive_mount_failed, error, true, | ||||
|   std::string, result, res, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE1(drive_mounted, normal, true, | ||||
| E_SIMPLE1(drive_mounted, info, true, | ||||
|   std::string, location, loc, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE1(drive_mount_result, normal, true, | ||||
| E_SIMPLE1(drive_mount_result, info, true, | ||||
|   std::string, result, res, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE1(drive_unmount_pending, normal, true, | ||||
| E_SIMPLE1(drive_unmount_pending, info, true, | ||||
|   std::string, location, loc, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE1(drive_unmounted, normal, true, | ||||
| E_SIMPLE1(drive_unmounted, info, true, | ||||
|   std::string, location, loc, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE1(event_level_changed, normal, true, | ||||
| E_SIMPLE1(event_level_changed, info, true, | ||||
|   std::string, new_event_level, level, E_STRING | ||||
| ); | ||||
|  | ||||
| @@ -86,7 +86,7 @@ E_SIMPLE1(failed_upload_removed, warn, true, | ||||
|   std::string, api_path, ap, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE1(failed_upload_retry, normal, true, | ||||
| E_SIMPLE1(failed_upload_retry, info, true, | ||||
|   std::string, api_path, ap, E_STRING | ||||
| ); | ||||
|  | ||||
| @@ -99,7 +99,7 @@ E_SIMPLE1(file_get_api_list_failed, error, true, | ||||
|   std::string, error, err, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE1(file_pinned, normal, true, | ||||
| E_SIMPLE1(file_pinned, info, true, | ||||
|   std::string, api_path, ap, E_STRING | ||||
| ); | ||||
|  | ||||
| @@ -109,7 +109,7 @@ E_SIMPLE3(file_read_bytes_failed, error, true, | ||||
|   std::size_t, retry, retry, E_FROM_SIZE_T | ||||
| ); | ||||
|  | ||||
| E_SIMPLE1(file_removed, normal, true, | ||||
| E_SIMPLE1(file_removed, info, true, | ||||
|   std::string, api_path, ap, E_STRING | ||||
| ); | ||||
|  | ||||
| @@ -134,20 +134,20 @@ E_SIMPLE2(file_get_size_failed, error, true, | ||||
|   std::string, error, err, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE3(filesystem_item_added, normal, true, | ||||
| E_SIMPLE3(filesystem_item_added, info, true, | ||||
|   std::string, api_path, ap, E_STRING, | ||||
|   std::string, parent, parent, E_STRING, | ||||
|   bool, directory, dir, E_FROM_BOOL | ||||
| ); | ||||
|  | ||||
| E_SIMPLE4(filesystem_item_closed, verbose, true, | ||||
| E_SIMPLE4(filesystem_item_closed, trace, true, | ||||
|   std::string, api_path, ap, E_STRING, | ||||
|   std::string, source, src, E_STRING, | ||||
|   bool, directory, dir, E_FROM_BOOL, | ||||
|   bool, changed, changed, E_FROM_BOOL | ||||
| ); | ||||
|  | ||||
| E_SIMPLE5(filesystem_item_handle_closed, verbose, true, | ||||
| E_SIMPLE5(filesystem_item_handle_closed, trace, true, | ||||
|   std::string, api_path, ap, E_STRING, | ||||
|   std::uint64_t, handle, handle, E_FROM_UINT64, | ||||
|   std::string, source, src, E_STRING, | ||||
| @@ -155,14 +155,14 @@ E_SIMPLE5(filesystem_item_handle_closed, verbose, true, | ||||
|   bool, changed, changed, E_FROM_BOOL | ||||
| ); | ||||
|  | ||||
| E_SIMPLE4(filesystem_item_handle_opened, verbose, true, | ||||
| E_SIMPLE4(filesystem_item_handle_opened, trace, true, | ||||
|   std::string, api_path, ap, E_STRING, | ||||
|   std::uint64_t, handle, handle, E_FROM_UINT64, | ||||
|   std::string, source, src, E_STRING, | ||||
|   bool, directory, dir, E_FROM_BOOL | ||||
| ); | ||||
|  | ||||
| E_SIMPLE2(filesystem_item_evicted, normal, true, | ||||
| E_SIMPLE2(filesystem_item_evicted, info, true, | ||||
|   std::string, api_path, ap, E_STRING, | ||||
|   std::string, source, src, E_STRING | ||||
| ); | ||||
| @@ -172,17 +172,17 @@ E_SIMPLE2(filesystem_item_get_failed, error, true, | ||||
|   std::string, error, err, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE3(filesystem_item_opened, verbose, true, | ||||
| E_SIMPLE3(filesystem_item_opened, trace, true, | ||||
|   std::string, api_path, ap, E_STRING, | ||||
|   std::string, source, src, E_STRING, | ||||
|   bool, directory, dir, E_FROM_BOOL | ||||
| ); | ||||
|  | ||||
| E_SIMPLE1(file_unpinned, normal, true, | ||||
| E_SIMPLE1(file_unpinned, info, true, | ||||
|   std::string, api_path, ap, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE4(file_upload_completed, normal, true, | ||||
| E_SIMPLE4(file_upload_completed, info, true, | ||||
|   std::string, api_path, ap, E_STRING, | ||||
|   std::string, source, src, E_STRING, | ||||
|   api_error, result, res, E_FROM_API_FILE_ERROR, | ||||
| @@ -200,7 +200,7 @@ E_SIMPLE2(file_upload_not_found, warn, true, | ||||
|   std::string, source, src, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE2(file_upload_queued, normal, true, | ||||
| E_SIMPLE2(file_upload_queued, info, true, | ||||
|   std::string, api_path, ap, E_STRING, | ||||
|   std::string, source, src, E_STRING | ||||
| ); | ||||
| @@ -209,20 +209,20 @@ E_SIMPLE1(file_upload_removed, debug, true, | ||||
|   std::string, api_path, ap, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE3(file_upload_retry, normal, true, | ||||
| E_SIMPLE3(file_upload_retry, info, true, | ||||
|   std::string, api_path, ap, E_STRING, | ||||
|   std::string, source, src, E_STRING, | ||||
|   api_error, result, res, E_FROM_API_FILE_ERROR | ||||
| ); | ||||
|  | ||||
| E_SIMPLE2(file_upload_started, normal, true, | ||||
| E_SIMPLE2(file_upload_started, info, true, | ||||
|   std::string, api_path, ap, E_STRING, | ||||
|   std::string, source, src, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE(item_scan_begin, normal, true); | ||||
| E_SIMPLE(item_scan_begin, info, true); | ||||
|  | ||||
| E_SIMPLE(item_scan_end, normal, true); | ||||
| E_SIMPLE(item_scan_end, info, true); | ||||
|  | ||||
| E_SIMPLE1(orphaned_file_deleted, warn, true, | ||||
|   std::string, source, src, E_STRING | ||||
| @@ -256,12 +256,12 @@ E_SIMPLE2(provider_offline, error, true, | ||||
|   std::uint16_t, port, port, E_FROM_UINT16 | ||||
| ); | ||||
|  | ||||
| E_SIMPLE2(provider_upload_begin, normal, true, | ||||
| E_SIMPLE2(provider_upload_begin, info, true, | ||||
|   std::string, api_path, ap, E_STRING, | ||||
|   std::string, source, src, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE3(provider_upload_end, normal, true, | ||||
| E_SIMPLE3(provider_upload_end, info, true, | ||||
|   std::string, api_path, ap, E_STRING, | ||||
|   std::string, source, src, E_STRING, | ||||
|   api_error, result, res, E_FROM_API_FILE_ERROR | ||||
| @@ -288,9 +288,9 @@ E_SIMPLE1(service_started, debug, true, | ||||
|   std::string, service, svc, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE(unmount_requested, normal, true); | ||||
| E_SIMPLE(unmount_requested, info, true); | ||||
| #if !defined(_WIN32) | ||||
| E_SIMPLE2(unmount_result, normal, true, | ||||
| E_SIMPLE2(unmount_result, info, true, | ||||
|   std::string, location, loc, E_STRING, | ||||
|   std::string, result, res, E_STRING | ||||
| ); | ||||
|   | ||||
| @@ -27,7 +27,7 @@ | ||||
|  | ||||
| namespace repertory { | ||||
| // clang-format off | ||||
| E_SIMPLE2(download_begin, normal, true, | ||||
| E_SIMPLE2(download_begin, info, true, | ||||
|   std::string, api_path, ap, E_STRING, | ||||
|   std::string, dest_path, dest, E_STRING | ||||
| ); | ||||
| @@ -49,19 +49,19 @@ E_SIMPLE6(download_chunk_end, debug, true, | ||||
|   api_error, result, result, E_FROM_API_FILE_ERROR | ||||
| ); | ||||
|  | ||||
| E_SIMPLE3(download_end, normal, true, | ||||
| E_SIMPLE3(download_end, info, true, | ||||
|   std::string, api_path, ap, E_STRING, | ||||
|   std::string, dest_path, dest, E_STRING, | ||||
|   api_error, result, result, E_FROM_API_FILE_ERROR | ||||
| ); | ||||
|  | ||||
| E_SIMPLE3(download_progress, normal, true, | ||||
| E_SIMPLE3(download_progress, info, true, | ||||
|   std::string, api_path, ap, E_STRING, | ||||
|   std::string, dest_path, dest, E_STRING, | ||||
|   double, progress, prog, E_DOUBLE_PRECISE | ||||
| ); | ||||
|  | ||||
| E_SIMPLE2(download_restored, normal, true, | ||||
| E_SIMPLE2(download_restored, info, true, | ||||
|   std::string, api_path, ap, E_STRING, | ||||
|   std::string, dest_path, dest, E_STRING | ||||
| ); | ||||
| @@ -72,17 +72,17 @@ E_SIMPLE3(download_restore_failed, error, true, | ||||
|   std::string, error, err, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE2(download_resumed, normal, true, | ||||
| E_SIMPLE2(download_resumed, info, true, | ||||
|   std::string, api_path, ap, E_STRING, | ||||
|   std::string, dest_path, dest, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE2(download_stored, normal, true, | ||||
| E_SIMPLE2(download_stored, info, true, | ||||
|   std::string, api_path, ap, E_STRING, | ||||
|   std::string, dest_path, dest, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE2(download_stored_removed, normal, true, | ||||
| E_SIMPLE2(download_stored_removed, info, true, | ||||
|   std::string, api_path, ap, E_STRING, | ||||
|   std::string, dest_path, dest, E_STRING | ||||
| ); | ||||
| @@ -93,7 +93,7 @@ E_SIMPLE3(download_stored_failed, error, true, | ||||
|   std::string, error, err, E_STRING | ||||
| ); | ||||
|  | ||||
| E_SIMPLE1(item_timeout, normal, true, | ||||
| E_SIMPLE1(item_timeout, info, true, | ||||
|   std::string, api_path, ap, E_STRING | ||||
| ); | ||||
| // clang-format on | ||||
|   | ||||
| @@ -32,12 +32,37 @@ namespace repertory { | ||||
| logging_consumer::logging_consumer(event_level level, std::string log_directory) | ||||
|     : event_level_(level), | ||||
|       log_directory_(utils::path::absolute(log_directory)) { | ||||
|   static const auto set_level = [](auto level) { | ||||
|     switch (level) { | ||||
|     case event_level::critical: | ||||
|       spdlog::set_level(spdlog::level::critical); | ||||
|       break; | ||||
|     case event_level::error: | ||||
|       spdlog::set_level(spdlog::level::err); | ||||
|       break; | ||||
|     case event_level::warn: | ||||
|       spdlog::set_level(spdlog::level::warn); | ||||
|       break; | ||||
|     case event_level::info: | ||||
|       spdlog::set_level(spdlog::level::info); | ||||
|       break; | ||||
|     case event_level::debug: | ||||
|       spdlog::set_level(spdlog::level::debug); | ||||
|       break; | ||||
|     case event_level::trace: | ||||
|       spdlog::set_level(spdlog::level::trace); | ||||
|     default: | ||||
|       spdlog::set_level(spdlog::level::info); | ||||
|       break; | ||||
|     } | ||||
|   }; | ||||
|  | ||||
|   E_SUBSCRIBE_ALL(process_event); | ||||
|   E_SUBSCRIBE_EXACT(event_level_changed, | ||||
|                     [this](const event_level_changed &changed) { | ||||
|                       event_level_ = event_level_from_string( | ||||
|                           changed.get_new_event_level().get<std::string>()); | ||||
|                       switch (event_level_) {} | ||||
|                       set_level(event_level_); | ||||
|                     }); | ||||
|  | ||||
|   spdlog::init_thread_pool(8192, 1); | ||||
| @@ -51,6 +76,8 @@ logging_consumer::logging_consumer(event_level level, std::string log_directory) | ||||
|   spdlog::register_logger(std::make_shared<spdlog::async_logger>( | ||||
|       "logger", sinks.begin(), sinks.end(), spdlog::thread_pool(), | ||||
|       spdlog::async_overflow_policy::block)); | ||||
|  | ||||
|   set_level(event_level_); | ||||
| } | ||||
|  | ||||
| logging_consumer::~logging_consumer() { E_CONSUMER_RELEASE(); } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user