From 249dcd05eef352c7f402192c2a4a0637e445102b Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Sat, 15 Sep 2012 22:31:56 -0400 Subject: [PATCH] reverted to old log() method to accelerate compile times --- include/fc/log.hpp | 109 +++++++++------------------------------------ src/thread.cpp | 2 +- 2 files changed, 23 insertions(+), 88 deletions(-) diff --git a/include/fc/log.hpp b/include/fc/log.hpp index 7f9fccc..ab3f6c6 100644 --- a/include/fc/log.hpp +++ b/include/fc/log.hpp @@ -1,13 +1,19 @@ -/** - * @file mace/cmt/log/log.hpp - * @brief Defines helpful console logging methods. - */ -#ifndef _BOOST_RPC_LOG_HPP_ -#define _BOOST_RPC_LOG_HPP_ -#include -#include -#include -#include +#ifndef _FC_LOG_HPP_ +#define _FC_LOG_HPP_ +#include + +namespace boost { class mutex; } + +namespace fc { + /** wrapper on printf */ + void log( const char* color, const char* file_name, size_t line_num, const char* method_name, const char* format, ... ); + + /** used to add extra fields to be printed (thread,fiber,time,etc) */ + void add_log_field( void (*f)() ); + void remove_log_field( void (*f)() ); + + boost::mutex& log_mutex(); +} #ifndef __func__ #define __func__ __FUNCTION__ @@ -17,82 +23,11 @@ #define COLOR_CONSOLE 1 #endif #include -#include -#include -#include + +#define dlog(...) do { fc::log( CONSOLE_DEFAULT, __FILE__, __LINE__, __func__, __VA_ARGS__ ); }while(false) +#define slog(...) do { fc::log( CONSOLE_DEFAULT, __FILE__, __LINE__, __func__, __VA_ARGS__ ); }while(false) +#define wlog(...) do { fc::log( CONSOLE_BROWN, __FILE__, __LINE__, __func__, __VA_ARGS__ ); }while(false) +#define elog(...) do { fc::log( CONSOLE_RED, __FILE__, __LINE__, __func__, __VA_ARGS__ ); }while(false) -namespace fc { - const char* thread_name(); - - boost::mutex& log_mutex(); - namespace detail { - - inline std::string short_name( const std::string& file_name ) { return file_name.substr( file_name.rfind( '/' ) + 1 ); } - - inline void log( std::ostream& os, const char* color, const char* file, uint32_t line, const char* method, const char* text ) { - fc::unique_lock lock(log_mutex()); - os< - inline void log( std::ostream& os, const char* color, const char* file, uint32_t line, const char* method, const std::string& format, const P1& p1 ) { - fc::unique_lock lock(log_mutex()); - os< - inline void log( std::ostream& os, const char* color, const char* file, uint32_t line, const char* method, const std::string& format, const P1& p1, const P2& p2 ) { - fc::unique_lock lock(log_mutex()); - os< - inline void log( std::ostream& os, const char* color, const char* file, uint32_t line, const char* method, const std::string& format, const P1& p1, const P2& p2, const P3& p3 ) { - fc::unique_lock lock(log_mutex()); - os< - inline void log( std::ostream& os, const char* color, const char* file, uint32_t line, const char* method, const std::string& format, const P1& p1, const P2& p2, const P3& p3, const P4& p4 ) { - fc::unique_lock lock(log_mutex()); - os< - inline void log( std::ostream& os, const char* color, const char* file, uint32_t line, const char* method, const std::string& format, const P1& p1, const P2& p2, const P3& p3, const P4& p4, const P5& p5 ) { - fc::unique_lock lock(log_mutex()); - os< - inline void log( std::ostream& os, const char* color, const char* file, uint32_t line, const char* method, const std::string& format, const P1& p1, const P2& p2, const P3& p3, const P4& p4, const P5& p5, const P6& p6 ) { - fc::unique_lock lock(log_mutex()); - os<set_value(); exec(); } catch ( ... ) { - elog( "Caught unhandled exception %1%", boost::current_exception_diagnostic_information() ); + elog( "Caught unhandled exception %s", boost::current_exception_diagnostic_information().c_str() ); } delete this->my; this->my = 0;