• Classes
  • Modules
  • Namespaces
  • Files
  • Related Pages
  • File List
  • File Members

loggingLog4cpp.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002  *    ALMA - Atacama Large Millimiter Array
00003  *    (c) European Southern Observatory, 2002
00004  *    Copyright by ESO (in the framework of the ALMA collaboration)
00005  *    and Cosylab 2002, All rights reserved
00006  *
00007  *    This library is free software; you can redistribute it and/or
00008  *    modify it under the terms of the GNU Lesser General Public
00009  *    License as published by the Free Software Foundation; either
00010  *    version 2.1 of the License, or (at your option) any later version.
00011  *
00012  *    This library is distributed in the hope that it will be useful,
00013  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  *    Lesser General Public License for more details.
00016  *
00017  *    You should have received a copy of the GNU Lesser General Public
00018  *    License along with this library; if not, write to the Free Software
00019  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00020  *
00021  *
00022  * "@(#) $Id: loggingLog4cpp.h,v 1.7 2011/04/26 20:19:22 javarias Exp $"
00023  */
00024 #ifndef LOGGING_LOG4CPP_H_
00025 #define LOGGING_LOG4CPP_H_
00026 
00027 #include "loggingACSCategory.h"
00028 #include "logging_idlC.h"
00029 
00030 #include <log4cpp/LayoutAppender.hh>
00031 #include <ace/Singleton.h>
00032 #include <ace/Synch.h>
00033 #include <orbsvcs/CosNamingC.h>
00034 
00035 #include "loggingBaseLog.h"
00036 
00037 #ifndef LM_DELOUSE
00038 #define LM_DELOUSE 010000U
00039 #endif
00040 
00041 namespace logging {
00042 
00043 struct BasicLogInfo {
00044         log4cpp::Priority::PriorityLevel priority;
00045         std::string message;
00046 };
00047 
00048 class Logger {
00049 public:
00050 
00051         Logger();
00052         ~Logger();
00053 
00054         ACSCategory* getLogger(const std::string& loggerName);
00055         ACSCategory* getGlobalLogger();
00056         ACSCategory* getStaticLogger();
00057 
00058         void enableRemoteAppender(unsigned long cacheSize = 100,
00059                         unsigned int autoFlushTimeoutSec = 3,
00060                         Logging::AcsLogService_ptr loggingService = Logging::AcsLogService::_nil(),
00061                         CosNaming::NamingContext_ptr namingService = CosNaming::NamingContext::_nil(),
00062                         int maxLogsPerSecond = -1);
00063         void enableSyslogAppender();
00064 
00065         void setLogLevels(const std::string& loggerName, log4cpp::Priority::PriorityLevel remote, log4cpp::Priority::PriorityLevel local);
00066 
00067         static BasicLogInfo formatLog(log4cpp::Priority::PriorityLevel priority, const char *fmt, ...)
00068 #if defined(__GNUC__)
00069         __attribute__ ((format (printf, 2, 3)))
00070 #endif
00071                 ;
00072         static BasicLogInfo formatLog(ACE_Log_Priority priority, const char *fmt, ...)
00073 #if defined(__GNUC__)
00074         __attribute__ ((format (printf, 2, 3)))
00075 #endif
00076                 ;
00077         static BasicLogInfo formatLog(unsigned int priority, const char *fmt, ...)
00078 #if defined(__GNUC__)
00079         __attribute__ ((format (printf, 2, 3)))
00080 #endif
00081                 ;
00082 
00083 private:
00084         bool remoteAppenderEnabled;
00085         bool syslogAppenderEnabled;
00086         unsigned int localLogLevel;
00087         unsigned int remoteLogLevel;
00088         unsigned int syslogLogLevel;
00089         //Configuration parameters for ACS Remote Logger
00090         unsigned long cacheSize;
00091         unsigned int autoFlushTimeoutSec;
00092         Logging::AcsLogService_ptr loggingService;
00093         CosNaming::NamingContext_ptr namingService;
00094         int maxLogsPerSecond;
00095         //
00096         ACE_Thread_Mutex initMutex;
00097         ACSCategory* initLogger(const std::string& loggerName);
00098 };
00099 
00100 class LogTrace {
00101 public:
00102         LogTrace (ACSCategory* logger, const std::string &method,
00103                         const std::string &file, const unsigned long line);
00104         LogTrace (ACSCategory* logger, const std::string &method);
00105         ~LogTrace();
00106 
00107 private:
00108         ACSCategory* logger;
00109         const std::string method;
00110         const std::string file;
00111         const unsigned long line;
00112 };
00113 
00114 log4cpp::Priority::PriorityLevel convertPriority(unsigned int logLevel);
00115 log4cpp::Priority::PriorityLevel convertPriority(ACE_Log_Priority logLevel);
00116 log4cpp::Priority::PriorityLevel convertPriority(Logging::BaseLog::Priority logLevel);
00117 log4cpp::Priority::PriorityLevel convertPriority(AcsLogLevels::logLevelValue logLevel);
00118 }
00119 
00120 #define LOGGER_FACTORY ACE_Singleton<logging::Logger, ACE_Null_Mutex>::instance()
00121 #endif

Generated on Thu Jan 12 2012 23:13:51 for ACS-10.0 C++ API by  doxygen 1.7.0