OFFIS DCMTK  Version 3.6.0
oflog.h
1 /*
2  *
3  * Copyright (C) 2009-2010, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: oflog
15  *
16  * Author: Uli Schlachter
17  *
18  * Purpose: Simplify the usage of log4cplus to other modules (Header)
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-10-14 13:20:52 $
22  * CVS/RCS Revision: $Revision: 1.12 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 
30 #ifndef OFLOG_H
31 #define OFLOG_H
32 
33 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
34 
35 #include "dcmtk/oflog/logger.h"
36 #include "dcmtk/ofstd/oftypes.h"
37 #include "dcmtk/ofstd/ofconapp.h"
38 
39 #define OFLOG_TRACE(logger, msg) LOG4CPLUS_TRACE(logger, msg)
40 #define OFLOG_DEBUG(logger, msg) LOG4CPLUS_DEBUG(logger, msg)
41 #define OFLOG_INFO(logger, msg) LOG4CPLUS_INFO(logger, msg)
42 #define OFLOG_WARN(logger, msg) LOG4CPLUS_WARN(logger, msg)
43 #define OFLOG_ERROR(logger, msg) LOG4CPLUS_ERROR(logger, msg)
44 #define OFLOG_FATAL(logger, msg) LOG4CPLUS_FATAL(logger, msg)
45 
49 class OFLogger : private log4cplus::Logger
50 {
51 public:
55  OFLogger(const log4cplus::Logger &base);
56 
58  enum LogLevel {
60  TRACE_LOG_LEVEL = log4cplus::TRACE_LOG_LEVEL,
62  DEBUG_LOG_LEVEL = log4cplus::DEBUG_LOG_LEVEL,
64  INFO_LOG_LEVEL = log4cplus::INFO_LOG_LEVEL,
66  WARN_LOG_LEVEL = log4cplus::WARN_LOG_LEVEL,
68  ERROR_LOG_LEVEL = log4cplus::ERROR_LOG_LEVEL,
70  FATAL_LOG_LEVEL = log4cplus::FATAL_LOG_LEVEL
71  };
72 
82  bool isEnabledFor(log4cplus::LogLevel ll) const {
83  return Logger::isEnabledFor(ll);
84  }
85 
87  void forcedLog(log4cplus::LogLevel ll, const log4cplus::tstring& message,
88  const char* file=NULL, int line=-1, const char* function=NULL) const {
89  Logger::forcedLog(ll, message, file, line, function);
90  }
91 
99  return OFstatic_cast(LogLevel, Logger::getChainedLogLevel());
100  }
101 };
102 
105 class OFLog
106 {
107  private:
108 
111  OFLog() { }
112 
116  static void configureLogger(log4cplus::LogLevel level);
117 
118  public:
119 
123  static OFLogger getLogger(const char *name);
124 
129 
135 
139  static void addOptions(OFCommandLine &cmd);
140 
146  static void reconfigure(OFCommandLine *cmd = NULL);
147 
148  private:
149 
152 };
153 
154 #endif
155 
156 
157 /*
158  *
159  * CVS/RCS Log:
160  * $Log: oflog.h,v $
161  * Revision 1.12 2010-10-14 13:20:52 joergr
162  * Updated copyright header. Added reference to COPYRIGHT file.
163  *
164  * Revision 1.11 2010-08-05 08:38:11 uli
165  * Fixed some warnings from -Wold-style-cast.
166  *
167  * Revision 1.10 2010-05-14 12:29:55 uli
168  * Added new function OFLog::reconfigure() which reinterprets the logger config
169  * file. This can e.g. be useful for logging to a different file after fork().
170  *
171  * Revision 1.9 2010-04-26 12:22:30 uli
172  * Fixed a some minor doxygen warnings.
173  *
174  * Revision 1.8 2010-04-23 11:04:46 uli
175  * Updated oflog to log4cplus revision 1200 from PRODUCTION_1_0_x branch.
176  *
177  * Revision 1.7 2010-03-08 10:50:40 uli
178  * Don't use "using" to fix compilation with MSVC6.
179  *
180  * Revision 1.6 2009-11-17 14:26:21 uli
181  * Make OFLogger::getChainedLogLevel() accessible.
182  *
183  * Revision 1.5 2009-11-06 09:41:22 joergr
184  * Changed documentation on log level "trace".
185  *
186  * Revision 1.4 2009-09-16 10:04:26 joergr
187  * Changed OFLogger's copy constructor: use "const &" for the parameter.
188  * Added missing documentation on parameters.
189  *
190  * Revision 1.3 2009-09-14 10:51:05 joergr
191  * Removed (now) unused helper function toLogMode().
192  *
193  * Revision 1.2 2009-08-20 12:08:02 joergr
194  * Added documentation on log level values.
195  *
196  * Revision 1.1 2009-08-19 11:54:00 joergr
197  * Added new module "oflog" which is based on log4cplus.
198  *
199  *
200  */


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2