Skip to content

Commit

Permalink
GLOBAL LOGGING
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Jan 16, 2024
1 parent 0365131 commit b3e61a2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions nano/lib/config.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/config.hpp>
#include <nano/lib/logging.hpp>

#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
2 changes: 1 addition & 1 deletion nano/lib/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions nano/lib/logging_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ enum class type
all = 0, // reserved

generic,
config,
logging,
node,
node_wrapper,
daemon,
Expand Down

0 comments on commit b3e61a2

Please sign in to comment.