Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
e9b90bd7
Commit
e9b90bd7
authored
Feb 15, 2016
by
Steven Murray
Browse files
Removed std::vector and array params from cta::log
parent
634c77c2
Changes
10
Hide whitespace changes
Inline
Side-by-side
common/log/DummyLogger.cpp
View file @
e9b90bd7
...
...
@@ -34,42 +34,6 @@ cta::log::DummyLogger::~DummyLogger() { }
//------------------------------------------------------------------------------
void
cta
::
log
::
DummyLogger
::
prepareForFork
()
{}
//------------------------------------------------------------------------------
// operator()
//------------------------------------------------------------------------------
void
cta
::
log
::
DummyLogger
::
operator
()(
const
int
priority
,
const
std
::
string
&
msg
,
const
std
::
vector
<
Param
>
&
params
,
const
struct
timeval
&
timeStamp
)
{}
//------------------------------------------------------------------------------
// operator()
//------------------------------------------------------------------------------
void
cta
::
log
::
DummyLogger
::
operator
()
(
const
int
priority
,
const
std
::
string
&
msg
,
const
std
::
list
<
Param
>
&
params
,
const
struct
timeval
&
timeStamp
)
{}
//------------------------------------------------------------------------------
// operator()
//------------------------------------------------------------------------------
void
cta
::
log
::
DummyLogger
::
operator
()
(
const
int
priority
,
const
std
::
string
&
msg
,
const
int
numParams
,
const
log
::
Param
params
[],
const
struct
timeval
&
timeStamp
)
{}
//------------------------------------------------------------------------------
// operator()
//------------------------------------------------------------------------------
void
cta
::
log
::
DummyLogger
::
operator
()
(
const
int
priority
,
const
std
::
string
&
msg
,
const
std
::
vector
<
Param
>
&
params
)
{}
//------------------------------------------------------------------------------
// operator()
//------------------------------------------------------------------------------
...
...
@@ -77,19 +41,3 @@ void cta::log::DummyLogger::operator() (
const
int
priority
,
const
std
::
string
&
msg
,
const
std
::
list
<
Param
>
&
params
)
{}
//------------------------------------------------------------------------------
// operator()
//------------------------------------------------------------------------------
void
cta
::
log
::
DummyLogger
::
operator
()
(
const
int
priority
,
const
std
::
string
&
msg
,
const
int
numParams
,
const
log
::
Param
params
[])
{}
//------------------------------------------------------------------------------
// operator()
//------------------------------------------------------------------------------
void
cta
::
log
::
DummyLogger
::
operator
()
(
const
int
priority
,
const
std
::
string
&
msg
)
{}
common/log/DummyLogger.hpp
View file @
e9b90bd7
...
...
@@ -66,91 +66,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
);
/**
* 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
);
/**
* 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
);
/**
* 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
);
/**
* 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
);
/**
* 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
[]);
/**
* 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
);
const
std
::
list
<
Param
>
&
params
=
std
::
list
<
Param
>
());
};
// class DummyLogger
...
...
common/log/LogContext.cpp
View file @
e9b90bd7
...
...
@@ -52,11 +52,6 @@ void cta::log::LogContext::log(const int priority, const std::string& msg) {
m_log
(
priority
,
msg
,
m_params
);
}
void
cta
::
log
::
LogContext
::
log
(
const
int
priority
,
const
std
::
string
&
msg
,
const
timeval
&
timeStamp
)
{
m_log
(
priority
,
msg
,
m_params
,
timeStamp
);
}
void
cta
::
log
::
LogContext
::
logBacktrace
(
const
int
priority
,
const
std
::
string
&
backtrace
)
{
// Sanity check to prevent substr from throwing exceptions
...
...
common/log/LogContext.hpp
View file @
e9b90bd7
...
...
@@ -96,20 +96,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
);
/**
* Helper class to find parameters by name.
*/
...
...
@@ -142,8 +128,8 @@ class ScopedParamContainer{
public:
ScopedParamContainer
(
LogContext
&
context
)
:
m_context
(
context
)
{}
~
ScopedParamContainer
()
{
for
(
std
::
vector
<
std
::
string
>::
const_iter
ato
r
it
=
m_names
.
begin
();
it
!=
m_names
.
end
();
++
it
)
{
m_context
.
erase
(
*
it
);
for
(
a
u
to
it
=
m_names
.
c
begin
();
it
!=
m_names
.
c
end
();
++
it
)
{
m_context
.
erase
(
*
it
);
}
}
...
...
@@ -155,7 +141,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
);
...
...
common/log/Logger.hpp
View file @
e9b90bd7
...
...
@@ -27,7 +27,6 @@
#include
<pthread.h>
#include
<syslog.h>
#include
<sys/time.h>
#include
<vector>
/**
* It is a convention of CTA to use syslog level of LOG_NOTICE to label
...
...
@@ -111,82 +110,6 @@ public:
*/
const
std
::
string
&
getProgramName
()
const
;
/**
* 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
)
=
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
)
=
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
)
=
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
)
=
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
...
...
@@ -202,82 +125,7 @@ public:
virtual
void
operator
()
(
const
int
priority
,
const
std
::
string
&
msg
,
const
std
::
list
<
Param
>
&
params
)
=
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
[])
=
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
)
=
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
>
())
=
0
;
protected:
...
...
common/log/StringLogger.cpp
View file @
e9b90bd7
...
...
@@ -129,40 +129,6 @@ cta::log::StringLogger::~StringLogger() {
void
cta
::
log
::
StringLogger
::
prepareForFork
()
{
}
//-----------------------------------------------------------------------------
// operator()
//-----------------------------------------------------------------------------
void
cta
::
log
::
StringLogger
::
operator
()
(
const
int
priority
,
const
std
::
string
&
msg
,
const
std
::
vector
<
Param
>
&
params
,
const
struct
timeval
&
timeStamp
)
{
operator
()
(
priority
,
msg
,
params
.
begin
(),
params
.
end
(),
timeStamp
);
}
//-----------------------------------------------------------------------------
// operator()
//-----------------------------------------------------------------------------
void
cta
::
log
::
StringLogger
::
operator
()
(
const
int
priority
,
const
std
::
string
&
msg
,
const
std
::
list
<
Param
>
&
params
,
const
struct
timeval
&
timeStamp
)
{
operator
()
(
priority
,
msg
,
params
.
begin
(),
params
.
end
(),
timeStamp
);
}
//-----------------------------------------------------------------------------
// operator()
//-----------------------------------------------------------------------------
void
cta
::
log
::
StringLogger
::
operator
()
(
const
int
priority
,
const
std
::
string
&
msg
,
const
int
numParams
,
const
log
::
Param
params
[],
const
struct
timeval
&
timeStamp
)
{
operator
()
(
priority
,
msg
,
params
,
params
+
numParams
,
timeStamp
);
}
//-----------------------------------------------------------------------------
// buildSyslogHeader
//-----------------------------------------------------------------------------
...
...
@@ -269,20 +235,6 @@ void cta::log::StringLogger::reducedSyslog(std::string msg) {
pthread_mutex_unlock
(
&
m_mutex
);
}
//-----------------------------------------------------------------------------
// operator()
//-----------------------------------------------------------------------------
void
cta
::
log
::
StringLogger
::
operator
()
(
const
int
priority
,
const
std
::
string
&
msg
,
const
std
::
vector
<
Param
>
&
params
)
{
struct
timeval
timeStamp
;
gettimeofday
(
&
timeStamp
,
NULL
);
operator
()
(
priority
,
msg
,
params
.
begin
(),
params
.
end
(),
timeStamp
);
}
//-----------------------------------------------------------------------------
// operator()
//-----------------------------------------------------------------------------
...
...
@@ -296,29 +248,3 @@ void cta::log::StringLogger::operator() (
operator
()
(
priority
,
msg
,
params
.
begin
(),
params
.
end
(),
timeStamp
);
}
//-----------------------------------------------------------------------------
// operator()
//-----------------------------------------------------------------------------
void
cta
::
log
::
StringLogger
::
operator
()
(
const
int
priority
,
const
std
::
string
&
msg
,
const
int
numParams
,
const
log
::
Param
params
[])
{
struct
timeval
timeStamp
;
gettimeofday
(
&
timeStamp
,
NULL
);
operator
()
(
priority
,
msg
,
numParams
,
params
,
timeStamp
);
}
//-----------------------------------------------------------------------------
// operator()
//-----------------------------------------------------------------------------
void
cta
::
log
::
StringLogger
::
operator
()
(
const
int
priority
,
const
std
::
string
&
msg
)
{
Param
*
emptyParams
=
NULL
;
operator
()
(
priority
,
msg
,
0
,
emptyParams
);
}
common/log/StringLogger.hpp
View file @
e9b90bd7
...
...
@@ -61,99 +61,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
);
/**
* 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
);
/**
* 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
);
/**
* 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
);
/**
* 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
);
/**
* Writes a message into the CASTOR logging system. Note that no exception
* will ever be thrown in case of failure. Failures will actually be
...
...
@@ -164,30 +71,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
[]);
const
std
::
list
<
Param
>
&
params
=
std
::
list
<
Param
>
());
/**
* 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.
*/
void
operator
()
(
const
int
priority
,
const
std
::
string
&
msg
);
/**
* Extractor for the resulting logs.
*/
...
...
common/log/SyslogLogger.cpp
View file @
e9b90bd7
...
...
@@ -274,40 +274,6 @@ void cta::log::SyslogLogger::closeLog() {
m_logFile
=
-
1
;
}
//-----------------------------------------------------------------------------
// operator()
//-----------------------------------------------------------------------------
void
cta
::
log
::
SyslogLogger
::
operator
()
(
const
int
priority
,
const
std
::
string
&
msg
,
const
std
::
vector
<
Param
>
&
params
,
const
struct
timeval
&
timeStamp
)
{
operator
()
(
priority
,
msg
,
params
.
begin
(),
params
.
end
(),
timeStamp
);