00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _terimber_log_h_
00029 #define _terimber_log_h_
00030
00032 enum terimber_log_severity
00033 {
00034 en_log_paranoid = 1,
00035 en_log_info = 2,
00036 en_log_warning = 4,
00037 en_log_error = 8,
00038 en_log_xray = 16
00039 };
00040
00043 class terimber_log
00044 {
00045 public:
00047 virtual ~terimber_log() {}
00049 virtual
00050 bool
00051 v_is_logging( size_t module,
00052 const char* file,
00053 size_t line,
00054 terimber_log_severity severity
00055 ) const = 0;
00057 virtual
00058 void
00059 v_do_logging( size_t module,
00060 const char* file,
00061 size_t line,
00062 terimber_log_severity severity,
00063 const char* msg
00064 ) const = 0;
00066 void
00067 format_logging( size_t module,
00068 const char* file,
00069 size_t line,
00070 terimber_log_severity severity,
00071 const char* format,
00072 ...
00073 ) const;
00074 };
00075
00076
00079 class terimber_log_helper : public terimber_log
00080 {
00081 public:
00083 inline
00084 terimber_log_helper() : _log(0)
00085 {
00086 }
00087
00089 inline
00090 terimber_log*
00091 log_on( terimber_log* log
00092 )
00093 {
00094 terimber_log* old = _log;
00095 _log = log;
00096 return old;
00097 }
00098
00100 inline
00101 bool
00102 v_is_logging( size_t module,
00103 const char* file,
00104 size_t line,
00105 terimber_log_severity severity
00106 ) const
00107 {
00108
00109 terimber_log* log = _log;
00110 return log ? log->v_is_logging(module, file, line, severity) : false;
00111 }
00113 inline
00114 void
00115 v_do_logging( size_t module,
00116 const char* file,
00117 size_t line,
00118 terimber_log_severity severity,
00119 const char* msg
00120 ) const
00121 {
00122
00123 terimber_log* log = _log;
00124
00125
00126 if (log)
00127 log->v_do_logging(module, file, line, severity, msg);
00128 }
00129
00130 private:
00131 terimber_log * volatile _log;
00132 };
00133
00134 #endif
00135
00136
00137