25#include <com/sun/star/logging/XConsoleHandler.hpp>
26#include <com/sun/star/lang/XServiceInfo.hpp>
27#include <com/sun/star/logging/LogLevel.hpp>
28#include <com/sun/star/lang/IllegalArgumentException.hpp>
29#include <com/sun/star/beans/NamedValue.hpp>
39 using ::com::sun::star::logging::XConsoleHandler;
40 using ::com::sun::star::lang::XServiceInfo;
41 using ::com::sun::star::uno::Reference;
42 using ::com::sun::star::uno::XComponentContext;
43 using ::com::sun::star::logging::XLogFormatter;
44 using ::com::sun::star::uno::Sequence;
45 using ::com::sun::star::logging::LogRecord;
46 using ::com::sun::star::uno::XInterface;
47 using ::com::sun::star::lang::IllegalArgumentException;
48 using ::com::sun::star::beans::NamedValue;
50 typedef ::cppu::WeakComponentImplHelper < XConsoleHandler
64 ConsoleHandler(
const Reference<XComponentContext> &context,
65 const css::uno::Sequence<css::uno::Any> &arguments);
66 virtual ~ConsoleHandler()
override;
70 virtual ::sal_Int32 SAL_CALL getThreshold()
override;
71 virtual void SAL_CALL setThreshold( ::sal_Int32 _threshold )
override;
74 virtual OUString SAL_CALL getEncoding()
override;
75 virtual void SAL_CALL setEncoding(
const OUString& _encoding )
override;
76 virtual Reference< XLogFormatter > SAL_CALL getFormatter()
override;
77 virtual void SAL_CALL setFormatter(
const Reference< XLogFormatter >& _formatter )
override;
78 virtual ::sal_Int32 SAL_CALL getLevel()
override;
79 virtual void SAL_CALL setLevel( ::sal_Int32 _level )
override;
80 virtual void SAL_CALL flush( )
override;
81 virtual sal_Bool SAL_CALL publish(
const LogRecord& Record )
override;
89 virtual void SAL_CALL disposing()
override;
92 typedef ComponentMethodGuard< ConsoleHandler > MethodGuard;
93 void enterMethod( MethodGuard::Access );
94 void leaveMethod( MethodGuard::Access );
99 ConsoleHandler::ConsoleHandler(
const Reference<XComponentContext> &context,
100 const css::uno::Sequence<css::uno::Any> &arguments)
105 ::osl::MutexGuard aGuard(
m_aMutex );
107 if ( !arguments.hasElements() )
113 if ( arguments.getLength() != 1 )
114 throw IllegalArgumentException( OUString(), *
this, 1 );
116 Sequence< NamedValue > aSettings;
117 if ( !( arguments[0] >>= aSettings ) )
118 throw IllegalArgumentException( OUString(), *
this, 1 );
124 aTypedSettings.get_ensureType(
"Threshold",
m_nThreshold );
129 ConsoleHandler::~ConsoleHandler()
131 if ( !rBHelper.bDisposed )
139 void SAL_CALL ConsoleHandler::disposing()
145 void ConsoleHandler::enterMethod( MethodGuard::Access )
151 void ConsoleHandler::leaveMethod( MethodGuard::Access )
157 ::sal_Int32 SAL_CALL ConsoleHandler::getThreshold()
159 MethodGuard aGuard( *
this );
164 void SAL_CALL ConsoleHandler::setThreshold( ::sal_Int32 _threshold )
166 MethodGuard aGuard( *
this );
171 OUString SAL_CALL ConsoleHandler::getEncoding()
173 MethodGuard aGuard( *
this );
180 void SAL_CALL ConsoleHandler::setEncoding(
const OUString& _rEncoding )
182 MethodGuard aGuard( *
this );
187 Reference< XLogFormatter > SAL_CALL ConsoleHandler::getFormatter()
189 MethodGuard aGuard( *
this );
194 void SAL_CALL ConsoleHandler::setFormatter(
const Reference< XLogFormatter >& _rxFormatter )
196 MethodGuard aGuard( *
this );
201 ::sal_Int32 SAL_CALL ConsoleHandler::getLevel()
203 MethodGuard aGuard( *
this );
208 void SAL_CALL ConsoleHandler::setLevel( ::sal_Int32 _nLevel )
210 MethodGuard aGuard( *
this );
215 void SAL_CALL ConsoleHandler::flush( )
217 MethodGuard aGuard( *
this );
223 sal_Bool SAL_CALL ConsoleHandler::publish(
const LogRecord& _rRecord )
225 MethodGuard aGuard( *
this );
232 fprintf( stderr,
"%s\n", sEntry.getStr() );
234 fprintf( stdout,
"%s\n", sEntry.getStr() );
239 OUString SAL_CALL ConsoleHandler::getImplementationName()
241 return "com.sun.star.comp.extensions.ConsoleHandler";
244 sal_Bool SAL_CALL ConsoleHandler::supportsService(
const OUString& _rServiceName )
249 Sequence< OUString > SAL_CALL ConsoleHandler::getSupportedServiceNames()
251 return {
"com.sun.star.logging.ConsoleHandler" };
256extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
258 css::uno::XComponentContext *context,
259 css::uno::Sequence<css::uno::Any>
const &arguments)
261 return cppu::acquire(
new logging::ConsoleHandler(context, arguments));
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_extensions_ConsoleHandler(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &arguments)
LogHandlerHelper m_aHandlerHelper
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
::cppu::WeakComponentImplHelper< XConsoleHandler, XServiceInfo > ConsoleHandler_Base