Commit 10d265db authored by Davis King's avatar Davis King

Added an overload of configure_loggers_from_file() that can read directly from

a config_reader.
parent 89f3e775
...@@ -19,7 +19,6 @@ namespace dlib ...@@ -19,7 +19,6 @@ namespace dlib
namespace logger_config_file_helpers namespace logger_config_file_helpers
{ {
typedef config_reader::kernel_1a cr_type;
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
...@@ -84,7 +83,7 @@ namespace dlib ...@@ -84,7 +83,7 @@ namespace dlib
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
void configure_sub_blocks ( void configure_sub_blocks (
const cr_type& cr, const config_reader& cr,
const std::string& name const std::string& name
) )
{ {
...@@ -138,24 +137,29 @@ namespace dlib ...@@ -138,24 +137,29 @@ namespace dlib
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
void configure_loggers_from_file ( void configure_loggers_from_file (
const std::string& file_name const std::string& file_name
) )
{ {
using namespace logger_config_file_helpers; std::ifstream fin(file_name.c_str());
using namespace std;
ifstream fin(file_name.c_str());
if (!fin) if (!fin)
throw logger_config_file_error("logger_config: unable to open config file " + file_name); throw logger_config_file_error("logger_config: unable to open config file " + file_name);
configure_loggers_from_file(config_reader(fin));
}
cr_type main_cr; // ----------------------------------------------------------------------------------------
main_cr.load_from(fin);
void configure_loggers_from_file (
const config_reader& main_cr
)
{
using namespace logger_config_file_helpers;
using namespace std;
if (main_cr.is_block_defined("logger_config")) if (main_cr.is_block_defined("logger_config"))
{ {
const cr_type& cr = main_cr.block("logger_config"); const config_reader& cr = main_cr.block("logger_config");
if (cr.is_key_defined("logging_level")) if (cr.is_key_defined("logging_level"))
{ {
......
...@@ -34,6 +34,19 @@ namespace dlib ...@@ -34,6 +34,19 @@ namespace dlib
this exception is thrown if there is a problem reading the config file this exception is thrown if there is a problem reading the config file
!*/ !*/
void configure_loggers_from_file (
const config_reader& cr
);
/*!
ensures
- configures the loggers with the contents of cr. This function is just like
the above version that reads from a file except that it reads from an in-memory
config_reader instead.
throws
- dlib::logger_config_file_error
this exception is thrown if there is a problem reading the config file
!*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
/*! /*!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment