logging_macros.h

Go to the documentation of this file.
00001 #ifndef LOGGING_MACROS_GROUP
00002 #define LOGGING_MACROS_GROUP
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : logging macros                                                    *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1996-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00024 #include <basis/enhance_cpp.h>
00025 #include <loggers/logging_filters.h>
00026 #include <timely/time_stamp.h>
00027 
00029 #define update_current_stack_frame_line_number(x)
00030 
00032 
00035 #define FILTER_LOG(the_logger, to_log, filter) { \
00036   if (the_logger.member(filter)) { \
00037     the_logger.log(to_log, filter); \
00038   } \
00039 }
00040 
00042 #define EMERGENCY_LOG(the_logger, to_log) \
00043   FILTER_LOG(the_logger, to_log, basis::ALWAYS_PRINT)
00044 
00046 #define STAMPED_FILTER_LOG(the_logger, to_log, filter) { \
00047   if (the_logger.member(filter)) { \
00048     astring temp_log = to_log; \
00049     if (temp_log.length()) \
00050       temp_log.insert(0, timely::time_stamp::notarize(true)); \
00051     the_logger.log(temp_log, filter); \
00052   } \
00053 }
00054 
00055 #define STAMPED_EMERGENCY_LOG(the_logger, to_log) \
00056   STAMPED_FILTER_LOG(the_logger, to_log, basis::ALWAYS_PRINT)
00057 
00059 /* These add a class and function name to the log entry. */
00060 #define CLASS_FILTER_LOG(the_logger, to_log, filter) { \
00061   update_current_stack_frame_line_number(__LINE__); \
00062   if (the_logger.member(filter)) { \
00063     astring temp_log = to_log; \
00064     if (temp_log.length()) { \
00065       temp_log.insert(0, timely::time_stamp::notarize(true)); \
00066       BASE_FUNCTION(func); \
00067       temp_log += " ["; \
00068       temp_log += function_name; \
00069       temp_log += "]"; \
00070     } \
00071     the_logger.log(temp_log, filter); \
00072   } \
00073   update_current_stack_frame_line_number(__LINE__); \
00074 }
00075 
00076 #define CLASS_EMERGENCY_LOG(the_logger, to_log) \
00077   CLASS_FILTER_LOG(the_logger, to_log, basis::ALWAYS_PRINT)
00078 
00080 
00082 #define INSTANCE_FILTER_LOG(the_logger, to_log, filter) { \
00083   update_current_stack_frame_line_number(__LINE__); \
00084   if (the_logger.member(filter)) { \
00085     astring temp_log = to_log; \
00086     if (temp_log.length()) { \
00087       temp_log.insert(0, timely::time_stamp::notarize(true)); \
00088       BASE_INSTANCE_FUNCTION(func); \
00089       temp_log += " ["; \
00090       temp_log += function_name; \
00091       temp_log += "]"; \
00092     } \
00093     the_logger.log(temp_log, filter); \
00094     update_current_stack_frame_line_number(__LINE__); \
00095   } \
00096 }
00097 
00098 #define INSTANCE_EMERGENCY_LOG(the_logger, to_log) \
00099   INSTANCE_FILTER_LOG(the_logger, to_log, basis::ALWAYS_PRINT)
00100 
00101 #endif
00102 
Generated on Sat Jan 28 04:22:22 2012 for hoople2 project by  doxygen 1.6.3