From 552847cccebe138fddbaaea1913f08efe3df3ca1 Mon Sep 17 00:00:00 2001 From: Jonathan Giszczak Date: Thu, 30 Nov 2017 13:25:11 -0600 Subject: [PATCH 1/2] Add logging configuration path and clean up version variables. --- application.cpp | 26 ++++++++++++++++---------- include/appbase/application.hpp | 21 ++++++++------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/application.cpp b/application.cpp index 6969b4ac4..83167cc7f 100644 --- a/application.cpp +++ b/application.cpp @@ -23,9 +23,9 @@ class application_impl { options_description _cfg_options; bfs::path _data_dir; + bfs::path _logging_conf; - string _version; - uint64_t _version_int; + uint64_t _version; }; application::application() @@ -35,20 +35,16 @@ application::application() application::~application() { } -void application::set_version(string version) { - my->_version = version; -} - void application::set_version(uint64_t version) { - my->_version_int = version; + my->_version = version; } -string application::version() const { +uint64_t application::version() const { return my->_version; } -uint64_t application::version_int() const { - return my->_version_int; +bfs::path application::get_logging_conf() const { + return my->_logging_conf; } void application::startup() { @@ -87,6 +83,7 @@ void application::set_program_options() ("version,v", "Print version information.") ("data-dir,d", bpo::value()->default_value( "data-dir" ), "Directory containing configuration file config.ini") ("config,c", bpo::value()->default_value( "config.ini" ), "Configuration file name relative to data-dir"); + ("logconf,l", bpo::value()->default_value( "logging.json" ), "Logging configuration file name/path"); my->_cfg_options.add(app_cfg_opts); my->_app_options.add(app_cfg_opts); @@ -109,6 +106,15 @@ bool application::initialize_impl(int argc, char** argv, vector(); + if( logconf.is_relative() ) + logconf = bfs::current_path() / logconf; + } + my->_logging_conf = logconf; + bfs::path data_dir = "data-dir"; if( options.count("data-dir") ) { diff --git a/include/appbase/application.hpp b/include/appbase/application.hpp index a43d7f78d..fbe4b3d09 100644 --- a/include/appbase/application.hpp +++ b/include/appbase/application.hpp @@ -13,26 +13,21 @@ namespace appbase { public: ~application(); - /** @brief Sets version string + /** @brief Set version * - * @param version Version string output verbatim with -v/--version - */ - void set_version(string version); - /** @overload - * - * @param version Integer version independent of the string output with -v/--version + * @param version Version output with -v/--version */ void set_version(uint64_t version); - /** @brief Gets version string + /** @brief Get version * - * @return Version string output with -v/--version + * @return Version output with -v/--version */ - string version() const; - /** @brief Gets version integer + uint64_t version() const; + /** @brief Get logging configuration path. * - * @return Version integer independent of the string output with -v/--version + * @return Logging configuration location from command line */ - uint64_t version_int() const; + bfs::path get_logging_conf() const; /** * @brief Looks for the --plugin commandline / config option and calls initialize on those plugins * From 1ecc4779b5d07c63e7193a604d263e278f0bb5a3 Mon Sep 17 00:00:00 2001 From: Jonathan Giszczak Date: Thu, 30 Nov 2017 14:04:34 -0600 Subject: [PATCH 2/2] CLI documentation clarification --- application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application.cpp b/application.cpp index 83167cc7f..d43e97f48 100644 --- a/application.cpp +++ b/application.cpp @@ -83,7 +83,7 @@ void application::set_program_options() ("version,v", "Print version information.") ("data-dir,d", bpo::value()->default_value( "data-dir" ), "Directory containing configuration file config.ini") ("config,c", bpo::value()->default_value( "config.ini" ), "Configuration file name relative to data-dir"); - ("logconf,l", bpo::value()->default_value( "logging.json" ), "Logging configuration file name/path"); + ("logconf,l", bpo::value()->default_value( "logging.json" ), "Logging configuration file name/path for library users"); my->_cfg_options.add(app_cfg_opts); my->_app_options.add(app_cfg_opts);