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 );
std::string format_string(const std::string &, const variant_object &, uint32_t max_object_depth=200)
Defines types and helper macros necessary for generating log messages.
std::string get_thread_name() const
void configure(const config &cfg)
log_context get_context() const
std::string get_format() const
virtual void log(const log_message &m)
std::string get_method() const
color::type lc[log_level::off+1]
#define FC_MAX_LOG_OBJECT_DEPTH
time_point get_timestamp() const
const microseconds & time_since_epoch() const
variant_object get_data() const
#define FC_CAPTURE_AND_RETHROW(...)
void print(const std::string &text_to_print, color::type text_color=color::console_default)
T as(uint32_t max_depth) const
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
log_level get_log_level() const
Defines exception's used by fc.
boost::mutex & log_mutex()
aggregates a message along with the context and associated meta-information.
std::string get_file() const
uint64_t get_line_number() const