Added set_all_logging_headers()

This commit is contained in:
Davis King 2015-02-25 07:52:35 -05:00
parent 2a224bf043
commit 0544b9aa72
3 changed files with 51 additions and 15 deletions

View File

@ -47,6 +47,21 @@ namespace dlib
gd.set_level("",new_level); gd.set_level("",new_level);
} }
void set_all_logging_headers (
const print_header_type& new_header
)
{
logger::global_data& gd = logger::get_global_data();
auto_mutex M(gd.m);
gd.loggers.reset();
while (gd.loggers.move_next())
{
gd.loggers.element()->print_header = new_header;
}
gd.set_logger_header("",new_header);
}
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
namespace logger_helper_stuff namespace logger_helper_stuff
@ -300,7 +315,7 @@ namespace dlib
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
logger::print_header_type logger::global_data:: print_header_type logger::global_data::
logger_header ( logger_header (
const std::string& name const std::string& name
) )

View File

@ -70,6 +70,17 @@ namespace dlib
const log_level& new_level const log_level& new_level
); );
typedef void (*print_header_type)(
std::ostream& out,
const std::string& logger_name,
const log_level& l,
const uint64 thread_id
);
void set_all_logging_headers (
const print_header_type& new_header
);
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
void print_default_logger_header ( void print_default_logger_header (
@ -352,13 +363,6 @@ namespace dlib
gd.set_output_hook(logger_name, hook); gd.set_output_hook(logger_name, hook);
} }
typedef void (*print_header_type)(
std::ostream& out,
const std::string& logger_name,
const log_level& l,
const uint64 thread_id
);
print_header_type logger_header ( print_header_type logger_header (
) const { return print_header; } ) const { return print_header; }
@ -602,6 +606,10 @@ namespace dlib
const log_level& new_level const log_level& new_level
); );
friend void set_all_logging_headers (
const print_header_type& new_header
);
friend void set_all_logging_output_streams ( friend void set_all_logging_output_streams (
std::ostream& out std::ostream& out
); );

View File

@ -79,6 +79,26 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
// ----------------------------------------------------------------------------------------
typedef void (*print_header_type)(
std::ostream& out,
const std::string& logger_name,
const log_level& l,
const uint64 thread_id
);
void set_all_logging_headers (
const print_header_type& new_header
);
/*!
ensures
- for all loggers L (even loggers not yet constructed):
- #L.logger_header() == new_header
throws
- std::bad_alloc
!*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
template < template <
@ -361,13 +381,6 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
typedef void (*print_header_type)(
std::ostream& out,
const std::string& logger_name,
const log_level& l,
const uint64 thread_id
);
print_header_type logger_header ( print_header_type logger_header (
) const; ) const;
/*! /*!