14 using std::stringstream;
15 using std::setprecision;
25 message::message(
const string& aKey,
const string& aDescription,
const string& aPrefix,
const string& aSuffix ) :
27 f_system_description( aDescription ),
28 f_system_prefix( aPrefix ),
29 f_system_suffix( aSuffix ),
31 f_error_color_prefix(
"\33[31;1m" ),
32 f_error_color_suffix(
"\33[0m" ),
33 f_error_description(
"error" ),
35 f_warning_color_prefix(
"\33[33;1m" ),
36 f_warning_color_suffix(
"\33[0m" ),
37 f_warning_description(
"warning" ),
39 f_normal_color_prefix(
"\33[32;1m" ),
40 f_normal_color_suffix(
"\33[0m" ),
41 f_normal_description(
"normal" ),
43 f_debug_color_prefix(
"\33[36;1m" ),
44 f_debug_color_suffix(
"\33[0m" ),
45 f_debug_description(
"debug" ),
47 f_default_color_prefix(
"\33[37;1m" ),
48 f_default_color_suffix(
"\33[0m" ),
49 f_default_description(
"unknown" ),
53 f_color_prefix( &
message::f_normal_color_prefix ),
54 f_description( &
message::f_normal_description ),
55 f_color_suffix( &
message::f_normal_color_suffix ),
60 f_terminal_severity(
messages::get_instance()->get_terminal_severity() ),
61 f_terminal_stream(
messages::get_instance()->get_terminal_stream() ),
62 f_log_severity(
messages::get_instance()->get_log_severity() ),
63 f_log_stream(
messages::get_instance()->get_log_stream() )
65 f_message_line.setf( messages::get_instance()->get_format(), std::ios::floatfield );
66 f_message_line.precision( messages::get_instance()->GetPrecision() );
67 messages::get_instance()->add(
this );
71 messages::get_instance()->remove(
this );
131 (*f_terminal_stream).flush();
140 (*f_log_stream).flush();
158 const size_t t_max_frames = 512;
159 void* t_frame_array[ t_max_frames ];
160 const size_t t_frame_count = backtrace( t_frame_array, t_max_frames );
161 char** t_frame_symbols = backtrace_symbols( t_frame_array, t_frame_count );
167 for(
size_t Index = 0; Index < t_frame_count; Index++ )
171 (*f_terminal_stream).flush();
178 for(
size_t t_index = 0; t_index < t_frame_count; t_index++ )
182 (*f_log_stream).flush();
185 free( t_frame_symbols );
228 f_threads.insert( std::this_thread::get_id() );
254 f_threads.erase( std::this_thread::get_id() );
274 f_format(
std::cout.flags() ),
275 f_precision(
std::cout.precision() ),
276 #ifdef MIDGE_ENABLE_DEBUG_MESSAGES
282 #ifdef MIDGE_ENABLE_DEBUG_MESSAGES
297 if( tIter ==
f_map.end() )
306 if( tIter !=
f_map.end() )
308 return tIter->second;
315 if( tIter !=
f_map.end() )
317 f_map.erase( tIter );
326 for( tIter =
f_map.begin(); tIter !=
f_map.end(); tIter++ )
328 tIter->second->set_format(
f_format );
341 for( tIter =
f_map.begin(); tIter !=
f_map.end(); tIter++ )
356 for( tIter =
f_map.begin(); tIter !=
f_map.end(); tIter++ )
371 for( tIter =
f_map.begin(); tIter !=
f_map.end(); tIter++ )
386 for( tIter =
f_map.begin(); tIter !=
f_map.end(); tIter++ )
401 for( tIter =
f_map.begin(); tIter !=
f_map.end(); tIter++ )
void set_terminal_stream(std::ostream *aTerminalStream)
void set_terminal_severity(const message_severity &aVerbosity)
message_severity f_log_severity
const message_severity & get_log_severity()
void set_precision(const message_precision &aPrecision)
void set_precision(const message_precision &aPrecision)
std::string message::* f_color_suffix
std::string f_system_suffix
std::string f_system_description
std::ostream * f_terminal_stream
void add(message *aMessage)
std::vector< std::string > f_message_lines
std::string f_error_description
void set_format(const message_format &aFormat)
void set_severity(const message_severity &aSeverity)
static std::mutex f_inner
static const message_severity s_debug
std::string f_normal_color_suffix
message_severity f_terminal_severity
std::streamsize message_precision
std::string f_warning_color_suffix
static const message_severity s_error
void set_terminal_severity(const message_severity &aVerbosity)
std::string f_warning_color_prefix
map_t::value_type entry_t
std::string f_debug_color_prefix
void set_format(const message_format &aFormat)
std::stringstream f_message_line
message_severity f_log_severity
message * get(const std::string &aKey)
std::ostream * f_log_stream
void set_log_severity(const message_severity &aVerbosity)
std::string message::* f_description
void set_terminal_stream(std::ostream *aTerminalStream)
std::ios_base::fmtflags message_format
void set_log_stream(std::ostream *aLogStream)
static const message_severity s_normal
static const message_severity s_warning
std::string f_system_prefix
std::string f_normal_color_prefix
std::string f_normal_description
static std::set< std::thread::id > f_threads
message_define(testmsg, test, test) using namespace midge
std::string message::* f_color_prefix
message_severity f_severity
std::string f_error_color_prefix
std::ostream * get_log_stream()
message_severity f_terminal_severity
void set_log_severity(const message_severity &aVerbosity)
const message_precision & GetPrecision()
void remove(message *aMessage)
std::string f_error_color_suffix
std::ostream * f_terminal_stream
const std::string & get_key() const
std::ostream * f_log_stream
std::string f_debug_description
const message_format & get_format()
message_precision f_precision
std::string f_warning_description
std::ostream * get_terminal_stream()
static std::mutex f_outer
void set_log_stream(std::ostream *aLogStream)
const message_severity & get_terminal_severity()
std::string f_debug_color_suffix
void set_key(const std::string &aKey)