diff options
Diffstat (limited to '')
-rw-r--r-- | src/multilog.h | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/src/multilog.h b/src/multilog.h index 30ad8d7..7e4a357 100644 --- a/src/multilog.h +++ b/src/multilog.h | |||
@@ -7,6 +7,7 @@ | |||
7 | 7 | ||
8 | #include "ringlist.h" | 8 | #include "ringlist.h" |
9 | #include "linkedlist.h" | 9 | #include "linkedlist.h" |
10 | #include "singleton.h" | ||
10 | 11 | ||
11 | /** | 12 | /** |
12 | * Calls the DetailLog function but includes pre-processor macros to fill in | 13 | * Calls the DetailLog function but includes pre-processor macros to fill in |
@@ -19,6 +20,8 @@ | |||
19 | */ | 20 | */ |
20 | #define LineLog( LEVEL, FORMAT, ...) DetailLog( LEVEL, __FILE__, __LINE__, __PRETTY_FUNCTION__, FORMAT, ##__VA_ARGS__ ) | 21 | #define LineLog( LEVEL, FORMAT, ...) DetailLog( LEVEL, __FILE__, __LINE__, __PRETTY_FUNCTION__, FORMAT, ##__VA_ARGS__ ) |
21 | 22 | ||
23 | #define MultiLineLog( LEVEL, FORMAT, ...) MultiLog::getInstance().DetailLog( LEVEL, __FILE__, __LINE__, __PRETTY_FUNCTION__, FORMAT, ##__VA_ARGS__ ) | ||
24 | |||
22 | /** MultiLog keeps track of logfile info in a myriad of varieties, and is | 25 | /** MultiLog keeps track of logfile info in a myriad of varieties, and is |
23 | * easily configurable between them all. It allows output to the standard | 26 | * easily configurable between them all. It allows output to the standard |
24 | * output, error output, files, networks, and streams, which includes memory | 27 | * output, error output, files, networks, and streams, which includes memory |
@@ -27,8 +30,9 @@ | |||
27 | * the log. Instead of instantiating a new copy, call the getLog method. | 30 | * the log. Instead of instantiating a new copy, call the getLog method. |
28 | *@author Mike Buland | 31 | *@author Mike Buland |
29 | */ | 32 | */ |
30 | class MultiLog | 33 | class MultiLog : public Singleton<MultiLog> |
31 | { | 34 | { |
35 | friend class Singleton<MultiLog>; | ||
32 | public: | 36 | public: |
33 | /** | 37 | /** |
34 | * Keeps track of a single log entry, in a standard format, that can be | 38 | * Keeps track of a single log entry, in a standard format, that can be |
@@ -46,16 +50,16 @@ public: | |||
46 | char *lpText; /**< The text content of this log entry. */ | 50 | char *lpText; /**< The text content of this log entry. */ |
47 | } LogEntry; | 51 | } LogEntry; |
48 | 52 | ||
49 | private: | 53 | protected: |
50 | /** | 54 | /** |
51 | * Private constructor, this ensures that this is a singleton. | 55 | * Private constructor, this ensures that this is a singleton. |
52 | */ | 56 | */ |
53 | MultiLog(); | 57 | MultiLog(); |
54 | 58 | ||
55 | /** | 59 | /** |
56 | * The only instance of MultiLog ever. | 60 | * Destroy the multilog. |
57 | */ | 61 | */ |
58 | static MultiLog *singleLog; | 62 | ~MultiLog(); |
59 | 63 | ||
60 | /** | 64 | /** |
61 | * Append a new logentry to the log list, possibly pushing an old entry off. | 65 | * Append a new logentry to the log list, possibly pushing an old entry off. |
@@ -79,11 +83,6 @@ private: | |||
79 | LinkedList *lChannel; | 83 | LinkedList *lChannel; |
80 | 84 | ||
81 | public: | 85 | public: |
82 | /** | ||
83 | * Destroy the multilog. | ||
84 | *@todo Why is this public? Does it need to be? | ||
85 | */ | ||
86 | ~MultiLog(); | ||
87 | 86 | ||
88 | /** Sends info to the logfile. | 87 | /** Sends info to the logfile. |
89 | *@param nLevel The type of data being logged (error, info, etc.) | 88 | *@param nLevel The type of data being logged (error, info, etc.) |
@@ -106,20 +105,6 @@ public: | |||
106 | */ | 105 | */ |
107 | void DetailLog( int nLevel, const char *lpFile, int nLine, const char *lpFunction, const char *lpFormat, ...); | 106 | void DetailLog( int nLevel, const char *lpFile, int nLine, const char *lpFunction, const char *lpFormat, ...); |
108 | 107 | ||
109 | /** Gets a pointer to the only instantion of the MultiLog that can exist. | ||
110 | * If there is no instantion in existance, it creates one, so it's | ||
111 | * foolproof. | ||
112 | *@returns A pointer to the only MultiLog instantion. | ||
113 | *@author Mike Buland | ||
114 | */ | ||
115 | static MultiLog *getLog(); | ||
116 | |||
117 | /** Performs standard cleanup and deletes the only instantiation of MultiLog | ||
118 | * that can exist. This is just the same as delete and will nicely close | ||
119 | * all open logs. always call this when you are done with your MultiLog. | ||
120 | */ | ||
121 | static void cleanup(); | ||
122 | |||
123 | /** | 108 | /** |
124 | * Adds a logging channel to the MultiLog channel chain. Every added | 109 | * Adds a logging channel to the MultiLog channel chain. Every added |
125 | * channel will automatically receive a complete log of everything that | 110 | * channel will automatically receive a complete log of everything that |