DLLogger.h

Go to the documentation of this file.
00001 
00002 #ifndef DLLOGGER_H
00003 #define DLLOGGER_H
00004 
00005 #include "DLSingletonDestroyer.h"
00006 
00007 #include <string>
00008 #include <cstdlib>
00009 #include <fstream>
00010 using namespace std;
00011 
00016 enum DLSeverity  {
00017    DL_DEBUG = 1,
00018    DL_INFO = 2,
00019    DL_CRITICAL = 3,
00020    DL_LOG_OFF = 4
00021 };
00022 
00024 enum DLLogType  {
00025    DL_STDERR = 1,
00026    DL_STDOUT = 2,
00027    DL_FILEOUT = 3
00028 };
00029 
00030 
00031 
00083 class DLLogger
00084 {
00088    template <class SINGLETON> friend class DLSingletonDestroyer;
00089    private:
00091    static DLLogger* logger;
00094    static DLSingletonDestroyer<DLLogger> _destroyer;
00095 
00097    DLSeverity logSeverity ;
00098 
00100    ostream* logStream;
00101 
00103    FILE* logOutFileStream;
00104 
00106    DLLogType loggerLogType;
00107     
00108 
00109    public:
00110 
00118    void dlSetLogSeverity(DLSeverity severity);
00119 
00128    void dlSetLogType(DLLogType logType, char* logFile = NULL);
00129 
00142    void dlLog(DLSeverity severity, const char *format, ...);
00143 
00149    void dlLog(string val, DLSeverity severity);
00150 
00156    void dlLog(const char* val, DLSeverity severity);
00157 
00163    void dlLog(char val, DLSeverity severity);
00164 
00170    void dlLog(int val, DLSeverity severity);
00171 
00177    void dlLog(float val, DLSeverity severity);
00178 
00184    void dlLog(long val, DLSeverity severity);
00185 
00191    void dlLog(short val, DLSeverity severity);
00192         
00198    void dlLog(double val, DLSeverity severity);
00199 
00207    bool isOkToLog(DLSeverity severity);
00208 
00214    static DLLogger* dlGetInstance() ;
00215 
00219    virtual ~DLLogger(void);
00220 
00221    private:
00229    DLLogger(void);
00230 
00231 
00232 };
00233 
00235 static DLLogger &dlLogger =  *DLLogger::dlGetInstance();
00236 
00237 #endif // DLLOGGER_H
00238 

DOCLIB is being developed under contract by a collaboration between:
The Laboratory for Language and Media Processing
Unviersity of Maryland, College Park
and
Booz | Allen | Hamilton

All Rights Reserved, 2003-2007