22#include <com/sun/star/logging/XLogFormatter.hpp>
23#include <com/sun/star/logging/LogLevel.hpp>
24#include <com/sun/star/uno/XComponentContext.hpp>
25#include <com/sun/star/lang/XServiceInfo.hpp>
32using css::logging::LogRecord;
33using namespace css::uno;
37class SimpleTextFormatter
38 :
public cppu::WeakImplHelper<css::logging::XLogFormatter, css::lang::XServiceInfo>
41 SimpleTextFormatter();
45 virtual OUString SAL_CALL getHead()
override;
46 virtual OUString SAL_CALL format(
const LogRecord& Record)
override;
47 virtual OUString SAL_CALL getTail()
override;
56SimpleTextFormatter::SimpleTextFormatter() {}
58OUString SAL_CALL SimpleTextFormatter::getHead() {
return OUString(); }
60OUString SAL_CALL SimpleTextFormatter::format(
const LogRecord& _rRecord)
64 if (_rRecord.Level == css::logging::LogLevel::SEVERE)
65 aLogEntry =
"ERROR: ";
66 else if (_rRecord.Level == css::logging::LogLevel::WARNING)
67 aLogEntry =
"WARNING: ";
69 return aLogEntry + _rRecord.Message +
"\n";
72OUString SAL_CALL SimpleTextFormatter::getTail() {
return OUString(); }
74sal_Bool SAL_CALL SimpleTextFormatter::supportsService(
const OUString& _rServiceName)
79OUString SAL_CALL SimpleTextFormatter::getImplementationName()
81 return "com.sun.star.comp.extensions.SimpleTextFormatter";
84Sequence<OUString> SAL_CALL SimpleTextFormatter::getSupportedServiceNames()
86 return {
"com.sun.star.logging.SimpleTextFormatter" };
91extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
93 css::uno::Sequence<css::uno::Any>
const&)
95 return cppu::acquire(
new logging::SimpleTextFormatter());
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_extensions_SimpleTextFormatter(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)