The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
swlog.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * swlog.h - class SWLog: used for logging messages
4  *
5  * $Id: swlog.h 3822 2020-11-03 18:54:47Z scribe $
6  *
7  * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
8  * CrossWire Bible Society
9  * P. O. Box 2528
10  * Tempe, AZ 85280-2528
11  *
12  * This program is free software; you can redistribute it and/or modify it
13  * under the terms of the GNU General Public License as published by the
14  * Free Software Foundation version 2.
15  *
16  * This program is distributed in the hope that it will be useful, but
17  * WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * General Public License for more details.
20  *
21  */
22 
23 //---------------------------------------------------------------------------
24 #ifndef swlogH
25 #define swlogH
26 //---------------------------------------------------------------------------
27 
28 #include <defs.h>
29 #include <time.h>
30 
32 
33 
35 
36 protected:
37  char logLevel;
38  static SWLog *systemLog;
39 
40 public:
41 
42  static const char LOG_ERROR;
43  static const char LOG_WARN;
44  static const char LOG_INFO;
45  static const char LOG_TIMEDINFO;
46  static const char LOG_DEBUG;
47 
48  static SWLog *getSystemLog();
49  static void setSystemLog(SWLog *newLogger);
50 
51  SWLog() { logLevel = 1; /*default to show only errors*/}
52  virtual ~SWLog() {};
53 
54  void setLogLevel(char level) { logLevel = level; }
55  char getLogLevel() const { return logLevel; }
56  void logWarning(const char *fmt, ...) const;
57  void logError(const char *fmt, ...) const;
58  void logInformation(const char *fmt, ...) const;
59  void logDebug(const char *fmt, ...) const;
60 
61  // Override this method if you want to have a custom logger
62  virtual void logMessage(const char *message, int level) const;
63 
64  // Override if you need to use a special OS clock for timing
65  virtual void logTimedInformation(const char *fmt, ...) const;
66 };
67 
69 #endif
#define SWORD_NAMESPACE_START
Definition: defs.h:39
char logLevel
Definition: swlog.h:37
#define SWDLLEXPORT
Definition: defs.h:171
SWLog()
Definition: swlog.h:51
virtual ~SWLog()
Definition: swlog.h:52
char getLogLevel() const
Definition: swlog.h:55
Definition: swlog.h:34
static SWLog * systemLog
Definition: swlog.h:38
static const char LOG_WARN
Definition: swlog.h:43
void setLogLevel(char level)
Definition: swlog.h:54
static const char LOG_INFO
Definition: swlog.h:44
#define SWORD_NAMESPACE_END
Definition: defs.h:40
static const char LOG_ERROR
Definition: swlog.h:42
static const char LOG_TIMEDINFO
Definition: swlog.h:45
static const char LOG_DEBUG
Definition: swlog.h:46