Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions console/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<bc::ofstream>(debug_file, mode);
auto error_log = boost::make_shared<bc::ofstream>(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);
}

Expand Down
25 changes: 25 additions & 0 deletions src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,31 @@ options_metadata parser::load_settings()
value<path>(&configured.network.error_file),
"The error log file path, defaults to 'error.log'."
)
(
"network.logs_path",
value<path>(&configured.network.logs_path),
"The path to log files not including name, defaults to 'logs'."
)
(
"network.log_rotation_size",
value<uintmax_t>(&configured.network.log_rotation_size),
"The size at which logs are to be rotated, defaults to 'maximum'."
)
// (
// "network.log_max_files",
// value<uintmax_t>(&configured.network.log_max_files),
// "The maximum number of logs to persist, defaults to 'maximum'."
// )
(
"network.log_max_files_size",
value<uintmax_t>(&configured.network.log_max_files_size),
"The cumulative maximum size in bytes of logs, defaults to 'maximum'."
)
(
"network.log_min_free_space",
value<uintmax_t>(&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<config::authority>(&configured.network.self),
Expand Down