From 96b00553a0ffe6bb34af6ad15e1cfc2bed67bd75 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 3 May 2006 06:49:30 +0000 Subject: Added a simple test for the log system, and switched the multilog to the new singleton system, which unfortunately changed it's API slightly. Now it's not a pointer from the singleton, but I did add a new macro to make most usage of it even easier. --- src/multilog.h | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) (limited to 'src/multilog.h') 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 @@ #include "ringlist.h" #include "linkedlist.h" +#include "singleton.h" /** * Calls the DetailLog function but includes pre-processor macros to fill in @@ -19,6 +20,8 @@ */ #define LineLog( LEVEL, FORMAT, ...) DetailLog( LEVEL, __FILE__, __LINE__, __PRETTY_FUNCTION__, FORMAT, ##__VA_ARGS__ ) +#define MultiLineLog( LEVEL, FORMAT, ...) MultiLog::getInstance().DetailLog( LEVEL, __FILE__, __LINE__, __PRETTY_FUNCTION__, FORMAT, ##__VA_ARGS__ ) + /** MultiLog keeps track of logfile info in a myriad of varieties, and is * easily configurable between them all. It allows output to the standard * output, error output, files, networks, and streams, which includes memory @@ -27,8 +30,9 @@ * the log. Instead of instantiating a new copy, call the getLog method. *@author Mike Buland */ -class MultiLog +class MultiLog : public Singleton { + friend class Singleton; public: /** * Keeps track of a single log entry, in a standard format, that can be @@ -46,16 +50,16 @@ public: char *lpText; /**< The text content of this log entry. */ } LogEntry; -private: +protected: /** * Private constructor, this ensures that this is a singleton. */ MultiLog(); /** - * The only instance of MultiLog ever. + * Destroy the multilog. */ - static MultiLog *singleLog; + ~MultiLog(); /** * Append a new logentry to the log list, possibly pushing an old entry off. @@ -79,11 +83,6 @@ private: LinkedList *lChannel; public: - /** - * Destroy the multilog. - *@todo Why is this public? Does it need to be? - */ - ~MultiLog(); /** Sends info to the logfile. *@param nLevel The type of data being logged (error, info, etc.) @@ -106,20 +105,6 @@ public: */ void DetailLog( int nLevel, const char *lpFile, int nLine, const char *lpFunction, const char *lpFormat, ...); - /** Gets a pointer to the only instantion of the MultiLog that can exist. - * If there is no instantion in existance, it creates one, so it's - * foolproof. - *@returns A pointer to the only MultiLog instantion. - *@author Mike Buland - */ - static MultiLog *getLog(); - - /** Performs standard cleanup and deletes the only instantiation of MultiLog - * that can exist. This is just the same as delete and will nicely close - * all open logs. always call this when you are done with your MultiLog. - */ - static void cleanup(); - /** * Adds a logging channel to the MultiLog channel chain. Every added * channel will automatically receive a complete log of everything that -- cgit v1.2.3