From b3e61a2685803aa2b9306a264401c99c20352d11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Tue, 16 Jan 2024 18:56:07 +0100 Subject: [PATCH] GLOBAL LOGGING --- nano/lib/config.cpp | 4 ++++ nano/lib/logging.cpp | 2 +- nano/lib/logging_enums.hpp | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/nano/lib/config.cpp b/nano/lib/config.cpp index b27e1dd8c6..ff1dd8f11f 100644 --- a/nano/lib/config.cpp +++ b/nano/lib/config.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -403,10 +404,12 @@ nano::tomlconfig nano::load_toml_file (const std::filesystem::path & config_file // First try to load config from the current working directory, then from the node data directory if (auto toml = try_load_toml (config_filename); toml) { + nano::default_logger ().info (nano::log::type::config, "Config for `{}` loaded from current working directory", config_filename.string ()); return *toml; } if (auto toml = try_load_toml (data_path / config_filename); toml) { + nano::default_logger ().info (nano::log::type::config, "Config for `{}` loaded from node data directory ({})", config_filename.string (), data_path.string ()); return *toml; } @@ -417,5 +420,6 @@ nano::tomlconfig nano::load_toml_file (const std::filesystem::path & config_file { throw std::runtime_error (error.get_message ()); } + nano::default_logger ().info (nano::log::type::config, "Config for `{}` not found, using default configuration", config_filename.string ()); return toml; } \ No newline at end of file diff --git a/nano/lib/logging.cpp b/nano/lib/logging.cpp index b8e1236652..1a1222f8cb 100644 --- a/nano/lib/logging.cpp +++ b/nano/lib/logging.cpp @@ -72,7 +72,7 @@ void nano::nlogger::initialize (nano::log_config config) std::filesystem::path log_path{ "log" }; log_path /= filename + ".log"; - std::cout << "Logging to file: " << log_path << std::endl; + nano::default_logger ().info (nano::log::type::logging, "Logging to file: {}", log_path.string ()); // If either max_size or rotation_count is 0, then disable file rotation if (config.file.max_size == 0 || config.file.rotation_count == 0) diff --git a/nano/lib/logging_enums.hpp b/nano/lib/logging_enums.hpp index 551ec4bb2f..83f49fafa1 100644 --- a/nano/lib/logging_enums.hpp +++ b/nano/lib/logging_enums.hpp @@ -22,6 +22,8 @@ enum class type all = 0, // reserved generic, + config, + logging, node, node_wrapper, daemon,