feisty meow concerns codebase  2.140
logging_macros.h
Go to the documentation of this file.
1 #ifndef LOGGING_MACROS_GROUP
2 #define LOGGING_MACROS_GROUP
3 
4 /*****************************************************************************\
5 * *
6 * Name : logging macros *
7 * Author : Chris Koeritz *
8 * *
9 *******************************************************************************
10 * Copyright (c) 1996-$now By Author. This program is free software; you can *
11 * redistribute it and/or modify it under the terms of the GNU General Public *
12 * License as published by the Free Software Foundation; either version 2 of *
13 * the License or (at your option) any later version. This is online at: *
14 * http://www.fsf.org/copyleft/gpl.html *
15 * Please send any updates to: fred@gruntose.com *
16 \*****************************************************************************/
17 
25 #include <basis/enhance_cpp.h>
27 #include <timely/time_stamp.h>
28 
31 
33 
36 #define FILTER_LOG(the_logger, to_log, filter) { \
37  if (the_logger.member(filter)) { \
38  the_logger.log(to_log, filter); \
39  } \
40 }
41 
43 #define EMERGENCY_LOG(the_logger, to_log) \
44  FILTER_LOG(the_logger, to_log, basis::ALWAYS_PRINT)
45 
47 #define STAMPED_FILTER_LOG(the_logger, to_log, filter) { \
48  if (the_logger.member(filter)) { \
49  astring temp_log = to_log; \
50  if (temp_log.length()) \
51  temp_log.insert(0, timely::time_stamp::notarize(true)); \
52  the_logger.log(temp_log, filter); \
53  } \
54 }
56 #define STAMPED_EMERGENCY_LOG(the_logger, to_log) \
57  STAMPED_FILTER_LOG(the_logger, to_log, basis::ALWAYS_PRINT)
58 
60 /* These add a class and function name to the log entry. */
61 #define CLASS_FILTER_LOG(the_logger, to_log, filter) { \
62  application::update_current_stack_frame_line_number(__LINE__); \
63  if (the_logger.member(filter)) { \
64  astring temp_log = to_log; \
65  if (temp_log.length()) { \
66  temp_log.insert(0, timely::time_stamp::notarize(true)); \
67  BASE_FUNCTION(func); \
68  temp_log += " ["; \
69  temp_log += function_name; \
70  temp_log += "]"; \
71  } \
72  the_logger.log(temp_log, filter); \
73  } \
74  application::update_current_stack_frame_line_number(__LINE__); \
75 }
77 #define CLASS_EMERGENCY_LOG(the_logger, to_log) \
78  CLASS_FILTER_LOG(the_logger, to_log, basis::ALWAYS_PRINT)
79 
81 
83 #define INSTANCE_FILTER_LOG(the_logger, to_log, filter) { \
84  application::update_current_stack_frame_line_number(__LINE__); \
85  if (the_logger.member(filter)) { \
86  astring temp_log = to_log; \
87  if (temp_log.length()) { \
88  temp_log.insert(0, timely::time_stamp::notarize(true)); \
89  BASE_INSTANCE_FUNCTION(func); \
90  temp_log += " ["; \
91  temp_log += function_name; \
92  temp_log += "]"; \
93  } \
94  the_logger.log(temp_log, filter); \
95  application::update_current_stack_frame_line_number(__LINE__); \
96  } \
97 }
99 #define INSTANCE_EMERGENCY_LOG(the_logger, to_log) \
100  INSTANCE_FILTER_LOG(the_logger, to_log, basis::ALWAYS_PRINT)
101 
102 #endif
103