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 
24 #include <basis/enhance_cpp.h>
26 #include <timely/time_stamp.h>
27 
29 #define update_current_stack_frame_line_number(x)
30 
32 
35 #define FILTER_LOG(the_logger, to_log, filter) { \
36  if (the_logger.member(filter)) { \
37  the_logger.log(to_log, filter); \
38  } \
39 }
40 
42 #define EMERGENCY_LOG(the_logger, to_log) \
43  FILTER_LOG(the_logger, to_log, basis::ALWAYS_PRINT)
44 
46 #define STAMPED_FILTER_LOG(the_logger, to_log, filter) { \
47  if (the_logger.member(filter)) { \
48  astring temp_log = to_log; \
49  if (temp_log.length()) \
50  temp_log.insert(0, timely::time_stamp::notarize(true)); \
51  the_logger.log(temp_log, filter); \
52  } \
53 }
55 #define STAMPED_EMERGENCY_LOG(the_logger, to_log) \
56  STAMPED_FILTER_LOG(the_logger, to_log, basis::ALWAYS_PRINT)
57 
59 /* These add a class and function name to the log entry. */
60 #define CLASS_FILTER_LOG(the_logger, to_log, filter) { \
61  update_current_stack_frame_line_number(__LINE__); \
62  if (the_logger.member(filter)) { \
63  astring temp_log = to_log; \
64  if (temp_log.length()) { \
65  temp_log.insert(0, timely::time_stamp::notarize(true)); \
66  BASE_FUNCTION(func); \
67  temp_log += " ["; \
68  temp_log += function_name; \
69  temp_log += "]"; \
70  } \
71  the_logger.log(temp_log, filter); \
72  } \
73  update_current_stack_frame_line_number(__LINE__); \
74 }
76 #define CLASS_EMERGENCY_LOG(the_logger, to_log) \
77  CLASS_FILTER_LOG(the_logger, to_log, basis::ALWAYS_PRINT)
78 
80 
82 #define INSTANCE_FILTER_LOG(the_logger, to_log, filter) { \
83  update_current_stack_frame_line_number(__LINE__); \
84  if (the_logger.member(filter)) { \
85  astring temp_log = to_log; \
86  if (temp_log.length()) { \
87  temp_log.insert(0, timely::time_stamp::notarize(true)); \
88  BASE_INSTANCE_FUNCTION(func); \
89  temp_log += " ["; \
90  temp_log += function_name; \
91  temp_log += "]"; \
92  } \
93  the_logger.log(temp_log, filter); \
94  update_current_stack_frame_line_number(__LINE__); \
95  } \
96 }
98 #define INSTANCE_EMERGENCY_LOG(the_logger, to_log) \
99  INSTANCE_FILTER_LOG(the_logger, to_log, basis::ALWAYS_PRINT)
100 
101 #endif
102