LibreOffice Module extensions (master) 1
Public Member Functions | Private Attributes | List of all members
logging::LogHandlerHelper Class Reference

#include <loghandler.hxx>

Collaboration diagram for logging::LogHandlerHelper:
[legend]

Public Member Functions

 LogHandlerHelper (const css::uno::Reference< css::uno::XComponentContext > &_rxContext, ::osl::Mutex &_rMutex, ::cppu::OBroadcastHelper &_rBHelper)
 
void setIsInitialized ()
 
bool getEncoding (OUString &_out_rEncoding) const
 
bool setEncoding (std::u16string_view _rEncoding)
 
rtl_TextEncoding getTextEncoding () const
 
const css::uno::Reference< css::logging::XLogFormatter > & getFormatter () const
 
void setFormatter (const css::uno::Reference< css::logging::XLogFormatter > &_rxFormatter)
 
sal_Int32 getLevel () const
 
void setLevel (const sal_Int32 _nLevel)
 
void enterMethod ()
 prepares implementation of a public accessible method of a log handler More...
 
bool formatForPublishing (const css::logging::LogRecord &_rRecord, OString &_out_rEntry) const
 formats a record for publishing it More...
 
bool getEncodedHead (OString &_out_rHead) const
 retrieves our formatter's heading, encoded with our encoding More...
 
bool getEncodedTail (OString &_out_rTail) const
 retrieves our formatter's tail, encoded with our encoding More...
 
void initFromSettings (const ::comphelper::NamedValueCollection &_rSettings)
 initializes the instance from a collection of named settings More...
 

Private Attributes

rtl_TextEncoding m_eEncoding
 
sal_Int32 m_nLevel
 
css::uno::Reference< css::logging::XLogFormatter > m_xFormatter
 
css::uno::Reference< css::uno::XComponentContext > m_xContext
 
::osl::Mutex & m_rMutex
 
::cppu::OBroadcastHelperm_rBHelper
 
bool m_bInitialized
 

Detailed Description

Definition at line 38 of file loghandler.hxx.

Constructor & Destructor Documentation

◆ LogHandlerHelper()

logging::LogHandlerHelper::LogHandlerHelper ( const css::uno::Reference< css::uno::XComponentContext > &  _rxContext,
::osl::Mutex &  _rMutex,
::cppu::OBroadcastHelper _rBHelper 
)

Definition at line 47 of file loghandler.cxx.

References m_nLevel, and m_rMutex.

Member Function Documentation

◆ enterMethod()

void logging::LogHandlerHelper::enterMethod ( )

prepares implementation of a public accessible method of a log handler

enterMethod does the following things:

  • It acquires the mutex given in the constructor.
  • It checks whether the component is already initialized, and throws an exception if not os.
  • It checks whether the component is already disposed, and throws an exception if not os.
  • It creates a default formatter (PlainTextFormatter), if no formatter exists at this time.

Definition at line 72 of file loghandler.cxx.

References cppu::OBroadcastHelperVar< class container, class keyType >::bDisposed, DBG_UNHANDLED_EXCEPTION, Exception, getFormatter(), m_bInitialized, m_rBHelper, m_rMutex, m_xContext, and setFormatter().

◆ formatForPublishing()

bool logging::LogHandlerHelper::formatForPublishing ( const css::logging::LogRecord &  _rRecord,
OString &  _out_rEntry 
) const

formats a record for publishing it

The method first checks whether the records log level is greater or equal our own log level. If not, <FALSE> is returned.

Second, our formatter is used to create a unicode string from the log record. If an error occurs during this, e.g. if the formatter is <NULL> or throws an exception during formatting, <FALSE> is returned.

Finally, the unicode string is encoded into a byte string, using our encoding setting. Then, <TRUE> is returned.

Definition at line 124 of file loghandler.cxx.

References DBG_UNHANDLED_EXCEPTION, Exception, getFormatter(), getLevel(), getTextEncoding(), and OUStringToOString().

◆ getEncodedHead()

bool logging::LogHandlerHelper::getEncodedHead ( OString &  _out_rHead) const

retrieves our formatter's heading, encoded with our encoding

Returns
<TRUE> in case of success, <FALSE> if any error occurred

Definition at line 145 of file loghandler.cxx.

References DBG_UNHANDLED_EXCEPTION, Exception, getFormatter(), getTextEncoding(), and OUStringToOString().

◆ getEncodedTail()

