23#include <com/sun/star/logging/LogLevel.hpp>
24#include <com/sun/star/lang/IllegalArgumentException.hpp>
25#include <com/sun/star/lang/DisposedException.hpp>
26#include <com/sun/star/logging/PlainTextFormatter.hpp>
29#include <rtl/tencinfo.h>
36 using ::com::sun::star::uno::Reference;
37 using ::com::sun::star::uno::XComponentContext;
38 using ::com::sun::star::logging::LogRecord;
39 using ::com::sun::star::logging::XLogFormatter;
40 using ::com::sun::star::uno::Exception;
41 using ::com::sun::star::lang::IllegalArgumentException;
42 using ::com::sun::star::lang::DisposedException;
43 using ::com::sun::star::logging::PlainTextFormatter;
45 namespace LogLevel = ::com::sun::star::logging::LogLevel;
48 :m_eEncoding( RTL_TEXTENCODING_UTF8 )
52 ,m_rBHelper( _rBHelper )
53 ,m_bInitialized( false )
61 if ( _rSettings.get_ensureType(
"Encoding", sEncoding ) )
64 throw IllegalArgumentException();
68 _rSettings.get_ensureType(
"Level",
m_nLevel );
77 throw DisposedException(
"component not initialized" );
80 throw DisposedException(
"component already disposed" );
87 Reference< XLogFormatter > xFormatter( PlainTextFormatter::create(
m_xContext ), css::uno::UNO_SET_THROW );
100 const char* pMimeCharset = rtl_getMimeCharsetFromTextEncoding(
m_eEncoding );
103 _out_rEncoding = OUString::createFromAscii( pMimeCharset );
106 _out_rEncoding.clear();
113 OString sAsciiEncoding(
OUStringToOString( _rEncoding, RTL_TEXTENCODING_ASCII_US ) );
114 rtl_TextEncoding eEncoding = rtl_getTextEncodingFromMimeCharset( sAsciiEncoding.getStr() );
115 if ( eEncoding != RTL_TEXTENCODING_DONTKNOW )
132 Reference< XLogFormatter > xFormatter(
getFormatter(), css::uno::UNO_SET_THROW );
133 OUString sEntry( xFormatter->format( _rRecord ) );
149 Reference< XLogFormatter > xFormatter(
getFormatter(), css::uno::UNO_SET_THROW );
150 OUString sHead( xFormatter->getHead() );
166 Reference< XLogFormatter > xFormatter(
getFormatter(), css::uno::UNO_SET_THROW );
167 OUString sTail( xFormatter->getTail() );
LogHandlerHelper(const css::uno::Reference< css::uno::XComponentContext > &_rxContext, ::osl::Mutex &_rMutex, ::cppu::OBroadcastHelper &_rBHelper)
bool getEncoding(OUString &_out_rEncoding) const
void enterMethod()
prepares implementation of a public accessible method of a log handler
const css::uno::Reference< css::logging::XLogFormatter > & getFormatter() const
::cppu::OBroadcastHelper & m_rBHelper
css::uno::Reference< css::uno::XComponentContext > m_xContext
bool setEncoding(std::u16string_view _rEncoding)
void initFromSettings(const ::comphelper::NamedValueCollection &_rSettings)
initializes the instance from a collection of named settings
sal_Int32 getLevel() const
void setFormatter(const css::uno::Reference< css::logging::XLogFormatter > &_rxFormatter)
bool formatForPublishing(const css::logging::LogRecord &_rRecord, OString &_out_rEntry) const
formats a record for publishing it
rtl_TextEncoding getTextEncoding() const
css::uno::Reference< css::logging::XLogFormatter > m_xFormatter
bool getEncodedTail(OString &_out_rTail) const
retrieves our formatter's tail, encoded with our encoding
bool getEncodedHead(OString &_out_rHead) const
retrieves our formatter's heading, encoded with our encoding
rtl_TextEncoding m_eEncoding
#define DBG_UNHANDLED_EXCEPTION(...)
Reference< XComponentContext > m_xContext
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)