LibreOffice Module comphelper (master)
1
|
encapsulates a css::logging::XLogger More...
#include <logging.hxx>
Public Member Functions | |
EventLogger (const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const char *_pAsciiLoggerName) | |
creates an EventLogger instance working with a css.logging.XLogger instance given by ASCII name. More... | |
bool | isLoggable (const sal_Int32 _nLogLevel) const |
determines whether an event with the given level would be logged More... | |
void | log (const sal_Int32 _nLogLevel, const OUString &rMessage) const |
logs a given message, without any arguments, or source class/method names More... | |
const css::uno::Reference< css::logging::XLogger > & | getLogger () const |
template<typename ARGTYPE1 > | |
void | log (const sal_Int32 _nLogLevel, const OUString &_rMessage, ARGTYPE1 _argument1) const |
logs a given message, replacing a placeholder in the message with an argument More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 > | |
void | log (const sal_Int32 _nLogLevel, const OUString &_rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2) const |
logs a given message, replacing 2 placeholders in the message with respective values More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 , typename ARGTYPE3 > | |
void | log (const sal_Int32 _nLogLevel, const OUString &_rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3) const |
logs a given message, replacing 3 placeholders in the message with respective values More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 , typename ARGTYPE3 , typename ARGTYPE4 > | |
void | log (const sal_Int32 _nLogLevel, const OUString &_rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4) const |
logs a given message, replacing 4 placeholders in the message with respective values More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 , typename ARGTYPE3 , typename ARGTYPE4 , typename ARGTYPE5 > | |
void | log (const sal_Int32 _nLogLevel, const OUString &_rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5) const |
logs a given message, replacing 5 placeholders in the message with respective values More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 , typename ARGTYPE3 , typename ARGTYPE4 , typename ARGTYPE5 , typename ARGTYPE6 > | |
void | log (const sal_Int32 _nLogLevel, const OUString &_rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5, ARGTYPE6 _argument6) const |
logs a given message, replacing 6 placeholders in the message with respective values More... | |
template<typename ARGTYPE1 > | |
void | log (const sal_Int32 _nLogLevel, const char *_pMessage, ARGTYPE1 _argument1) const |
logs a given message, replacing a placeholder in the message with an argument More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 > | |
void | log (const sal_Int32 _nLogLevel, const char *_pMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2) const |
logs a given message, replacing 2 placeholders in the message with respective values More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 , typename ARGTYPE3 > | |
void | log (const sal_Int32 _nLogLevel, const char *_pMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3) const |
logs a given message, replacing 3 placeholders in the message with respective values More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 , typename ARGTYPE3 , typename ARGTYPE4 > | |
void | log (const sal_Int32 _nLogLevel, const char *_pMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4) const |
logs a given message, replacing 4 placeholders in the message with respective values More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 , typename ARGTYPE3 , typename ARGTYPE4 , typename ARGTYPE5 > | |
void | log (const sal_Int32 _nLogLevel, const char *_pMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5) const |
logs a given message, replacing 5 placeholders in the message with respective values More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 , typename ARGTYPE3 , typename ARGTYPE4 , typename ARGTYPE5 , typename ARGTYPE6 > | |
void | log (const sal_Int32 _nLogLevel, const char *_pMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5, ARGTYPE6 _argument6) const |
logs a given message, replacing 6 placeholders in the message with respective values More... | |
template<typename ARGTYPE1 > | |
void | logp (const sal_Int32 _nLogLevel, const char *_pSourceClass, const char *_pSourceMethod, const OUString &_rMessage, ARGTYPE1 _argument1) const |
logs a given message, replacing a placeholder in the message with an argument More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 > | |
void | logp (const sal_Int32 _nLogLevel, const char *_pSourceClass, const char *_pSourceMethod, const OUString &_rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2) const |
logs a given message, replacing 2 placeholders in the message with respective values More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 , typename ARGTYPE3 > | |
void | logp (const sal_Int32 _nLogLevel, const char *_pSourceClass, const char *_pSourceMethod, const OUString &_rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3) const |
logs a given message, replacing 3 placeholders in the message with respective values More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 , typename ARGTYPE3 , typename ARGTYPE4 > | |
void | logp (const sal_Int32 _nLogLevel, const char *_pSourceClass, const char *_pSourceMethod, const OUString &_rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4) const |
logs a given message, replacing 4 placeholders in the message with respective values More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 , typename ARGTYPE3 , typename ARGTYPE4 , typename ARGTYPE5 > | |
void | logp (const sal_Int32 _nLogLevel, const char *_pSourceClass, const char *_pSourceMethod, const OUString &_rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5) const |
logs a given message, replacing 5 placeholders in the message with respective values More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 , typename ARGTYPE3 , typename ARGTYPE4 , typename ARGTYPE5 , typename ARGTYPE6 > | |
void | logp (const sal_Int32 _nLogLevel, const char *_pSourceClass, const char *_pSourceMethod, const OUString &_rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5, ARGTYPE6 _argument6) const |
logs a given message, replacing 6 placeholders in the message with respective values More... | |
template<typename ARGTYPE1 > | |
void | logp (const sal_Int32 _nLogLevel, const char *_pSourceClass, const char *_pSourceMethod, const char *_pAsciiMessage, ARGTYPE1 _argument1) const |
logs a given ASCII message, replacing a placeholder in the message with an argument More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 > | |
void | logp (const sal_Int32 _nLogLevel, const char *_pSourceClass, const char *_pSourceMethod, const char *_pAsciiMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2) const |
logs a given ASCII message, replacing 2 placeholders in the message with respective values More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 , typename ARGTYPE3 > | |
void | logp (const sal_Int32 _nLogLevel, const char *_pSourceClass, const char *_pSourceMethod, const char *_pAsciiMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3) const |
logs a given ASCII message, replacing 3 placeholders in the message with respective values More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 , typename ARGTYPE3 , typename ARGTYPE4 > | |
void | logp (const sal_Int32 _nLogLevel, const char *_pSourceClass, const char *_pSourceMethod, const char *_pAsciiMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4) const |
logs a given ASCII message, replacing 4 placeholders in the message with respective values More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 , typename ARGTYPE3 , typename ARGTYPE4 , typename ARGTYPE5 > | |
void | logp (const sal_Int32 _nLogLevel, const char *_pSourceClass, const char *_pSourceMethod, const char *_pAsciiMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5) const |
logs a given ASCII message, replacing 5 placeholders in the message with respective values More... | |
template<typename ARGTYPE1 , typename ARGTYPE2 , typename ARGTYPE3 , typename ARGTYPE4 , typename ARGTYPE5 , typename ARGTYPE6 > | |
void | logp (const sal_Int32 _nLogLevel, const char *_pSourceClass, const char *_pSourceMethod, const char *_pAsciiMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5, ARGTYPE6 _argument6) const |
logs a given ASCII message, replacing 6 placeholders in the message with respective values More... | |
Protected Member Functions | |
void | impl_log (const sal_Int32 _nLogLevel, const char *_pSourceClass, const char *_pSourceMethod, const OUString &_rMessage, const OptionalString &_rArgument1=OptionalString(), const OptionalString &_rArgument2=OptionalString(), const OptionalString &_rArgument3=OptionalString(), const OptionalString &_rArgument4=OptionalString(), const OptionalString &_rArgument5=OptionalString(), const OptionalString &_rArgument6=OptionalString()) const |
Protected Attributes | |
std::shared_ptr< EventLogger_Impl > | m_pImpl |
encapsulates a css::logging::XLogger
The class silences several (unlikely) errors which could potentially happen when working with a logger. Additionally, it provides some convenience methods for logging events.
You can use this class as follows
EventLogger aLogger( xContext, sLoggerName ); ... aLogger.log( LogLevel::SEVERE, sSomeMessage ); aLogger.logp( LogLevel::CONFIG, "MyClass", "MyMethod", sSomeMessage, SomeParameter1, SomeParameter2, SomeParameter3 );
The <code>log</code> and <code>logp</code> calls support up to 6 parameters, which can be of arbitrary type. For every parameter, there must exist a function <code>convertLogArgToString</code> which takes an argument of the respective type, and returns a string. After a parameter has been converted to a string using the above mentioned <code>convertLogArgToString</code> function, a placeholder $1$ (resp. $2$ resp. $4$ ...) in the message will be replaced with this string, and the resulting message will be logged.
Definition at line 92 of file logging.hxx.
comphelper::EventLogger::EventLogger | ( | const css::uno::Reference< css::uno::XComponentContext > & | _rxContext, |
const char * | _pAsciiLoggerName | ||
) |
creates an EventLogger
instance working with a css.logging.XLogger instance given by ASCII name.
_rxContext | the component context to create services |
_rLoggerName | the ASCII name of the logger to create. |
Definition at line 67 of file logging.cxx.
References m_pImpl, and make_shared().
const css::uno::Reference< css::logging::XLogger > & comphelper::EventLogger::getLogger | ( | ) | const |
Definition at line 89 of file logging.cxx.
References m_pImpl.
|
protected |
Definition at line 109 of file logging.cxx.
bool comphelper::EventLogger::isLoggable | ( | const sal_Int32 | _nLogLevel | ) | const |
determines whether an event with the given level would be logged
Definition at line 72 of file logging.cxx.
|
inline |
logs a given message, without any arguments, or source class/method names
Definition at line 121 of file logging.hxx.
|
inline |
logs a given message, replacing a placeholder in the message with an argument
The function takes, additionally to the log level and the message, an arbitrary argument. This argument is converted to a string using an overloaded function named convertLogArgToString
. Then, a placeholder "$1$" is searched in the message string, and replaced with the argument string.
Definition at line 137 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given message, replacing 2 placeholders in the message with respective values
Definition at line 146 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given message, replacing 3 placeholders in the message with respective values
Definition at line 156 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given message, replacing 4 placeholders in the message with respective values
Definition at line 167 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given message, replacing 5 placeholders in the message with respective values
Definition at line 179 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given message, replacing 6 placeholders in the message with respective values
Definition at line 192 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given message, replacing a placeholder in the message with an argument
The function takes, additionally to the log level and the message, an arbitrary argument. This argument is converted to a string using an overloaded function named convertLogArgToString
. Then, a placeholder "$1$" is searched in the message string, and replaced with the argument string.
Definition at line 216 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given message, replacing 2 placeholders in the message with respective values
Definition at line 225 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given message, replacing 3 placeholders in the message with respective values
Definition at line 235 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given message, replacing 4 placeholders in the message with respective values
Definition at line 246 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given message, replacing 5 placeholders in the message with respective values
Definition at line 258 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given message, replacing 6 placeholders in the message with respective values
Definition at line 271 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given message, replacing a placeholder in the message with an argument
The function takes, additionally to the logp level and the message, an arbitrary argument. This argument is converted to a string using an overloaded function named convertLogArgToString
. Then, a placeholder "$1$" is searched in the message string, and replaced with the argument string.
Definition at line 295 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given message, replacing 2 placeholders in the message with respective values
Definition at line 304 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given message, replacing 3 placeholders in the message with respective values
Definition at line 314 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given message, replacing 4 placeholders in the message with respective values
Definition at line 325 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given message, replacing 5 placeholders in the message with respective values
Definition at line 337 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given message, replacing 6 placeholders in the message with respective values
Definition at line 350 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given ASCII message, replacing a placeholder in the message with an argument
The function takes, additionally to the logp level and the message, an arbitrary argument. This argument is converted to a string using an overloaded function named convertLogArgToString
. Then, a placeholder "$1$" is searched in the message string, and replaced with the argument string.
Definition at line 374 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given ASCII message, replacing 2 placeholders in the message with respective values
Definition at line 383 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given ASCII message, replacing 3 placeholders in the message with respective values
Definition at line 393 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given ASCII message, replacing 4 placeholders in the message with respective values
Definition at line 404 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given ASCII message, replacing 5 placeholders in the message with respective values
Definition at line 416 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
inline |
logs a given ASCII message, replacing 6 placeholders in the message with respective values
Definition at line 429 of file logging.hxx.
References comphelper::log::convert::convertLogArgToString().
|
protected |
Definition at line 95 of file logging.hxx.
Referenced by getLogger(), impl_log(), and isLoggable().