bool logging::LogHandlerHelper::getEncodedTail ( OString &  _out_rTail) const

retrieves our formatter's tail, encoded with our encoding

Returns
<TRUE> in case of success, <FALSE> if any error occurred

Definition at line 162 of file loghandler.cxx.

References DBG_UNHANDLED_EXCEPTION, Exception, getFormatter(), getTextEncoding(), and OUStringToOString().

◆ getEncoding()

bool logging::LogHandlerHelper::getEncoding ( OUString &  _out_rEncoding) const

Definition at line 98 of file loghandler.cxx.

References m_eEncoding.

◆ getFormatter()

const css::uno::Reference< css::logging::XLogFormatter > & logging::LogHandlerHelper::getFormatter ( ) const
inline

Definition at line 71 of file loghandler.hxx.

References m_xFormatter.

Referenced by enterMethod(), formatForPublishing(), getEncodedHead(), and getEncodedTail().

◆ getLevel()

sal_Int32 logging::LogHandlerHelper::getLevel ( ) const
inline

Definition at line 79 of file loghandler.hxx.

References m_nLevel.

Referenced by formatForPublishing().

◆ getTextEncoding()

rtl_TextEncoding logging::LogHandlerHelper::getTextEncoding ( ) const
inline

Definition at line 68 of file loghandler.hxx.

References m_eEncoding.

Referenced by formatForPublishing(), getEncodedHead(), and getEncodedTail().

◆ initFromSettings()

void logging::LogHandlerHelper::initFromSettings ( const ::comphelper::NamedValueCollection _rSettings)

initializes the instance from a collection of named settings

The recognized named settings are Encoding, Formatter, and Level, which initialize the respective attributes.

Settings which are recognized are remove from the given collection. This allows the caller to determine whether or not the collection contained any unsupported items, and react appropriately.

Exceptions
IllegalArgumentExceptionif one of the values in the collection is of wrong type.

Definition at line 58 of file loghandler.cxx.

References m_nLevel, m_xFormatter, and setEncoding().

◆ setEncoding()

bool logging::LogHandlerHelper::setEncoding ( std::u16string_view  _rEncoding)

Definition at line 111 of file loghandler.cxx.

References m_eEncoding, and OUStringToOString().

Referenced by initFromSettings().

◆ setFormatter()

void logging::LogHandlerHelper::setFormatter ( const css::uno::Reference< css::logging::XLogFormatter > &  _rxFormatter)
inline

Definition at line 73 of file loghandler.hxx.

References m_xFormatter.

Referenced by enterMethod().

◆ setIsInitialized()

void logging::LogHandlerHelper::setIsInitialized ( )
inline

Definition at line 62 of file loghandler.hxx.

References m_bInitialized.

◆ setLevel()

void logging::LogHandlerHelper::setLevel ( const sal_Int32  _nLevel)
inline

Definition at line 81 of file loghandler.hxx.

References m_nLevel.

Member Data Documentation

◆ m_bInitialized

bool logging::LogHandlerHelper::m_bInitialized
private

Definition at line 52 of file loghandler.hxx.

Referenced by enterMethod(), and setIsInitialized().

◆ m_eEncoding

rtl_TextEncoding logging::LogHandlerHelper::m_eEncoding
private

Definition at line 42 of file loghandler.hxx.

Referenced by getEncoding(), getTextEncoding(), and setEncoding().

◆ m_nLevel

sal_Int32 logging::LogHandlerHelper::m_nLevel
private

Definition at line 43 of file loghandler.hxx.

Referenced by getLevel(), initFromSettings(), and setLevel().

◆ m_rBHelper

::cppu::OBroadcastHelper& logging::LogHandlerHelper::m_rBHelper
private

Definition at line 51 of file loghandler.hxx.

Referenced by enterMethod().

◆ m_rMutex

::osl::Mutex& logging::LogHandlerHelper::m_rMutex
private

Definition at line 50 of file loghandler.hxx.

Referenced by enterMethod().

◆ m_xContext

css::uno::Reference< css::uno::XComponentContext > logging::LogHandlerHelper::m_xContext
private

Definition at line 49 of file loghandler.hxx.

Referenced by enterMethod().

◆ m_xFormatter

css::uno::Reference< css::logging::XLogFormatter > logging::LogHandlerHelper::m_xFormatter
private

Definition at line 45 of file loghandler.hxx.

Referenced by getFormatter(), initFromSettings(), and setFormatter().


The documentation for this class was generated from the following files: