diff --git a/console/executor.cpp b/console/executor.cpp index d5a0da2b..78404901 100644 --- a/console/executor.cpp +++ b/console/executor.cpp @@ -41,6 +41,8 @@ using namespace bc::database; using namespace bc::network; using namespace std::placeholders; +namespace keywords = boost::log::keywords; + static const auto application_name = "bs"; static constexpr int initialize_stop = 0; static constexpr int directory_exists = 0; @@ -53,16 +55,28 @@ executor::executor(parser& metadata, std::istream& input, std::ostream& output, std::ostream& error) : metadata_(metadata), output_(output), error_(error) { - const auto debug_file = metadata_.configured.network.debug_file.string(); - const auto error_file = metadata_.configured.network.error_file.string(); - - auto debug_log = boost::make_shared(debug_file, mode); - auto error_log = boost::make_shared(error_file, mode); + const log::file_sink_configuration debug_file = { + metadata_.configured.network.debug_file.string(), + metadata_.configured.network.logs_path.string(), + metadata_.configured.network.log_rotation_size, +// metadata_.configured.network.log_max_files, + metadata_.configured.network.log_max_files_size, + metadata_.configured.network.log_min_free_space + }; + + const log::file_sink_configuration error_file = { + metadata_.configured.network.error_file.string(), + metadata_.configured.network.logs_path.string(), + metadata_.configured.network.log_rotation_size, +// metadata_.configured.network.log_max_files, + metadata_.configured.network.log_max_files_size, + metadata_.configured.network.log_min_free_space + }; log::stream console_out(&output_, null_deleter()); log::stream console_err(&error_, null_deleter()); - log::initialize(debug_log, error_log, console_out, console_err); + log::initialize(debug_file, error_file, console_out, console_err); handle_stop(initialize_stop); } diff --git a/src/parser.cpp b/src/parser.cpp index a9450ce4..d42a7a05 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -234,6 +234,31 @@ options_metadata parser::load_settings() value(&configured.network.error_file), "The error log file path, defaults to 'error.log'." ) + ( + "network.logs_path", + value(&configured.network.logs_path), + "The path to log files not including name, defaults to 'logs'." + ) + ( + "network.log_rotation_size", + value(&configured.network.log_rotation_size), + "The size at which logs are to be rotated, defaults to 'maximum'." + ) +// ( +// "network.log_max_files", +// value(&configured.network.log_max_files), +// "The maximum number of logs to persist, defaults to 'maximum'." +// ) + ( + "network.log_max_files_size", + value(&configured.network.log_max_files_size), + "The cumulative maximum size in bytes of logs, defaults to 'maximum'." + ) + ( + "network.log_min_free_space", + value(&configured.network.log_min_free_space), + "The minimum free space in bytes to be maintained in the logs_path, defaults to '0'." + ) ( "network.self", value(&configured.network.self),