Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

BLogger.h

Go to the documentation of this file.
00001 // BLogger.h (this is -*- C++ -*-)
00002 // 
00003 // \author: Bjoern Giesler <bjoern@giesler.de>
00004 // 
00005 // 
00006 // $Author: giesler $
00007 // $Locker$
00008 // $Revision$
00009 // $Date: 2002-08-19 10:41:28 +0200 (Mon, 19 Aug 2002) $
00010 
00011 #ifndef BLOGGER_H
00012 #define BLOGGER_H
00013 
00020 /* system includes */
00021 #include "gba_nds_fat/gba_nds_fat.h"
00022 #include <string>
00023 #include <deque>
00024 
00025 /* my includes */
00026 /* (none) */
00027 
00029 typedef enum {
00030   LOG_FATAL = 0, // Fatal error
00031   LOG_CRIT = 1,  // Critical error
00032   LOG_ERROR = 2, // Regular error
00033   LOG_WARN = 3,  // Warning
00034   LOG_INFO = 4,  // Informational
00035   LOG_BLAH = 5   // Everything else
00036 } LogLevel;
00037 
00039 #define LOG(level, txt...) BLoggerManager::get()->log(level, txt)
00040 
00048 class BLogger {
00049 public:
00050   virtual ~BLogger();
00051 
00052 
00060   virtual void log(LogLevel level, const std::string& text) = 0;
00061 };
00062 
00063 
00069 class BFileLogger: public BLogger {
00070 public:
00077   BFileLogger(const std::string& filename);
00078   virtual ~BFileLogger();
00079 
00081   virtual void log(LogLevel level, const std::string& text);
00082 private:
00083   FAT_FILE* file;
00084   std::string filename;
00085 };
00086 
00092 class BStdoutLogger: public BLogger {
00093 public:
00094   virtual ~BStdoutLogger();
00095   virtual void log(LogLevel level, const std::string& text);
00096 };
00097 
00117 class BLoggerManager {
00118 public:
00120   static BLoggerManager* get();
00121   ~BLoggerManager();
00122 
00124   void log(LogLevel level, const char* format, ...);
00125 
00132   void setLogLevel(LogLevel level);
00133 
00135   void addLogger(BLogger* logger);
00136 
00138   void setWakeOnLog(bool wakeOnLog);
00139 
00141   bool wakesOnLog() { return wakeOnLog; }
00142 
00149   void setScreenSaverResetFunction(void (*fn)(void*), void* arg);
00150   
00151 private:
00152   BLoggerManager();
00153   static BLoggerManager* singleton;
00154   std::deque<BLogger*> loggers;
00155   BStdoutLogger* defaultLogger;
00156   LogLevel level;
00157   bool wakeOnLog;
00158   void (*ssResetFn)(void*); void *ssResetArg;
00159 };
00160 
00161 #endif /* BLOGGER_H */

Generated on Tue May 1 11:00:41 2007 for libDSFTP by doxygen1.3-rc3