00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef SEMAINE_CMS_CMSLOGGER_H
00010 #define SEMAINE_CMS_CMSLOGGER_H
00011
00012 #include <map>
00013 #include <exception>
00014 #include <string>
00015
00016 #include <semaine/config.h>
00017
00018 #include <cms/Connection.h>
00019 #include <cms/Session.h>
00020 #include <cms/MessageProducer.h>
00021
00022 #include <semaine/cms/loglevel.h>
00023 #include <semaine/cms/message/SEMAINEMessage.h>
00024
00025 using namespace cms;
00026 using namespace semaine::cms::message;
00027
00028 namespace semaine {
00029 namespace cms {
00037 class CMSLogger {
00038
00039 public:
00040 static CMSLogger * getLog(const std::string& source);
00041 static std::string toLogMessageText(const std::string & message, const std::exception *exc = NULL);
00042 static std::string message2logString(SEMAINEMessage * m);
00043
00044 ~CMSLogger();
00045
00046 void error(const std::string & message, const std::exception * exc = NULL);
00047 void warn(const std::string & message, const std::exception * exc = NULL);
00048 void info(const std::string & message, const std::exception * exc = NULL);
00049 void debug(const std::string & message, const std::exception * exc = NULL);
00050
00051 bool isDebugEnabled();
00052
00053
00054 private:
00055 static Connection * connection;
00056 static Session * session;
00057 static std::map<const std::string, CMSLogger *> loggers;
00058
00059 CMSLogger(const std::string & source);
00060
00061 MessageProducer * errorMP;
00062 MessageProducer * warnMP;
00063 MessageProducer * infoMP;
00064 MessageProducer * debugMP;
00065 const std::string source;
00066
00067 void log(MessageProducer * mp, const std::string & level, const std::string & message, const std::exception * exc);
00068
00069 };
00070 }
00071 }
00072
00073 #endif
00074