swlog.h

00001 /******************************************************************************
00002  *  swlog.h     - definition of class SWLog used for logging messages
00003  *
00004  * $Id: swlog.h 2080 2007-09-17 06:21:29Z scribe $
00005  *
00006  * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
00007  *      CrossWire Bible Society
00008  *      P. O. Box 2528
00009  *      Tempe, AZ  85280-2528
00010  *
00011  * This program is free software; you can redistribute it and/or modify it
00012  * under the terms of the GNU General Public License as published by the
00013  * Free Software Foundation version 2.
00014  *
00015  * This program is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * General Public License for more details.
00019  *
00020  */
00021 
00022 //---------------------------------------------------------------------------
00023 #ifndef swlogH
00024 #define swlogH
00025 //---------------------------------------------------------------------------
00026 
00027 #include <defs.h>
00028 
00029 SWORD_NAMESPACE_START
00030 
00031 class SWDLLEXPORT SWLog {
00032 protected:
00033         char logLevel;
00034         static SWLog *systemLog;
00035 
00036 public:
00037 
00038         static const int LOG_ERROR;
00039         static const int LOG_WARN;
00040         static const int LOG_INFO;
00041         static const int LOG_TIMEDINFO;
00042         static const int LOG_DEBUG;
00043 
00044         static SWLog *getSystemLog();
00045         static void setSystemLog(SWLog *newLogger);
00046 
00047         SWLog() { logLevel = 1; /*default to show only errors*/}
00048         virtual ~SWLog() {};
00049 
00050         void setLogLevel(char level) { logLevel = level; }
00051         char getLogLevel() const { return logLevel; }
00052         void logWarning(const char *fmt, ...) const;
00053         void logError(const char *fmt, ...) const;
00054         void logInformation(const char *fmt, ...) const;
00055         virtual void logTimedInformation(const char *fmt, ...) const;
00056         void logDebug(const char *fmt, ...) const;
00057 
00058         // Override this method if you want to have a custom logger
00059         virtual void logMessage(const char *message, int level) const;
00060 };
00061 
00062 SWORD_NAMESPACE_END
00063 #endif