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
00029
00030 #ifndef OFLOG_H
00031 #define OFLOG_H
00032
00033 #include "dcmtk/config/osconfig.h"
00034
00035 #include "dcmtk/oflog/logger.h"
00036 #include "dcmtk/ofstd/oftypes.h"
00037 #include "dcmtk/ofstd/ofconapp.h"
00038
00039 #define OFLOG_TRACE(logger, msg) LOG4CPLUS_TRACE(logger, msg)
00040 #define OFLOG_DEBUG(logger, msg) LOG4CPLUS_DEBUG(logger, msg)
00041 #define OFLOG_INFO(logger, msg) LOG4CPLUS_INFO(logger, msg)
00042 #define OFLOG_WARN(logger, msg) LOG4CPLUS_WARN(logger, msg)
00043 #define OFLOG_ERROR(logger, msg) LOG4CPLUS_ERROR(logger, msg)
00044 #define OFLOG_FATAL(logger, msg) LOG4CPLUS_FATAL(logger, msg)
00045
00049 class OFLogger : private log4cplus::Logger
00050 {
00051 public:
00055 OFLogger(const log4cplus::Logger &base);
00056
00058 enum LogLevel {
00060 TRACE_LOG_LEVEL = log4cplus::TRACE_LOG_LEVEL,
00062 DEBUG_LOG_LEVEL = log4cplus::DEBUG_LOG_LEVEL,
00064 INFO_LOG_LEVEL = log4cplus::INFO_LOG_LEVEL,
00066 WARN_LOG_LEVEL = log4cplus::WARN_LOG_LEVEL,
00068 ERROR_LOG_LEVEL = log4cplus::ERROR_LOG_LEVEL,
00070 FATAL_LOG_LEVEL = log4cplus::FATAL_LOG_LEVEL
00071 };
00072
00082 bool isEnabledFor(log4cplus::LogLevel ll) const {
00083 return Logger::isEnabledFor(ll);
00084 }
00085
00087 void forcedLog(log4cplus::LogLevel ll, const log4cplus::tstring& message,
00088 const char* file=NULL, int line=-1, const char* function=NULL) const {
00089 Logger::forcedLog(ll, message, file, line, function);
00090 }
00091
00098 LogLevel getChainedLogLevel() const {
00099 return OFstatic_cast(LogLevel, Logger::getChainedLogLevel());
00100 }
00101 };
00102
00105 class OFLog
00106 {
00107 private:
00108
00111 OFLog() { }
00112
00116 static void configureLogger(log4cplus::LogLevel level);
00117
00118 public:
00119
00123 static OFLogger getLogger(const char *name);
00124
00128 static void configure(OFLogger::LogLevel level = OFLogger::WARN_LOG_LEVEL);
00129
00134 static void configureFromCommandLine(OFCommandLine &cmd, OFConsoleApplication &app);
00135
00139 static void addOptions(OFCommandLine &cmd);
00140
00146 static void reconfigure(OFCommandLine *cmd = NULL);
00147
00148 private:
00149
00151 static OFauto_ptr<log4cplus::helpers::Properties> configProperties_;
00152 };
00153
00154 #endif
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200