9 #include <boost/thread/mutex.hpp>
10 #define COLOR_CONSOLE 1
11 #include "console_defines.h"
26 HANDLE console_handle;
48 my->console_handle = INVALID_HANDLE_VALUE;
50 my->cfg = console_appender_config;
53 my->console_handle = GetStdHandle(STD_ERROR_HANDLE);
55 my->console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
60 for(
auto itr = my->cfg.level_colors.begin(); itr != my->cfg.level_colors.end(); ++itr )
61 my->lc[itr->level] = itr->color;
82 return CONSOLE_DEFAULT;
87 static boost::mutex m;
return m;
94 std::stringstream file_line;
98 std::stringstream line;
100 line << std::setw( 10 ) << std::left << m.
get_context().
get_thread_name().substr(0,9).c_str() <<
" "<<std::setw(30)<< std::left <<file_line.str();
107 for( uint32_t i = 0;i < me.size(); ++i )
109 if( me[i] ==
':' ) p = i;
112 if( me[p] ==
':' ) ++p;
123 fprintf( out,
"\n" );
125 if( my->cfg.flush ) fflush( out );
133 if (my->console_handle != INVALID_HANDLE_VALUE)
134 SetConsoleTextAttribute(my->console_handle, get_console_color(text_color));
136 if(isatty(fileno(out))) fprintf( out,
"\r%s", get_console_color( text_color ) );
140 fprintf( out,
"%s", text.c_str() );
143 if (my->console_handle != INVALID_HANDLE_VALUE)
144 SetConsoleTextAttribute(my->console_handle, CONSOLE_DEFAULT);
146 if(isatty(fileno(out))) fprintf( out,
"\r%s", CONSOLE_DEFAULT );
149 if( my->cfg.flush ) fflush( out );