Commit b09a3af3 authored by Steven Murray's avatar Steven Murray
Browse files

Renamed the Log class to Logger and likewise the LogImplementation to

LoggerImplementation.  This then allowed me to rename the writeMsg()
suit of functions to logMsg() which is much more clear.
parent a80c0bf1
......@@ -139,8 +139,8 @@ set (CLIENT_LIB_SRC_FILES
io/StreamRequestTypeCnv.cpp
io/StreamNsFileIdCnv.cpp
log/IPAddress.cpp
log/Log.cpp
log/LogImplementation.cpp
log/Logger.cpp
log/LoggerImplementation.cpp
log/Message.cpp
log/Param.cpp
log/TimeStamp.cpp
......
......@@ -126,8 +126,8 @@ STGLIB_SRCS = BaseAddress.cpp \
io/StreamRequestTypeCnv.cpp \
io/StreamNsFileIdCnv.cpp \
log/IPAddress.cpp \
log/Log.cpp \
log/LogImplementation.cpp \
log/Logger.cpp \
log/LoggerImplementation.cpp \
log/Message.cpp \
log/Param.cpp \
log/TimeStamp.cpp \
......
......@@ -30,7 +30,7 @@
#include "castor/gc/GcDaemon.hpp"
#include "castor/gc/DeletionThread.hpp"
#include "castor/gc/SynchronizationThread.hpp"
#include "castor/log/LogImplementation.hpp"
#include "castor/log/LoggerImplementation.hpp"
#include "castor/server/SignalThreadPool.hpp"
#include "castor/server/BaseThreadPool.hpp"
#include "Cgetopt.h"
......@@ -45,8 +45,8 @@
int main(int argc, char *argv[]) {
try {
castor::log::LogImplementation log("gcd");
castor::gc::GcDaemon daemon(log);
castor::log::LoggerImplementation logger("gcd");
castor::gc::GcDaemon daemon(logger);
// Randomize the start-up of the daemon between 1 and 15 minutes.
char *value;
......@@ -110,8 +110,8 @@ int main(int argc, char *argv[]) {
//-----------------------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------------------
castor::gc::GcDaemon::GcDaemon(log::Log &log):
castor::server::BaseDaemon(log) {
castor::gc::GcDaemon::GcDaemon(log::Logger &logger):
castor::server::BaseDaemon(logger) {
// Now with predefined messages
castor::dlf::Message messages[] = {
......
......@@ -47,9 +47,9 @@ namespace castor {
/**
* Constructor
*
* @param log Object representing the API of the CASTOR logging system.
* @param logger Object representing the API of the CASTOR logging system.
*/
GcDaemon(log::Log &log);
GcDaemon(log::Logger &logger);
/**
* Default destructor
......
/******************************************************************************
* castor/log/Log.cpp
* castor/log/Logger.cpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
......@@ -22,12 +22,12 @@
* @author Steven.Murray@cern.ch
*****************************************************************************/
#include "castor/log/Log.hpp"
#include "castor/log/Logger.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
castor::log::Log::Log(const std::string &programName)
castor::log::Logger::Logger(const std::string &programName)
throw(castor::exception::Internal, castor::exception::InvalidArgument):
m_programName(programName) {
}
......@@ -35,12 +35,12 @@ castor::log::Log::Log(const std::string &programName)
//------------------------------------------------------------------------------
// getProgramName
//------------------------------------------------------------------------------
const std::string &castor::log::Log::getProgramName() const throw() {
const std::string &castor::log::Logger::getProgramName() const throw() {
return m_programName;
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
castor::log::Log::~Log() throw() {
castor::log::Logger::~Logger() throw() {
}
/******************************************************************************
* castor/log/Log.hpp
* castor/log/Logger.hpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
......@@ -23,8 +23,8 @@
* @author Steven.Murray@cern.ch
*****************************************************************************/
#ifndef CASTOR_LOG_LOG_HPP
#define CASTOR_LOG_LOG_HPP 1
#ifndef CASTOR_LOG_LOGGER_HPP
#define CASTOR_LOG_LOGGER_HPP 1
// Include Files
#include "castor/exception/Internal.hpp"
......@@ -42,7 +42,7 @@ namespace log {
/**
* Abstract class representing the API of the CASTOR logging system.
*/
class Log {
class Logger {
public:
/**
......@@ -51,7 +51,7 @@ public:
* @param programName The name of the program to be prepended to every log
* message.
*/
Log(const std::string &programName)
Logger(const std::string &programName)
throw(castor::exception::Internal, castor::exception::InvalidArgument);
/**
......@@ -63,14 +63,14 @@ public:
/**
* Destructor.
*/
virtual ~Log() throw() = 0;
virtual ~Logger() throw() = 0;
/**
* Writes a message into the CASTOR logging system. Note that no exception
* will ever be thrown in case of failure. Failures will actually be
* silently ignored in order to not impact the processing.
*
* Note that this version of writeMsg() allows the caller to specify the
* Note that this version of logMsg() allows the caller to specify the
* time stamp of the log message.
*
* @param priority the priority of the message as defined by the syslog API.
......@@ -79,7 +79,7 @@ public:
* @param params the parameters of the message.
* @param timeStamp the time stamp of the log message.
*/
virtual void writeMsg(
virtual void logMsg(
const int priority,
const std::string &msg,
const int numParams,
......@@ -87,10 +87,10 @@ public:
const struct timeval &timeStamp) throw() = 0;
/**
* A template function that wraps writeMsg in order to get the compiler
* A template function that wraps logMsg in order to get the compiler
* to automatically determine the size of the params parameter, therefore
*
* Note that this version of writeMsg() allows the caller to specify the
* Note that this version of logMsg() allows the caller to specify the
* time stamp of the log message.
*
* @param priority the priority of the message as defined by the syslog API.
......@@ -98,12 +98,12 @@ public:
* @param params the parameters of the message.
* @param timeStamp the time stamp of the log message.
*/
template<int numParams> void writeMsg(
template<int numParams> void logMsg(
const int priority,
const std::string &msg,
castor::log::Param(&params)[numParams],
const struct timeval &timeStamp) throw() {
writeMsg(priority, msg, numParams, params, timeStamp);
logMsg(priority, msg, numParams, params, timeStamp);
}
/**
......@@ -111,7 +111,7 @@ public:
* will ever be thrown in case of failure. Failures will actually be
* silently ignored in order to not impact the processing.
*
* Note that this version of writeMsg() implicitly uses the current time as
* Note that this version of logMsg() implicitly uses the current time as
* the time stamp of the message.
*
* @param priority the priority of the message as defined by the syslog API.
......@@ -119,29 +119,29 @@ public:
* @param numParams the number of parameters in the message.
* @param params the parameters of the message.
*/
virtual void writeMsg(
virtual void logMsg(
const int priority,
const std::string &msg,
const int numParams,
const castor::log::Param params[]) throw() = 0;
/**
* A template function that wraps writeMsg in order to get the compiler
* A template function that wraps logMsg in order to get the compiler
* to automatically determine the size of the params parameter, therefore
* removing the need for the devloper to provide it explicity.
*
* Note that this version of writeMsg() implicitly uses the current time as
* Note that this version of logMsg() implicitly uses the current time as
* the time stamp of the message.
*
* @param priority the priority of the message as defined by the syslog API.
* @param msg the message.
* @param params the parameters of the message.
*/
template<int numParams> void writeMsg(
template<int numParams> void logMsg(
const int priority,
const std::string &msg,
castor::log::Param(&params)[numParams]) throw() {
writeMsg(priority, msg, numParams, params);
logMsg(priority, msg, numParams, params);
}
/**
......@@ -149,13 +149,13 @@ public:
* will ever be thrown in case of failure. Failures will actually be
* silently ignored in order to not impact the processing.
*
* Note that this version of writeMsg() implicitly uses the current time as
* Note that this version of logMsg() implicitly uses the current time as
* the time stamp of the message.
*
* @param priority the priority of the message as defined by the syslog API.
* @param msg the message.
*/
virtual void writeMsg(
virtual void logMsg(
const int priority,
const std::string &msg) throw() = 0;
......@@ -166,9 +166,9 @@ protected:
*/
const std::string m_programName;
}; // class Log
}; // class Logger
} // namespace log
} // namespace castor
#endif // CASTOR_LOG_LOG_HPP
#endif // CASTOR_LOG_LOGGER_HPP
/******************************************************************************
* castor/log/LogImplementation.cpp
* castor/log/LoggerImplementation.cpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
......@@ -23,7 +23,7 @@
*****************************************************************************/
#include "castor/log/Constants.hpp"
#include "castor/log/LogImplementation.hpp"
#include "castor/log/LoggerImplementation.hpp"
#include "h/Castor_limits.h"
#include "h/getconfent.h"
......@@ -40,10 +40,10 @@
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
castor::log::LogImplementation::LogImplementation(
castor::log::LoggerImplementation::LoggerImplementation(
const std::string &programName)
throw(castor::exception::Internal, castor::exception::InvalidArgument):
Log(programName),
Logger(programName),
m_maxMsgLen(determineMaxMsgLen()),
m_logFile(-1),
m_connected(false),
......@@ -55,7 +55,7 @@ castor::log::LogImplementation::LogImplementation(
//------------------------------------------------------------------------------
// determineMaxMsgLen
//------------------------------------------------------------------------------
size_t castor::log::LogImplementation::determineMaxMsgLen() const throw() {
size_t castor::log::LoggerImplementation::determineMaxMsgLen() const throw() {
const char *p = NULL;
size_t msgSize = 0;
......@@ -99,7 +99,7 @@ size_t castor::log::LogImplementation::determineMaxMsgLen() const throw() {
// generatePriorityToTextMap
//------------------------------------------------------------------------------
std::map<int, std::string>
castor::log::LogImplementation::generatePriorityToTextMap() const
castor::log::LoggerImplementation::generatePriorityToTextMap() const
throw(castor::exception::Internal) {
std::map<int, std::string> m;
......@@ -125,7 +125,7 @@ std::map<int, std::string>
//------------------------------------------------------------------------------
// checkProgramNameLen
//------------------------------------------------------------------------------
void castor::log::LogImplementation::checkProgramNameLen(
void castor::log::LoggerImplementation::checkProgramNameLen(
const std::string &programName) throw(castor::exception::InvalidArgument) {
if(programName.length() > LOG_MAX_PROGNAMELEN) {
castor::exception::InvalidArgument ex;
......@@ -138,7 +138,7 @@ void castor::log::LogImplementation::checkProgramNameLen(
//------------------------------------------------------------------------------
// initMutex
//------------------------------------------------------------------------------
void castor::log::LogImplementation::initMutex()
void castor::log::LoggerImplementation::initMutex()
throw(castor::exception::Internal) {
pthread_mutexattr_t attr;
int rc = pthread_mutexattr_init(&attr);
......@@ -174,13 +174,13 @@ void castor::log::LogImplementation::initMutex()
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
castor::log::LogImplementation::~LogImplementation() throw() {
castor::log::LoggerImplementation::~LoggerImplementation() throw() {
}
//------------------------------------------------------------------------------
// openLog
//------------------------------------------------------------------------------
void castor::log::LogImplementation::openLog() throw() {
void castor::log::LoggerImplementation::openLog() throw() {
if(-1 == m_logFile) {
struct sockaddr_un syslogAddr;
syslogAddr.sun_family = AF_UNIX;
......@@ -224,7 +224,7 @@ void castor::log::LogImplementation::openLog() throw() {
//------------------------------------------------------------------------------
// closeLog
//------------------------------------------------------------------------------
void castor::log::LogImplementation::closeLog() throw() {
void castor::log::LoggerImplementation::closeLog() throw() {
if(!m_connected) {
return;
}
......@@ -234,9 +234,9 @@ void castor::log::LogImplementation::closeLog() throw() {
}
//-----------------------------------------------------------------------------
// writeMsg
// logMsg
//-----------------------------------------------------------------------------
void castor::log::LogImplementation::writeMsg(
void castor::log::LoggerImplementation::logMsg(
const int priority,
const std::string &msg,
const int numParams,
......@@ -371,7 +371,7 @@ void castor::log::LogImplementation::writeMsg(
//-----------------------------------------------------------------------------
// buildSyslogHeader
//-----------------------------------------------------------------------------
int castor::log::LogImplementation::buildSyslogHeader(
int castor::log::LoggerImplementation::buildSyslogHeader(
char *const buffer,
const int buflen,
const int priority,
......@@ -398,7 +398,7 @@ int castor::log::LogImplementation::buildSyslogHeader(
//-----------------------------------------------------------------------------
// cleanString
//-----------------------------------------------------------------------------
std::string castor::log::LogImplementation::cleanString(const std::string &s,
std::string castor::log::LoggerImplementation::cleanString(const std::string &s,
const bool replaceSpaces) throw() {
char *str = strdup(s.c_str());
......@@ -447,7 +447,7 @@ std::string castor::log::LogImplementation::cleanString(const std::string &s,
//-----------------------------------------------------------------------------
// reducedSyslog
//-----------------------------------------------------------------------------
void castor::log::LogImplementation::reducedSyslog(const char *const msg,
void castor::log::LoggerImplementation::reducedSyslog(const char *const msg,
const int msgLen) throw() {
int send_flags = 0;
#ifndef __APPLE__
......@@ -481,9 +481,9 @@ void castor::log::LogImplementation::reducedSyslog(const char *const msg,
}
//-----------------------------------------------------------------------------
// writeMsg
// logMsg
//-----------------------------------------------------------------------------
void castor::log::LogImplementation::writeMsg(
void castor::log::LoggerImplementation::logMsg(
const int priority,
const std::string &msg,
const int numParams,
......@@ -492,15 +492,15 @@ void castor::log::LogImplementation::writeMsg(
struct timeval timeStamp;
gettimeofday(&timeStamp, NULL);
writeMsg(priority, msg, numParams, params, timeStamp);
logMsg(priority, msg, numParams, params, timeStamp);
}
//-----------------------------------------------------------------------------
// writeMsg
// logMsg
//-----------------------------------------------------------------------------
void castor::log::LogImplementation::writeMsg(
void castor::log::LoggerImplementation::logMsg(
const int priority,
const std::string &msg) throw() {
Param *emptyParams = NULL;
writeMsg(priority, msg, 0, emptyParams);
logMsg(priority, msg, 0, emptyParams);
}
/******************************************************************************
* castor/log/LogImplementation.hpp
* castor/log/LoggerImplementation.hpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
......@@ -23,10 +23,10 @@
* @author Steven.Murray@cern.ch
*****************************************************************************/
#ifndef CASTOR_LOG_LOGIMPLEMENTATION_HPP
#define CASTOR_LOG_LOGIMPLEMENTATION_HPP 1
#ifndef CASTOR_LOG_LOGGERIMPLEMENTATION_HPP
#define CASTOR_LOG_LOGGERIMPLEMENTATION_HPP 1
#include "castor/log/Log.hpp"
#include "castor/log/Logger.hpp"
#include <map>
#include <pthread.h>
......@@ -39,7 +39,7 @@ namespace log {
/**
* Class implementaing the API of the CASTOR logging system.
*/
class LogImplementation: public Log {
class LoggerImplementation: public Logger {
public:
/**
......@@ -48,20 +48,20 @@ public:
* @param programName The name of the program to be prepended to every log
* message.
*/
LogImplementation(const std::string &programName)
LoggerImplementation(const std::string &programName)
throw(castor::exception::Internal, castor::exception::InvalidArgument);
/**
* Destructor.
*/
~LogImplementation() throw();
~LoggerImplementation() throw();
/**
* Writes a message into the CASTOR logging system. Note that no exception
* will ever be thrown in case of failure. Failures will actually be
* silently ignored in order to not impact the processing.
*
* Note that this version of writeMsg() allows the caller to specify the
* Note that this version of logMsg() allows the caller to specify the
* time stamp of the log message.
*
* @param priority the priority of the message as defined by the syslog API.
......@@ -70,7 +70,7 @@ public:
* @param params the parameters of the message.
* @param timeStamp the time stamp of the log message.
*/
void writeMsg(
void logMsg(
const int priority,
const std::string &msg,
const int numParams,
......@@ -82,7 +82,7 @@ public:
* will ever be thrown in case of failure. Failures will actually be
* silently ignored in order to not impact the processing.
*
* Note that this version of writeMsg() implicitly uses the current time as
* Note that this version of logMsg() implicitly uses the current time as
* the time stamp of the message.
*
* @param priority the priority of the message as defined by the syslog API.
......@@ -90,7 +90,7 @@ public:
* @param numParams the number of parameters in the message.
* @param params the parameters of the message.
*/
void writeMsg(
void logMsg(
const int priority,
const std::string &msg,
const int numParams,
......@@ -101,13 +101,13 @@ public:
* will ever be thrown in case of failure. Failures will actually be
* silently ignored in order to not impact the processing.
*
* Note that this version of writeMsg() implicitly uses the current time as
* Note that this version of logMsg() implicitly uses the current time as
* the time stamp of the message.
*
* @param priority the priority of the message as defined by the syslog API.
* @param msg the message.
*/
void writeMsg(
void logMsg(
const int priority,
const std::string &msg) throw();
......@@ -144,7 +144,8 @@ private:
const size_t m_maxMsgLen;
/**
* Mutex used to protect the critical section of the LogImplementation object.
* Mutex used to protect the critical section of the LoggerImplementation
* object.
*/
pthread_mutex_t m_mutex;
......@@ -188,7 +189,7 @@ private:
/**
* Initializes the mutex used to protect the critical section of the
* LogImplementation object.
* LoggerImplementation object.
*/
void initMutex() throw(castor::exception::Internal);
......@@ -196,13 +197,13 @@ private:
* Connects to syslog.
*
* Please note that this method must be called from within the critical
* section of the LogImplementation object.
* section of the LoggerImplementation object.
*
* If the connection with syslog is already open then this method does
* nothing.
*
* This method does not throw an exception if the connection cannot be made
* to syslog. In this case the internal state of the LogImplementation
* to syslog. In this case the internal state of the LoggerImplementation
* object reflects the fact that no connection was made.
*/
void openLog() throw();
......@@ -242,16 +243,16 @@ private:
* Closes the connection to syslog.
*
* Please note that this method must be called from within the critical
* section of the LogImplementation object.
* section of the LoggerImplementation object.
*
* If the connection to syslog is already closed then this method does
* nothing.
*/
void closeLog() throw();
}; // class LogImplementation
}; // class LoggerImplementation
} // namespace log
} // namespace castor
#endif // CASTOR_LOG_LOGIMPLEMENTATION_HPP
#endif // CASTOR_LOG_LOGGERIMPLEMENTATION_HPP
......@@ -27,7 +27,7 @@
#include "castor/exception/Internal.hpp"
#include "castor/server/TCPListenerThreadPool.hpp"
#include "castor/server/AuthListenerThreadPool.hpp"
#include "castor/log/LogImplementation.hpp"
#include "castor/log/LoggerImplementation.hpp"
#include "castor/metrics/MetricsCollector.hpp"
#include "castor/metrics/ObjTypeCounter.hpp"
#include "castor/rh/UserCounter.hpp"
......@@ -62,8 +62,8 @@ const char *castor::rh::PORT_SEC_CONF = "SEC_PORT";
//------------------------------------------------------------------------------
int main(int argc, char *argv[]) {
try {
castor::log::LogImplementation log("rhd");
castor::rh::Server server(log);
castor::log::LoggerImplementation logger("rhd");
castor::rh::Server server(logger);
// parse the command line
server.parseCommandLine(argc, argv);
......@@ -93,8 +93,8 @@ int main(int argc, char *argv[]) {
//------------------------------------------------------------------------------
// Constructor
//------------------------------------------------------------------------------
castor::rh::Server::Server(castor::log::Log &log) :
castor::server::BaseDaemon(log),
castor::rh::Server::Server(castor::log::Logger &logger) :
castor::server::BaseDaemon(logger),
m_port(-1),
m_secure(false),
m_waitIfBusy(true),
......
......@@ -59,9 +59,9 @@ namespace castor {
/**
* Constructor
*
* @param log Object representing the API of the CASTOR logging system.
* @param logger Object representing the API of the CASTOR logging system.
*/
Server(log::Log &log);
Server(log::Logger &logger);
/**
* Destructor
......
......@@ -44,8 +44,8 @@
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
castor::server::BaseDaemon::BaseDaemon(log::Log &log) :
castor::server::BaseServer(log),
castor::server::BaseDaemon::BaseDaemon(log::Logger &logger) :
castor::server::BaseServer(logger),
m_signalMutex(0) {
memset(&m_signalSet, 0, sizeof(m_signalSet));
}
......
......@@ -32,7 +32,7 @@
#include <map>
#include "castor/exception/Exception.hpp"
#include "castor/BaseObject.hpp"
#include "castor/log/Log.hpp"
#include "castor/log/Logger.hpp"
#include "castor/server/BaseServer.hpp"
#include "castor/server/Mutex.hpp"
......@@ -59,9 +59,9 @@ namespace castor {
/**
* Constructor
* @param log Object representing the API of the CASTOR logging system.
* @param logger Object representing the API of the CASTOR logging system.
*/