diff --git a/.gitattributes b/.gitattributes index 5c49a72b04208eaaba03faaa94020c4549be6712..a80ed1de8a8727a8df46fbc13ffeb17b17151917 100644 --- a/.gitattributes +++ b/.gitattributes @@ -273,7 +273,6 @@ MAC/Test/Suite/configure.in -text svneol=native#application/octet-stream MAC/Test/Suite/src/Makefile.am -text svneol=native#application/octet-stream MAC/Test/bootstrap -text svneol=native#application/octet-stream MAC/Test/lofarconf.in -text svneol=native#application/octet-stream -MAC/Tools/LofarLogger/src/Makefile.am -text svneol=native#application/octet-stream MAC/Tools/bootstrap -text svneol=native#application/octet-stream MAC/Tools/lofarconf.in -text svneol=native#application/octet-stream MAC/bootstrap -text svneol=native#application/octet-stream diff --git a/MAC/Tools/LofarLogger/src/LofarLogger.cc b/MAC/Tools/LofarLogger/src/LofarLogger.cc deleted file mode 100644 index 353b57426f68ff057bc0c4abbad1b4a7100d6606..0000000000000000000000000000000000000000 --- a/MAC/Tools/LofarLogger/src/LofarLogger.cc +++ /dev/null @@ -1,190 +0,0 @@ -//# LofarLogger.cc: logger wrapper -//# -//# Copyright (C) 2002-2003 -//# ASTRON (Netherlands Foundation for Research in Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl -//# -//# This program is free software; you can redistribute it and/or modify -//# it under the terms of the GNU General Public License as published by -//# the Free Software Foundation; either version 2 of the License, or -//# (at your option) any later version. -//# -//# This program is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License -//# along with this program; if not, write to the Free Software -//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//# -//# $Id$ - -#include "LofarLogger.h" -#include <stdarg.h> -#include <stdio.h> -#include <log4cplus/configurator.h> -#include <log4cplus/loggingmacros.h> - -// namespaces -using namespace std; - -// static member initialization -LofarLogger LofarLogger::_sLofarLogger; - -/** - * LofarLogger constructor - */ -LofarLogger::LofarLogger() : - _loggerMap() -{ - log4cplus::PropertyConfigurator::doConfigure("log4cplus.properties"); -} - -LofarLogger::LofarLogger(const LofarLogger& rhs) : - _loggerMap(rhs._loggerMap) -{ -} - -/** - * ~LofarLogger destructor - */ -LofarLogger::~LofarLogger() -{ -} - -/** - * getInstance - returns the static instance of the LofarLogger - */ -LofarLogger LofarLogger::getInstance() -{ - return _sLofarLogger; -} - -/** - * trace - logs TRACE level messages - */ -void LofarLogger::trace(const string& logger,const string& logEvent,const char* file, int line) -{ - log4cplus::Logger log4cplusLogger=getLogger(logger); - - if(log4cplusLogger.isEnabledFor(log4cplus::TRACE_LOG_LEVEL)) - { - log4cplus::tostringstream _log4cplus_buf; - _log4cplus_buf << logEvent; - const char* shortFile = strrchr(file, '/'); - if (shortFile == 0) shortFile = file; else shortFile++; - log4cplusLogger.forcedLog(log4cplus::TRACE_LOG_LEVEL,_log4cplus_buf.str(),shortFile,line); - } -} - -/** - * debug - logs DEBUG level messages - */ -void LofarLogger::debug(const string& logger,const string& logEvent,const char* file, int line) -{ - log4cplus::Logger log4cplusLogger=getLogger(logger); - - if(log4cplusLogger.isEnabledFor(log4cplus::DEBUG_LOG_LEVEL)) - { - log4cplus::tostringstream _log4cplus_buf; - _log4cplus_buf << logEvent; - const char* shortFile = strrchr(file, '/'); - if (shortFile == 0) shortFile = file; else shortFile++; - log4cplusLogger.forcedLog(log4cplus::DEBUG_LOG_LEVEL, _log4cplus_buf.str(), shortFile,line); - } -} - -/** - * info - logs INFO level messages - */ -void LofarLogger::info(const string& logger,const string& logEvent,const char* file, int line) -{ - log4cplus::Logger log4cplusLogger=getLogger(logger); - - if(log4cplusLogger.isEnabledFor(log4cplus::INFO_LOG_LEVEL)) - { - log4cplus::tostringstream _log4cplus_buf; - _log4cplus_buf << logEvent; - const char* shortFile = strrchr(file, '/'); - if (shortFile == 0) shortFile = file; else shortFile++; - log4cplusLogger.forcedLog(log4cplus::INFO_LOG_LEVEL, _log4cplus_buf.str(), shortFile,line); - } -} - -/** - * warn - logs WARN level messages - */ -void LofarLogger::warn(const string& logger,const string& logEvent,const char* file, int line) -{ - log4cplus::Logger log4cplusLogger=getLogger(logger); - - if(log4cplusLogger.isEnabledFor(log4cplus::WARN_LOG_LEVEL)) - { - log4cplus::tostringstream _log4cplus_buf; - _log4cplus_buf << logEvent; - const char* shortFile = strrchr(file, '/'); - if (shortFile == 0) shortFile = file; else shortFile++; - log4cplusLogger.forcedLog(log4cplus::WARN_LOG_LEVEL, _log4cplus_buf.str(), shortFile,line); - } -} - -/** - * error - logs ERROR level messages - */ -void LofarLogger::error(const string& logger,const string& logEvent,const char* file, int line) -{ - log4cplus::Logger log4cplusLogger=getLogger(logger); - - if(log4cplusLogger.isEnabledFor(log4cplus::ERROR_LOG_LEVEL)) - { - log4cplus::tostringstream _log4cplus_buf; - _log4cplus_buf << logEvent; - const char* shortFile = strrchr(file, '/'); - if (shortFile == 0) shortFile = file; else shortFile++; - log4cplusLogger.forcedLog(log4cplus::ERROR_LOG_LEVEL, _log4cplus_buf.str(), shortFile,line); - } -} - -/** - * fatal - logs FATAL level messages - */ -void LofarLogger::fatal(const string& logger,const string& logEvent,const char* file, int line) -{ - log4cplus::Logger log4cplusLogger=getLogger(logger); - - if(log4cplusLogger.isEnabledFor(log4cplus::FATAL_LOG_LEVEL)) - { - log4cplus::tostringstream _log4cplus_buf; - _log4cplus_buf << logEvent; - const char* shortFile = strrchr(file, '/'); - if (shortFile == 0) shortFile = file; else shortFile++; - log4cplusLogger.forcedLog(log4cplus::FATAL_LOG_LEVEL, _log4cplus_buf.str(), shortFile,line); - } -} - -/** - * formatString - creates a formatted string - */ -string LofarLogger::formatString(char* format,...) -{ - va_list args; - char buffer[1000]; - va_start(args,format); - vsnprintf(buffer,1000,format,args); - return string(buffer); -} - -/** - * getLogger - finds a logger in the logger map or creates a new logger - */ -log4cplus::Logger& LofarLogger::getLogger(const string& logger) -{ - TLoggerMap::iterator loggerMapIterator=_loggerMap.find(logger); - if(loggerMapIterator==_loggerMap.end()) - { - _loggerMap.insert(TLoggerMap::value_type(logger,log4cplus::Logger::getInstance(logger))); - } - loggerMapIterator=_loggerMap.find(logger); - return (loggerMapIterator->second); -} diff --git a/MAC/Tools/LofarLogger/src/LofarLogger.h b/MAC/Tools/LofarLogger/src/LofarLogger.h deleted file mode 100644 index e420bff5fa83514fe17225b4d3d1785e9c39c05c..0000000000000000000000000000000000000000 --- a/MAC/Tools/LofarLogger/src/LofarLogger.h +++ /dev/null @@ -1,152 +0,0 @@ -//# LofarLogger.h: logger wrapper -//# -//# Copyright (C) 2002-2003 -//# ASTRON (Netherlands Foundation for Research in Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl -//# -//# This program is free software; you can redistribute it and/or modify -//# it under the terms of the GNU General Public License as published by -//# the Free Software Foundation; either version 2 of the License, or -//# (at your option) any later version. -//# -//# This program is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License -//# along with this program; if not, write to the Free Software -//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//# -//# $Id$ - -#ifndef LOFAR_LOGGER_H -#define LOFAR_LOGGER_H - -#include <Common/lofar_string.h> -#include <Common/lofar_map.h> -#include <log4cplus/logger.h> -#include "LofarLoggerNames.h" - -// forward declaration -// define convenience macros -#ifndef NOLOG -#define LOFAR_LOG_TRACE_SCOPE(logger,logEvent) \ - LofarScopeTraceLogger _scopeLogger(logger,LofarLogger::formatString logEvent ,__FILE__,__LINE__); -#define LOFAR_LOG_TRACE(logger,logEvent) \ - LofarLogger::getInstance().trace(logger,LofarLogger::formatString logEvent ,__FILE__,__LINE__); -#define LOFAR_LOG_DEBUG(logger,logEvent) \ - LofarLogger::getInstance().debug(logger,LofarLogger::formatString logEvent ,__FILE__,__LINE__); -#define LOFAR_LOG_INFO(logger,logEvent) \ - LofarLogger::getInstance().info(logger,LofarLogger::formatString logEvent ,__FILE__,__LINE__); -#define LOFAR_LOG_WARN(logger,logEvent) \ - LofarLogger::getInstance().warn(logger,LofarLogger::formatString logEvent ,__FILE__,__LINE__); -#define LOFAR_LOG_ERROR(logger,logEvent) \ - LofarLogger::getInstance().error(logger,LofarLogger::formatString logEvent ,__FILE__,__LINE__); -#define LOFAR_LOG_FATAL(logger,logEvent) \ - LofarLogger::getInstance().fatal(logger,LofarLogger::formatString logEvent ,__FILE__,__LINE__); -#else -#define LOFAR_LOG_TRACE_SCOPE(logger,logEvent) \ - {}; -#define LOFAR_LOG_TRACE(logger,logEvent) \ - {}; -#define LOFAR_LOG_DEBUG(logger,logEvent) \ - {}; -#define LOFAR_LOG_INFO(logger,logEvent) \ - {}; -#define LOFAR_LOG_WARN(logger,logEvent) \ - {}; -#define LOFAR_LOG_ERROR(logger,logEvent) \ - {}; -#define LOFAR_LOG_FATAL(logger,logEvent) \ - {}; -#endif -/** - * - * The LofarLogger class wraps the log4cplus::Logger class - * - * Usage: - * - * #define EXAMPLE_LOGGER_NAME "ASTRON.LOFAR.MAC.ExampleLoggerName" - * - * LOFAR_LOG_TRACE(EXAMPLE_LOGGER_NAME,("example %d level message %d","trace",15)) - * LOFAR_LOG_FATAL(EXAMPLE_LOGGER_NAME,("example fatal level message")) - * - * NOTE: the second argument of the macro HAS to be surrounded with brackets. - */ -class LofarLogger -{ - public: - - /** - * destructor - */ - virtual ~LofarLogger(); - - static LofarLogger getInstance(); - - /** - * logging methods4 - */ - void trace(const string& logger,const string& logEvent,const char* file=NULL,int line=-1); - void debug(const string& logger,const string& logEvent,const char* file=NULL,int line=-1); - void info(const string& logger,const string& logEvent,const char* file=NULL,int line=-1); - void warn(const string& logger,const string& logEvent,const char* file=NULL,int line=-1); - void error(const string& logger,const string& logEvent,const char* file=NULL,int line=-1); - void fatal(const string& logger,const string& logEvent,const char* file=NULL,int line=-1); - - log4cplus::Logger& getLogger(const string& logger); - static string formatString(char* format,...); - - protected: - /**4 - * constructor. Protected because public construction is not allowed - */ - LofarLogger(); - LofarLogger(const LofarLogger&); - - private: - - /** - * Don't allow copying of the LofarLogger object. - */ - LofarLogger& operator=(const LofarLogger&); - - typedef std::map<const std::string,log4cplus::Logger> TLoggerMap; - - /** - * keep the loggers in a map for re-use - */ - TLoggerMap _loggerMap; - static LofarLogger _sLofarLogger; -}; - -/** - * - * The LofarScopeTraceLogger class logs trace messages in its constructor and destructor - * - */ -class LofarScopeTraceLogger -{ - public: - explicit LofarScopeTraceLogger(const std::string& logger, const std::string& logEvent,const char* file=NULL,int line=-1) : - _traceLogger(LofarLogger::getInstance().getLogger(logger),logEvent,file,line) - { - }; - ~LofarScopeTraceLogger() - { - }; - - protected: - /** - * constructor. Protected because public construction is not allowed - */ - LofarScopeTraceLogger(); - LofarScopeTraceLogger(const LofarScopeTraceLogger&); - LofarScopeTraceLogger& operator=(const LofarScopeTraceLogger&); - - private: - log4cplus::TraceLogger _traceLogger; -}; - -#endif diff --git a/MAC/Tools/LofarLogger/src/LofarLoggerNames.h b/MAC/Tools/LofarLogger/src/LofarLoggerNames.h deleted file mode 100644 index 5fb8d0627b9bb0f23e743e5cb30573803c7f15f7..0000000000000000000000000000000000000000 --- a/MAC/Tools/LofarLogger/src/LofarLoggerNames.h +++ /dev/null @@ -1,30 +0,0 @@ -//# LofarLoggerNames.h: logger names -//# -//# Copyright (C) 2002-2003 -//# ASTRON (Netherlands Foundation for Research in Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl -//# -//# This program is free software; you can redistribute it and/or modify -//# it under the terms of the GNU General Public License as published by -//# the Free Software Foundation; either version 2 of the License, or -//# (at your option) any later version. -//# -//# This program is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License -//# along with this program; if not, write to the Free Software -//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//# -//# $Id$ - -#ifndef LOFAR_LOGGER_NAMES_H -#define LOFAR_LOGGER_NAMES_H - -#define LOFAR_LOGGER_ROOT (string("ASTRON.LOFAR")) -#define MAC_LOGGER_ROOT (LOFAR_LOGGER_ROOT+string(".MAC")) -#define LCS_LOGGER_ROOT (LOFAR_LOGGER_ROOT+string(".LCS")) - -#endif diff --git a/MAC/Tools/LofarLogger/src/Makefile.am b/MAC/Tools/LofarLogger/src/Makefile.am deleted file mode 100644 index 07d3e8696e9c88e2dee4d19ee18273f4fff21bb1..0000000000000000000000000000000000000000 --- a/MAC/Tools/LofarLogger/src/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -pkginclude_HEADERS = \ - LofarLogger.h \ - LofarLoggerNames.h - -DOCHDRS = \ - $(pkginclude_HEADERS) - -lib_LTLIBRARIES = liblofarlogger.la - -liblofarlogger_la_SOURCES= $(DOCHDRS) \ - LofarLogger.cc - -include $(lofar_sharedir)/Makefile.common -