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

Removed std::vector and array params from castor::log

parent e9b90bd7
......@@ -44,46 +44,6 @@ void castor::log::DummyLogger::prepareForFork()
{
}
//------------------------------------------------------------------------------
// operator()
//------------------------------------------------------------------------------
void castor::log::DummyLogger::operator() (
const int priority,
const std::string &msg,
const std::vector<Param> &params,
const struct timeval &timeStamp) throw() {
}
//------------------------------------------------------------------------------
// operator()
//------------------------------------------------------------------------------
void castor::log::DummyLogger::operator() (
const int priority,
const std::string &msg,
const std::list<Param> &params,
const struct timeval &timeStamp) throw() {
}
//------------------------------------------------------------------------------
// operator()
//------------------------------------------------------------------------------
void castor::log::DummyLogger::operator() (
const int priority,
const std::string &msg,
const int numParams,
const log::Param params[],
const struct timeval &timeStamp) throw() {
}
//------------------------------------------------------------------------------
// operator()
//------------------------------------------------------------------------------
void castor::log::DummyLogger::operator() (
const int priority,
const std::string &msg,
const std::vector<Param> &params) throw() {
}
//------------------------------------------------------------------------------
// operator()
//------------------------------------------------------------------------------
......@@ -92,21 +52,3 @@ void castor::log::DummyLogger::operator() (
const std::string &msg,
const std::list<Param> &params) throw() {
}
//------------------------------------------------------------------------------
// operator()
//------------------------------------------------------------------------------
void castor::log::DummyLogger::operator() (
const int priority,
const std::string &msg,
const int numParams,
const log::Param params[]) throw() {
}
//------------------------------------------------------------------------------
// operator()
//------------------------------------------------------------------------------
void castor::log::DummyLogger::operator() (
const int priority,
const std::string &msg) throw() {
}
......@@ -26,11 +26,6 @@
#include "castor/log/Logger.hpp"
#include <map>
#include <pthread.h>
#include <syslog.h>
#include <sys/time.h>
namespace castor {
namespace log {
......@@ -74,91 +69,11 @@ public:
* @param priority the priority of the message as defined by the syslog API.
* @param msg the message.
* @param params the parameters of the message.
* @param timeStamp the time stamp of the log message.
*/
void operator() (
const int priority,
const std::string &msg,
const std::vector<Param> &params,
const struct timeval &timeStamp) throw();
/**
* Dummy operator() method that does nothing.
*
* @param priority the priority of the message as defined by the syslog API.
* @param msg the message.
* @param params the parameters of the message.
* @param timeStamp the time stamp of the log message.
*/
void operator() (
const int priority,
const std::string &msg,
const std::list<Param> &params,
const struct timeval &timeStamp) throw();
/**
* Dummy operator() method that does nothing.
*
* @param priority the priority of the message as defined by the syslog API.
* @param msg the message.
* @param numParams the number of parameters in the message.
* @param params the parameters of the message.
* @param timeStamp the time stamp of the log message.
*/
void operator() (
const int priority,
const std::string &msg,
const int numParams,
const Param params[],
const struct timeval &timeStamp) throw();
/**
* Dummy operator() method that does nothing.
*
* @param priority the priority of the message as defined by the syslog API.
* @param msg the message.
* @param params the parameters of the message.
*/
void operator() (
const int priority,
const std::string &msg,
const std::vector<Param> &params) throw();
/**
* Dummy operator() method that does nothing.
*
* @param priority the priority of the message as defined by the syslog API.
* @param msg the message.
* @param params the parameters of the message.
*/
void operator() (
const int priority,
const std::string &msg,
const std::list<Param> &params) throw();
/**
* Dummy operator() method that does nothing.
*
* @param priority the priority of the message as defined by the syslog API.
* @param msg the message.
* @param numParams the number of parameters in the message.
* @param params the parameters of the message.
*/
void operator() (
const int priority,
const std::string &msg,
const int numParams,
const Param params[]) throw();
/**
* Dummy operator() method that does nothing.
*
* @param priority the priority of the message as defined by the syslog API.
* @param msg the message.
*/
void operator() (
const int priority,
const std::string &msg) throw();
const std::list<Param> &params = std::list<Param>()) throw();
}; // class DummyLogger
......
......@@ -52,11 +52,6 @@ void castor::log::LogContext::log(const int priority, const std::string& msg) th
m_log(priority, msg, m_params);
}
void castor::log::LogContext::log(const int priority, const std::string& msg,
const timeval& timeStamp) throw() {
m_log(priority, msg, m_params, timeStamp);
}
void castor::log::LogContext::logBacktrace(const int priority,
const std::string& backtrace) throw() {
// Sanity check to prevent substr from throwing exceptions
......
......@@ -103,20 +103,6 @@ public:
*/
size_t size() const { return m_params.size(); }
/**
* 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.
*
* All the parameters present in the context will be added to the log message.
*
* @param priority the priority of the message as defined by the syslog API.
* @param msg the message.
*/
virtual void log(
const int priority,
const std::string &msg,
const struct timeval &timeStamp) throw();
/**
* Helper class to find parameters by name.
*/
......@@ -149,8 +135,8 @@ class ScopedParamContainer{
public:
ScopedParamContainer(LogContext & context):m_context(context) {}
~ScopedParamContainer() {
for(std::vector<std::string>::const_iterator it=m_names.begin();it!=m_names.end();++it)
{ m_context.erase(*it);
for(auto it = m_names.cbegin(); it != m_names.cend(); ++it) {
m_context.erase(*it);
}
}
......@@ -162,7 +148,7 @@ class ScopedParamContainer{
private:
LogContext & m_context;
std::vector<std::string> m_names;
std::list<std::string> m_names;
};
std::ostream & operator << (std::ostream & os , const LogContext & lc);
......
......@@ -29,11 +29,9 @@
#include "castor/log/Param.hpp"
#include <list>
#include <map>
#include <pthread.h>
#include <syslog.h>
#include <sys/time.h>
#include <vector>
/**
* It is a convention of CASTOR to use syslog level of LOG_NOTICE to label
......@@ -118,82 +116,6 @@ public:
*/
const std::string &getProgramName() const 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 operator() 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.
* @param msg the message.
* @param params the parameters of the message.
* @param timeStamp the time stamp of the log message.
*/
virtual void operator() (
const int priority,
const std::string &msg,
const std::vector<Param> &params,
const struct timeval &timeStamp) 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 operator() 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.
* @param msg the message.
* @param params the parameters of the message.
* @param timeStamp the time stamp of the log message.
*/
virtual void operator() (
const int priority,
const std::string &msg,
const std::list<Param> &params,
const struct timeval &timeStamp) 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 operator() 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.
* @param msg the message.
* @param numParams the number of parameters in the message.
* @param params the parameters of the message.
* @param timeStamp the time stamp of the log message.
*/
virtual void operator() (
const int priority,
const std::string &msg,
const int numParams,
const Param params[],
const struct timeval &timeStamp) 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 operator() 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.
*/
virtual void operator() (
const int priority,
const std::string &msg,
const std::vector<Param> &params) 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
......@@ -209,82 +131,7 @@ public:
virtual void operator() (
const int priority,
const std::string &msg,
const std::list<Param> &params) 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 operator() 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 numParams the number of parameters in the message.
* @param params the parameters of the message.
*/
virtual void operator() (
const int priority,
const std::string &msg,
const int numParams,
const Param params[]) 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 operator() 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 operator() (
const int priority,
const std::string &msg) throw() = 0;
/**
* A template function that wraps operator() in order to get the compiler
* to automatically determine the size of the params parameter, therefore
*
* Note that this version of operator() 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.
* @param msg the message.
* @param params the parameters of the message.
* @param timeStamp the time stamp of the log message.
*/
template<int numParams> void operator() (
const int priority,
const std::string &msg,
const log::Param(&params)[numParams],
const struct timeval &timeStamp) throw() {
operator() (priority, msg, numParams, params, timeStamp);
}
/**
* A template function that wraps operator() 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 operator() 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 operator() (
const int priority,
const std::string &msg,
const log::Param(&params)[numParams]) throw() {
operator() (priority, msg, numParams, params);
}
const std::list<Param> &params = std::list<Param>()) throw() = 0;
protected:
......
......@@ -130,40 +130,6 @@ castor::log::StringLogger::~StringLogger() throw() {
void castor::log::StringLogger::prepareForFork() {
}
//-----------------------------------------------------------------------------
// operator()
//-----------------------------------------------------------------------------
void castor::log::StringLogger::operator() (
const int priority,
const std::string &msg,
const std::vector<Param> &params,
const struct timeval &timeStamp) throw() {
operator() (priority, msg, params.begin(), params.end(), timeStamp);
}
//-----------------------------------------------------------------------------
// operator()
//-----------------------------------------------------------------------------
void castor::log::StringLogger::operator() (
const int priority,
const std::string &msg,
const std::list<Param> &params,
const struct timeval &timeStamp) throw() {
operator() (priority, msg, params.begin(), params.end(), timeStamp);
}
//-----------------------------------------------------------------------------
// operator()
//-----------------------------------------------------------------------------
void castor::log::StringLogger::operator() (
const int priority,
const std::string &msg,
const int numParams,
const log::Param params[],
const struct timeval &timeStamp) throw() {
operator() (priority, msg, params, params+numParams, timeStamp);
}
//-----------------------------------------------------------------------------
// buildSyslogHeader
//-----------------------------------------------------------------------------
......@@ -271,20 +237,6 @@ void castor::log::StringLogger::reducedSyslog(std::string msg)
pthread_mutex_unlock(&m_mutex);
}
//-----------------------------------------------------------------------------
// operator()
//-----------------------------------------------------------------------------
void castor::log::StringLogger::operator() (
const int priority,
const std::string &msg,
const std::vector<Param> &params) throw() {
struct timeval timeStamp;
gettimeofday(&timeStamp, NULL);
operator() (priority, msg, params.begin(), params.end(), timeStamp);
}
//-----------------------------------------------------------------------------
// operator()
//-----------------------------------------------------------------------------
......@@ -298,29 +250,3 @@ void castor::log::StringLogger::operator() (
operator() (priority, msg, params.begin(), params.end(), timeStamp);
}
//-----------------------------------------------------------------------------
// operator()
//-----------------------------------------------------------------------------
void castor::log::StringLogger::operator() (
const int priority,
const std::string &msg,
const int numParams,
const log::Param params[]) throw() {
struct timeval timeStamp;
gettimeofday(&timeStamp, NULL);
operator() (priority, msg, numParams, params, timeStamp);
}
//-----------------------------------------------------------------------------
// operator()
//-----------------------------------------------------------------------------
void castor::log::StringLogger::operator() (
const int priority,
const std::string &msg) throw() {
Param *emptyParams = NULL;
operator() (priority, msg, 0, emptyParams);
}
</
......@@ -70,99 +70,6 @@ public:
*/
void prepareForFork() ;
/**
* 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 operator() 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.
* @param msg the message.
* @param params the parameters of the message.
* @param timeStamp the time stamp of the log message.
*/
void operator() (
const int priority,
const std::string &msg,
const std::vector<Param> &params,
const struct timeval &timeStamp) 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 operator() 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.
* @param msg the message.
* @param params the parameters of the message.
* @param timeStamp the time stamp of the log message.
*/
void operator() (
const int priority,
const std::string &msg,
const std::list<Param> &params,
const struct timeval &timeStamp) 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 operator() 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.
* @param msg the message.
* @param numParams the number of parameters in the message.
* @param params the parameters of the message.
* @param timeStamp the time stamp of the log message.
*/
void operator() (
const int priority,
const std::string &msg,
const int numParams,
const Param params[],
const struct timeval &timeStamp) 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 operator() 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.
*/
void operator() (
const int priority,
const std::string &msg,
const std::vector<Param> &params) 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 operator() 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.
*/
void operator() (
const int priority,
const std::string &msg,
const std::list<Param> &params) 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
......@@ -173,30 +80,13 @@ public:
*
* @param priority the priority of the message as defined by the syslog API.
* @param msg the message.
* @param numParams the number of parameters in the message.
* @param params the parameters of the message.
*/
void operator() (
const int priority,
const std::string &msg,
const int numParams,
const Param params[]) throw();
const std::list<Param> &params = std::list<Param>()) 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