From b348200ebf3a6b4adc64bc58e58d8ddfc801d240 Mon Sep 17 00:00:00 2001 From: Steve Gerbino Date: Fri, 29 Sep 2023 16:14:39 -0400 Subject: [PATCH 1/4] Upgrade log library to v2.0.0 --- CMakeLists.txt | 2 +- libraries/log | 2 +- programs/koinos_chain/main.cpp | 24 ++++++++++++++++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e56b0b4..dcfe2639 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ HunterGate( LOCAL ) -project(koinos_chain VERSION 1.1.0 LANGUAGES CXX C) +project(koinos_chain VERSION 1.2.0 LANGUAGES CXX C) add_compile_definitions(KOINOS_MAJOR_VERSION=${PROJECT_VERSION_MAJOR}) add_compile_definitions(KOINOS_MINOR_VERSION=${PROJECT_VERSION_MINOR}) add_compile_definitions(KOINOS_PATCH_VERSION=${PROJECT_VERSION_PATCH}) diff --git a/libraries/log b/libraries/log index ca1fdcbb..3475592e 160000 --- a/libraries/log +++ b/libraries/log @@ -1 +1 @@ -Subproject commit ca1fdcbb26ee2d9c2c45f8692747b3f7a5235025 +Subproject commit 3475592ef6c306dfe5750d3a8b18692e1116fcc1 diff --git a/programs/koinos_chain/main.cpp b/programs/koinos_chain/main.cpp index b57e156c..33a3d8ac 100644 --- a/programs/koinos_chain/main.cpp +++ b/programs/koinos_chain/main.cpp @@ -48,6 +48,10 @@ #define AMQP_DEFAULT "amqp://guest:guest@localhost:5672/" #define LOG_LEVEL_OPTION "log-level" #define LOG_LEVEL_DEFAULT "info" +#define LOG_DIR_OPTION "log-dir" +#define LOG_DIR_DEFAULT "" +#define LOG_COLOR_OPTION "log-color" +#define LOG_COLOR_DEFAULT false #define INSTANCE_ID_OPTION "instance-id" #define STATEDIR_OPTION "statedir" #define JOBS_OPTION "jobs" @@ -72,11 +76,11 @@ void attach_request_handler( chain::controller& controller, mq::request_handler& int main( int argc, char** argv ) { - std::string amqp_url, log_level, instance_id, fork_algorithm_option; + std::string amqp_url, log_level, log_dir, instance_id, fork_algorithm_option; std::filesystem::path statedir, genesis_data_file; uint64_t jobs, read_compute_limit; chain::genesis_data genesis_data; - bool reset; + bool reset, log_color; chain::fork_resolution_algorithm fork_algorithm; try @@ -96,7 +100,9 @@ int main( int argc, char** argv ) (STATEDIR_OPTION , program_options::value< std::string >(), "The location of the blockchain state files (absolute path or relative to basedir/chain)") (RESET_OPTION , program_options::value< bool >(), "Reset the database") - (FORK_ALGORITHM_OPTION ",f", program_options::value< std::string >(), "The fork resolution algorithm to use. Can be 'fifo', 'pob', or 'block-time'. (Default: 'fifo')"); + (FORK_ALGORITHM_OPTION ",f", program_options::value< std::string >(), "The fork resolution algorithm to use. Can be 'fifo', 'pob', or 'block-time'. (Default: 'fifo')") + (LOG_DIR_OPTION , program_options::value< std::string >(), "The logging directory") + (LOG_COLOR_OPTION , program_options::value< bool >(), "Log color toggle"); program_options::variables_map args; program_options::store( program_options::parse_command_line( argc, argv, options ), args ); @@ -138,6 +144,8 @@ int main( int argc, char** argv ) amqp_url = util::get_option< std::string >( AMQP_OPTION, AMQP_DEFAULT, args, chain_config, global_config ); log_level = util::get_option< std::string >( LOG_LEVEL_OPTION, LOG_LEVEL_DEFAULT, args, chain_config, global_config ); + log_dir = util::get_option< std::string >( LOG_DIR_OPTION, LOG_DIR_DEFAULT, args, chain_config, global_config ); + log_color = util::get_option< bool >( LOG_COLOR_OPTION, LOG_COLOR_DEFAULT, args, chain_config, global_config ); instance_id = util::get_option< std::string >( INSTANCE_ID_OPTION, util::random_alphanumeric( 5 ), args, chain_config, global_config ); statedir = std::filesystem::path( util::get_option< std::string >( STATEDIR_OPTION, STATEDIR_DEFAULT, args, chain_config, global_config ) ); genesis_data_file = std::filesystem::path( util::get_option< std::string >( GENESIS_DATA_FILE_OPTION, GENESIS_DATA_FILE_DEFAULT, args, chain_config, global_config ) ); @@ -146,7 +154,15 @@ int main( int argc, char** argv ) read_compute_limit = util::get_option< uint64_t >( READ_COMPUTE_BANDWITH_LIMIT_OPTION, READ_COMPUTE_BANDWITH_LIMIT_DEFAULT, args, chain_config, global_config ); fork_algorithm_option = util::get_option< std::string >( FORK_ALGORITHM_OPTION, FORK_ALGORITHM_DEFAULT, args, chain_config, global_config ); - koinos::initialize_logging( util::service::chain, instance_id, log_level, basedir / util::service::chain / "logs" ); + std::optional< std::filesystem::path > logdir_path; + if ( !log_dir.empty() ) + { + logdir_path = std::make_optional< std::filesystem::path >( log_dir ); + if ( logdir_path->is_relative() ) + logdir_path = basedir / util::service::chain / *logdir_path; + } + + koinos::initialize_logging( util::service::chain, instance_id, log_level, logdir_path, log_color ); LOG(info) << version_string(); From ae16345a5348f14286013805305a2e8dc0267c0b Mon Sep 17 00:00:00 2001 From: Steve Gerbino Date: Mon, 2 Oct 2023 17:31:17 -0400 Subject: [PATCH 2/4] Updated to include log-datetime flag --- libraries/log | 2 +- programs/koinos_chain/main.cpp | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libraries/log b/libraries/log index 3475592e..26a6f7cd 160000 --- a/libraries/log +++ b/libraries/log @@ -1 +1 @@ -Subproject commit 3475592ef6c306dfe5750d3a8b18692e1116fcc1 +Subproject commit 26a6f7cd9bcc46a10608e9e48bda8f2f04799865 diff --git a/programs/koinos_chain/main.cpp b/programs/koinos_chain/main.cpp index 33a3d8ac..da42f921 100644 --- a/programs/koinos_chain/main.cpp +++ b/programs/koinos_chain/main.cpp @@ -51,7 +51,9 @@ #define LOG_DIR_OPTION "log-dir" #define LOG_DIR_DEFAULT "" #define LOG_COLOR_OPTION "log-color" -#define LOG_COLOR_DEFAULT false +#define LOG_COLOR_DEFAULT true +#define LOG_DATETIME_OPTION "log-datetime" +#define LOG_DATETIME_DEFAULT true #define INSTANCE_ID_OPTION "instance-id" #define STATEDIR_OPTION "statedir" #define JOBS_OPTION "jobs" @@ -102,7 +104,8 @@ int main( int argc, char** argv ) (RESET_OPTION , program_options::value< bool >(), "Reset the database") (FORK_ALGORITHM_OPTION ",f", program_options::value< std::string >(), "The fork resolution algorithm to use. Can be 'fifo', 'pob', or 'block-time'. (Default: 'fifo')") (LOG_DIR_OPTION , program_options::value< std::string >(), "The logging directory") - (LOG_COLOR_OPTION , program_options::value< bool >(), "Log color toggle"); + (LOG_COLOR_OPTION , program_options::value< bool >(), "Log color toggle") + (LOG_DATETIME_OPTION , program_options::value< bool >(), "Log datetime on console toggle"); program_options::variables_map args; program_options::store( program_options::parse_command_line( argc, argv, options ), args ); @@ -146,6 +149,7 @@ int main( int argc, char** argv ) log_level = util::get_option< std::string >( LOG_LEVEL_OPTION, LOG_LEVEL_DEFAULT, args, chain_config, global_config ); log_dir = util::get_option< std::string >( LOG_DIR_OPTION, LOG_DIR_DEFAULT, args, chain_config, global_config ); log_color = util::get_option< bool >( LOG_COLOR_OPTION, LOG_COLOR_DEFAULT, args, chain_config, global_config ); + log_datetime = util::get_option< bool >( LOG_DATETIME_OPTION, LOG_DATETIME_DEFAULT, args, chain_config, global_config ); instance_id = util::get_option< std::string >( INSTANCE_ID_OPTION, util::random_alphanumeric( 5 ), args, chain_config, global_config ); statedir = std::filesystem::path( util::get_option< std::string >( STATEDIR_OPTION, STATEDIR_DEFAULT, args, chain_config, global_config ) ); genesis_data_file = std::filesystem::path( util::get_option< std::string >( GENESIS_DATA_FILE_OPTION, GENESIS_DATA_FILE_DEFAULT, args, chain_config, global_config ) ); @@ -162,7 +166,7 @@ int main( int argc, char** argv ) logdir_path = basedir / util::service::chain / *logdir_path; } - koinos::initialize_logging( util::service::chain, instance_id, log_level, logdir_path, log_color ); + koinos::initialize_logging( util::service::chain, instance_id, log_level, logdir_path, log_color, log_datetime ); LOG(info) << version_string(); From cf7b7871e1084ecaedde49d8c6dd47e16a87a61c Mon Sep 17 00:00:00 2001 From: Steve Gerbino Date: Mon, 2 Oct 2023 17:33:32 -0400 Subject: [PATCH 3/4] Declare log_datetime --- programs/koinos_chain/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/koinos_chain/main.cpp b/programs/koinos_chain/main.cpp index da42f921..7cd6db55 100644 --- a/programs/koinos_chain/main.cpp +++ b/programs/koinos_chain/main.cpp @@ -82,7 +82,7 @@ int main( int argc, char** argv ) std::filesystem::path statedir, genesis_data_file; uint64_t jobs, read_compute_limit; chain::genesis_data genesis_data; - bool reset, log_color; + bool reset, log_color, log_datetime; chain::fork_resolution_algorithm fork_algorithm; try From 71baed38f7bc0225d3c620f67cfd2dc9477a1279 Mon Sep 17 00:00:00 2001 From: Steve Gerbino Date: Tue, 3 Oct 2023 14:10:49 -0400 Subject: [PATCH 4/4] Bump log library to v2.0.0 --- libraries/log | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/log b/libraries/log index 26a6f7cd..89b59cd4 160000 --- a/libraries/log +++ b/libraries/log @@ -1 +1 @@ -Subproject commit 26a6f7cd9bcc46a10608e9e48bda8f2f04799865 +Subproject commit 89b59cd48bd4e41ca1d377890af1de3d393f60f8