util/I_Log.h

Go to the documentation of this file.
00001 /*----------------------------------------------------------------------------
00002 Name:      I_Log.h
00003 Project:   xmlBlaster.org
00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
00005 -----------------------------------------------------------------------------*/
00006 
00007 #ifndef _ORG_XMLBLASTER_UTIL_I_LOG_H
00008 #define _ORG_XMLBLASTER_UTIL_I_LOG_H
00009 
00010 #include <util/xmlBlasterDef.h>
00011 #include <string>
00012 #include <iostream>
00013 
00036 namespace org { namespace xmlBlaster { namespace util {
00037    
00038 class Dll_Export I_Log {
00039 
00040    protected:
00042       bool call_;
00043       bool time_;
00044       bool trace_;
00045       bool dump_;
00046       bool info_;
00047       
00048    public:
00049       I_Log() : call_(false), time_(false), trace_(false), dump_(false), info_(true) {}
00050       virtual ~I_Log() {}
00051 
00053       inline bool call() const { return call_; }
00054       inline bool time() const { return time_; }
00055       inline bool trace() const { return trace_; }
00056       inline bool dump() const { return dump_; }
00057 
00062       virtual void panic(const std::string &instance, const std::string &text) { error(instance, text); ::exit(1); }
00063 
00064 
00069       virtual void exit(const std::string &instance, const std::string &text) { error(instance, text); ::exit(0); }
00070 
00071 
00075       virtual void info(const std::string &instance, const std::string &text)= 0;
00076       
00077 
00082       virtual void warn(const std::string &instance, const std::string &text)= 0;
00083       
00084       
00088       virtual void error(const std::string &instance, const std::string &text)= 0;
00089 
00090 
00091       /*
00092        * Log without time/date/instance (ignoring the header is not supported with all logging frameworks)
00093        * @param text the std::string to log
00094        * @deprecated
00095        */
00096       virtual void plain(const std::string &instance, const std::string &text) { info(instance, text); }
00097 
00098 
00099       /*
00100        * Log without time/date
00101        * @deprecated
00102        */
00103       virtual void dump(const std::string &instance, const std::string &text) { trace(instance, text); }
00104 
00105 
00109       virtual void trace(const std::string &instance, const std::string &text)= 0;
00110 
00111 
00115       virtual void call(const std::string &instance, const std::string &text)= 0;
00116 
00117       
00122       virtual void time(const std::string &instance, const std::string &text) { trace(instance, text); }
00123 
00128       virtual std::string getLogLevelStr() const { return ""; }
00129 
00130       virtual std::string usage() const { return "No logging usage available, please check the logging documentation"; }
00131    }; // end of class I_Log
00132 
00133 
00134 
00135 }}} // end of namespace util
00136 
00137 #endif // _ORG_XMLBLASTER_UTIL_I_LOG_H