1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski // MARKER(update_precomp.py): autogen include statement, do not remove 25*b1cdbd2cSJim Jagielski #include "precompiled_extensions.hxx" 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski #include "log_module.hxx" 28*b1cdbd2cSJim Jagielski #include "logrecord.hxx" 29*b1cdbd2cSJim Jagielski #include "loggerconfig.hxx" 30*b1cdbd2cSJim Jagielski 31*b1cdbd2cSJim Jagielski /** === begin UNO includes === **/ 32*b1cdbd2cSJim Jagielski #include <com/sun/star/logging/XLogger.hpp> 33*b1cdbd2cSJim Jagielski #include <com/sun/star/logging/LogLevel.hpp> 34*b1cdbd2cSJim Jagielski #include <com/sun/star/uno/XComponentContext.hpp> 35*b1cdbd2cSJim Jagielski #include <com/sun/star/lang/XServiceInfo.hpp> 36*b1cdbd2cSJim Jagielski #include <com/sun/star/logging/XLoggerPool.hpp> 37*b1cdbd2cSJim Jagielski /** === end UNO includes === **/ 38*b1cdbd2cSJim Jagielski 39*b1cdbd2cSJim Jagielski #include <tools/diagnose_ex.h> 40*b1cdbd2cSJim Jagielski 41*b1cdbd2cSJim Jagielski #include <comphelper/componentcontext.hxx> 42*b1cdbd2cSJim Jagielski 43*b1cdbd2cSJim Jagielski #include <cppuhelper/basemutex.hxx> 44*b1cdbd2cSJim Jagielski #include <cppuhelper/interfacecontainer.hxx> 45*b1cdbd2cSJim Jagielski #include <cppuhelper/implbase2.hxx> 46*b1cdbd2cSJim Jagielski #include <cppuhelper/weakref.hxx> 47*b1cdbd2cSJim Jagielski 48*b1cdbd2cSJim Jagielski #include <boost/bind.hpp> 49*b1cdbd2cSJim Jagielski 50*b1cdbd2cSJim Jagielski #include <map> 51*b1cdbd2cSJim Jagielski 52*b1cdbd2cSJim Jagielski //........................................................................ 53*b1cdbd2cSJim Jagielski namespace logging 54*b1cdbd2cSJim Jagielski { 55*b1cdbd2cSJim Jagielski //........................................................................ 56*b1cdbd2cSJim Jagielski 57*b1cdbd2cSJim Jagielski /** === begin UNO using === **/ 58*b1cdbd2cSJim Jagielski using ::com::sun::star::logging::XLogger; 59*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::Reference; 60*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::XComponentContext; 61*b1cdbd2cSJim Jagielski using ::com::sun::star::lang::XServiceInfo; 62*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::RuntimeException; 63*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::Sequence; 64*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::XInterface; 65*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::UNO_QUERY_THROW; 66*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::Any; 67*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::Exception; 68*b1cdbd2cSJim Jagielski using ::com::sun::star::uno::WeakReference; 69*b1cdbd2cSJim Jagielski using ::com::sun::star::logging::XLogHandler; 70*b1cdbd2cSJim Jagielski using ::com::sun::star::logging::XLoggerPool; 71*b1cdbd2cSJim Jagielski using ::com::sun::star::logging::LogRecord; 72*b1cdbd2cSJim Jagielski /** === end UNO using === **/ 73*b1cdbd2cSJim Jagielski namespace LogLevel = ::com::sun::star::logging::LogLevel; 74*b1cdbd2cSJim Jagielski 75*b1cdbd2cSJim Jagielski //==================================================================== 76*b1cdbd2cSJim Jagielski //= helper 77*b1cdbd2cSJim Jagielski //==================================================================== 78*b1cdbd2cSJim Jagielski namespace 79*b1cdbd2cSJim Jagielski { lcl_supportsService_nothrow(XServiceInfo & _rSI,const::rtl::OUString & _rServiceName)80*b1cdbd2cSJim Jagielski sal_Bool lcl_supportsService_nothrow( XServiceInfo& _rSI, const ::rtl::OUString& _rServiceName ) 81*b1cdbd2cSJim Jagielski { 82*b1cdbd2cSJim Jagielski const Sequence< ::rtl::OUString > aServiceNames( _rSI.getSupportedServiceNames() ); 83*b1cdbd2cSJim Jagielski for ( const ::rtl::OUString* pServiceNames = aServiceNames.getConstArray(); 84*b1cdbd2cSJim Jagielski pServiceNames != aServiceNames.getConstArray() + aServiceNames.getLength(); 85*b1cdbd2cSJim Jagielski ++pServiceNames 86*b1cdbd2cSJim Jagielski ) 87*b1cdbd2cSJim Jagielski if ( _rServiceName == *pServiceNames ) 88*b1cdbd2cSJim Jagielski return sal_True; 89*b1cdbd2cSJim Jagielski return sal_False; 90*b1cdbd2cSJim Jagielski } 91*b1cdbd2cSJim Jagielski } 92*b1cdbd2cSJim Jagielski 93*b1cdbd2cSJim Jagielski //==================================================================== 94*b1cdbd2cSJim Jagielski //= EventLogger - declaration 95*b1cdbd2cSJim Jagielski //==================================================================== 96*b1cdbd2cSJim Jagielski typedef ::cppu::WeakImplHelper2 < XLogger 97*b1cdbd2cSJim Jagielski , XServiceInfo 98*b1cdbd2cSJim Jagielski > EventLogger_Base; 99*b1cdbd2cSJim Jagielski class EventLogger :public ::cppu::BaseMutex 100*b1cdbd2cSJim Jagielski ,public EventLogger_Base 101*b1cdbd2cSJim Jagielski { 102*b1cdbd2cSJim Jagielski private: 103*b1cdbd2cSJim Jagielski ::comphelper::ComponentContext m_aContext; 104*b1cdbd2cSJim Jagielski ::cppu::OInterfaceContainerHelper m_aHandlers; 105*b1cdbd2cSJim Jagielski oslInterlockedCount m_nEventNumber; 106*b1cdbd2cSJim Jagielski 107*b1cdbd2cSJim Jagielski // <attributes> 108*b1cdbd2cSJim Jagielski sal_Int32 m_nLogLevel; 109*b1cdbd2cSJim Jagielski ::rtl::OUString m_sName; 110*b1cdbd2cSJim Jagielski // </attributes> 111*b1cdbd2cSJim Jagielski 112*b1cdbd2cSJim Jagielski public: 113*b1cdbd2cSJim Jagielski EventLogger( const Reference< XComponentContext >& _rxContext, const ::rtl::OUString& _rName ); 114*b1cdbd2cSJim Jagielski 115*b1cdbd2cSJim Jagielski // XServiceInfo 116*b1cdbd2cSJim Jagielski virtual ::rtl::OUString SAL_CALL getImplementationName() throw(RuntimeException); 117*b1cdbd2cSJim Jagielski virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException); 118*b1cdbd2cSJim Jagielski virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException); 119*b1cdbd2cSJim Jagielski 120*b1cdbd2cSJim Jagielski // XLogger 121*b1cdbd2cSJim Jagielski virtual ::rtl::OUString SAL_CALL getName() throw (RuntimeException); 122*b1cdbd2cSJim Jagielski virtual ::sal_Int32 SAL_CALL getLevel() throw (RuntimeException); 123*b1cdbd2cSJim Jagielski virtual void SAL_CALL setLevel( ::sal_Int32 _level ) throw (RuntimeException); 124*b1cdbd2cSJim Jagielski virtual void SAL_CALL addLogHandler( const Reference< XLogHandler >& LogHandler ) throw (RuntimeException); 125*b1cdbd2cSJim Jagielski virtual void SAL_CALL removeLogHandler( const Reference< XLogHandler >& LogHandler ) throw (RuntimeException); 126*b1cdbd2cSJim Jagielski virtual ::sal_Bool SAL_CALL isLoggable( ::sal_Int32 _nLevel ) throw (RuntimeException); 127*b1cdbd2cSJim Jagielski virtual void SAL_CALL log( ::sal_Int32 Level, const ::rtl::OUString& Message ) throw (RuntimeException); 128*b1cdbd2cSJim Jagielski virtual void SAL_CALL logp( ::sal_Int32 Level, const ::rtl::OUString& SourceClass, const ::rtl::OUString& SourceMethod, const ::rtl::OUString& Message ) throw (RuntimeException); 129*b1cdbd2cSJim Jagielski 130*b1cdbd2cSJim Jagielski protected: 131*b1cdbd2cSJim Jagielski ~EventLogger(); 132*b1cdbd2cSJim Jagielski 133*b1cdbd2cSJim Jagielski private: 134*b1cdbd2cSJim Jagielski /** logs the given log record 135*b1cdbd2cSJim Jagielski */ 136*b1cdbd2cSJim Jagielski void impl_ts_logEvent_nothrow( const LogRecord& _rRecord ); 137*b1cdbd2cSJim Jagielski 138*b1cdbd2cSJim Jagielski /** non-threadsafe impl-version of isLoggable 139*b1cdbd2cSJim Jagielski */ 140*b1cdbd2cSJim Jagielski bool impl_nts_isLoggable_nothrow( ::sal_Int32 _nLevel ); 141*b1cdbd2cSJim Jagielski }; 142*b1cdbd2cSJim Jagielski 143*b1cdbd2cSJim Jagielski //==================================================================== 144*b1cdbd2cSJim Jagielski //= LoggerPool - declaration 145*b1cdbd2cSJim Jagielski //==================================================================== 146*b1cdbd2cSJim Jagielski typedef ::cppu::WeakImplHelper2 < XLoggerPool 147*b1cdbd2cSJim Jagielski , XServiceInfo 148*b1cdbd2cSJim Jagielski > LoggerPool_Base; 149*b1cdbd2cSJim Jagielski /** administrates a pool of XLogger instances, where a logger is keyed by its name, 150*b1cdbd2cSJim Jagielski and subsequent requests for a logger with the same name return the same instance. 151*b1cdbd2cSJim Jagielski */ 152*b1cdbd2cSJim Jagielski class LoggerPool : public LoggerPool_Base 153*b1cdbd2cSJim Jagielski { 154*b1cdbd2cSJim Jagielski private: 155*b1cdbd2cSJim Jagielski typedef ::std::map< ::rtl::OUString, WeakReference< XLogger > > ImplPool; 156*b1cdbd2cSJim Jagielski 157*b1cdbd2cSJim Jagielski private: 158*b1cdbd2cSJim Jagielski ::osl::Mutex m_aMutex; 159*b1cdbd2cSJim Jagielski ::comphelper::ComponentContext m_aContext; 160*b1cdbd2cSJim Jagielski ImplPool m_aImpl; 161*b1cdbd2cSJim Jagielski 162*b1cdbd2cSJim Jagielski public: 163*b1cdbd2cSJim Jagielski LoggerPool( const Reference< XComponentContext >& _rxContext ); 164*b1cdbd2cSJim Jagielski 165*b1cdbd2cSJim Jagielski // XServiceInfo 166*b1cdbd2cSJim Jagielski virtual ::rtl::OUString SAL_CALL getImplementationName() throw(RuntimeException); 167*b1cdbd2cSJim Jagielski virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException); 168*b1cdbd2cSJim Jagielski virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException); 169*b1cdbd2cSJim Jagielski 170*b1cdbd2cSJim Jagielski // helper for factories 171*b1cdbd2cSJim Jagielski static Sequence< ::rtl::OUString > getSupportedServiceNames_static(); 172*b1cdbd2cSJim Jagielski static ::rtl::OUString getImplementationName_static(); 173*b1cdbd2cSJim Jagielski static ::rtl::OUString getSingletonName_static(); 174*b1cdbd2cSJim Jagielski static Reference< XInterface > Create( const Reference< XComponentContext >& _rxContext ); 175*b1cdbd2cSJim Jagielski 176*b1cdbd2cSJim Jagielski // XLoggerPool 177*b1cdbd2cSJim Jagielski virtual Reference< XLogger > SAL_CALL getNamedLogger( const ::rtl::OUString& Name ) throw (RuntimeException); 178*b1cdbd2cSJim Jagielski virtual Reference< XLogger > SAL_CALL getDefaultLogger( ) throw (RuntimeException); 179*b1cdbd2cSJim Jagielski }; 180*b1cdbd2cSJim Jagielski 181*b1cdbd2cSJim Jagielski //==================================================================== 182*b1cdbd2cSJim Jagielski //= EventLogger - implementation 183*b1cdbd2cSJim Jagielski //==================================================================== 184*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- EventLogger(const Reference<XComponentContext> & _rxContext,const::rtl::OUString & _rName)185*b1cdbd2cSJim Jagielski EventLogger::EventLogger( const Reference< XComponentContext >& _rxContext, const ::rtl::OUString& _rName ) 186*b1cdbd2cSJim Jagielski :m_aContext( _rxContext ) 187*b1cdbd2cSJim Jagielski ,m_aHandlers( m_aMutex ) 188*b1cdbd2cSJim Jagielski ,m_nEventNumber( 0 ) 189*b1cdbd2cSJim Jagielski ,m_nLogLevel( LogLevel::OFF ) 190*b1cdbd2cSJim Jagielski ,m_sName( _rName ) 191*b1cdbd2cSJim Jagielski { 192*b1cdbd2cSJim Jagielski osl_incrementInterlockedCount( &m_refCount ); 193*b1cdbd2cSJim Jagielski { 194*b1cdbd2cSJim Jagielski initializeLoggerFromConfiguration( m_aContext, this ); 195*b1cdbd2cSJim Jagielski } 196*b1cdbd2cSJim Jagielski osl_decrementInterlockedCount( &m_refCount ); 197*b1cdbd2cSJim Jagielski } 198*b1cdbd2cSJim Jagielski 199*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- ~EventLogger()200*b1cdbd2cSJim Jagielski EventLogger::~EventLogger() 201*b1cdbd2cSJim Jagielski { 202*b1cdbd2cSJim Jagielski } 203*b1cdbd2cSJim Jagielski 204*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- impl_nts_isLoggable_nothrow(::sal_Int32 _nLevel)205*b1cdbd2cSJim Jagielski bool EventLogger::impl_nts_isLoggable_nothrow( ::sal_Int32 _nLevel ) 206*b1cdbd2cSJim Jagielski { 207*b1cdbd2cSJim Jagielski if ( _nLevel < m_nLogLevel ) 208*b1cdbd2cSJim Jagielski return false; 209*b1cdbd2cSJim Jagielski 210*b1cdbd2cSJim Jagielski if ( !m_aHandlers.getLength() ) 211*b1cdbd2cSJim Jagielski return false; 212*b1cdbd2cSJim Jagielski 213*b1cdbd2cSJim Jagielski return true; 214*b1cdbd2cSJim Jagielski } 215*b1cdbd2cSJim Jagielski 216*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- impl_ts_logEvent_nothrow(const LogRecord & _rRecord)217*b1cdbd2cSJim Jagielski void EventLogger::impl_ts_logEvent_nothrow( const LogRecord& _rRecord ) 218*b1cdbd2cSJim Jagielski { 219*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex ); 220*b1cdbd2cSJim Jagielski 221*b1cdbd2cSJim Jagielski if ( !impl_nts_isLoggable_nothrow( _rRecord.Level ) ) 222*b1cdbd2cSJim Jagielski return; 223*b1cdbd2cSJim Jagielski 224*b1cdbd2cSJim Jagielski m_aHandlers.forEach< XLogHandler >( 225*b1cdbd2cSJim Jagielski ::boost::bind( &XLogHandler::publish, _1, ::boost::cref( _rRecord ) ) ); 226*b1cdbd2cSJim Jagielski m_aHandlers.forEach< XLogHandler >( 227*b1cdbd2cSJim Jagielski ::boost::bind( &XLogHandler::flush, _1 ) ); 228*b1cdbd2cSJim Jagielski } 229*b1cdbd2cSJim Jagielski 230*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- getName()231*b1cdbd2cSJim Jagielski ::rtl::OUString SAL_CALL EventLogger::getName() throw (RuntimeException) 232*b1cdbd2cSJim Jagielski { 233*b1cdbd2cSJim Jagielski return m_sName; 234*b1cdbd2cSJim Jagielski } 235*b1cdbd2cSJim Jagielski 236*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- getLevel()237*b1cdbd2cSJim Jagielski ::sal_Int32 SAL_CALL EventLogger::getLevel() throw (RuntimeException) 238*b1cdbd2cSJim Jagielski { 239*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex ); 240*b1cdbd2cSJim Jagielski return m_nLogLevel; 241*b1cdbd2cSJim Jagielski } 242*b1cdbd2cSJim Jagielski 243*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- setLevel(::sal_Int32 _level)244*b1cdbd2cSJim Jagielski void SAL_CALL EventLogger::setLevel( ::sal_Int32 _level ) throw (RuntimeException) 245*b1cdbd2cSJim Jagielski { 246*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex ); 247*b1cdbd2cSJim Jagielski m_nLogLevel = _level; 248*b1cdbd2cSJim Jagielski } 249*b1cdbd2cSJim Jagielski 250*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- addLogHandler(const Reference<XLogHandler> & _rxLogHandler)251*b1cdbd2cSJim Jagielski void SAL_CALL EventLogger::addLogHandler( const Reference< XLogHandler >& _rxLogHandler ) throw (RuntimeException) 252*b1cdbd2cSJim Jagielski { 253*b1cdbd2cSJim Jagielski if ( _rxLogHandler.is() ) 254*b1cdbd2cSJim Jagielski m_aHandlers.addInterface( _rxLogHandler ); 255*b1cdbd2cSJim Jagielski } 256*b1cdbd2cSJim Jagielski 257*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- removeLogHandler(const Reference<XLogHandler> & _rxLogHandler)258*b1cdbd2cSJim Jagielski void SAL_CALL EventLogger::removeLogHandler( const Reference< XLogHandler >& _rxLogHandler ) throw (RuntimeException) 259*b1cdbd2cSJim Jagielski { 260*b1cdbd2cSJim Jagielski if ( _rxLogHandler.is() ) 261*b1cdbd2cSJim Jagielski m_aHandlers.removeInterface( _rxLogHandler ); 262*b1cdbd2cSJim Jagielski } 263*b1cdbd2cSJim Jagielski 264*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- isLoggable(::sal_Int32 _nLevel)265*b1cdbd2cSJim Jagielski ::sal_Bool SAL_CALL EventLogger::isLoggable( ::sal_Int32 _nLevel ) throw (RuntimeException) 266*b1cdbd2cSJim Jagielski { 267*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex ); 268*b1cdbd2cSJim Jagielski return impl_nts_isLoggable_nothrow( _nLevel ); 269*b1cdbd2cSJim Jagielski } 270*b1cdbd2cSJim Jagielski 271*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- log(::sal_Int32 _nLevel,const::rtl::OUString & _rMessage)272*b1cdbd2cSJim Jagielski void SAL_CALL EventLogger::log( ::sal_Int32 _nLevel, const ::rtl::OUString& _rMessage ) throw (RuntimeException) 273*b1cdbd2cSJim Jagielski { 274*b1cdbd2cSJim Jagielski impl_ts_logEvent_nothrow( createLogRecord( 275*b1cdbd2cSJim Jagielski m_sName, 276*b1cdbd2cSJim Jagielski _rMessage, 277*b1cdbd2cSJim Jagielski _nLevel, 278*b1cdbd2cSJim Jagielski osl_incrementInterlockedCount( &m_nEventNumber ) 279*b1cdbd2cSJim Jagielski ) ); 280*b1cdbd2cSJim Jagielski } 281*b1cdbd2cSJim Jagielski 282*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- logp(::sal_Int32 _nLevel,const::rtl::OUString & _rSourceClass,const::rtl::OUString & _rSourceMethod,const::rtl::OUString & _rMessage)283*b1cdbd2cSJim Jagielski void SAL_CALL EventLogger::logp( ::sal_Int32 _nLevel, const ::rtl::OUString& _rSourceClass, const ::rtl::OUString& _rSourceMethod, const ::rtl::OUString& _rMessage ) throw (RuntimeException) 284*b1cdbd2cSJim Jagielski { 285*b1cdbd2cSJim Jagielski impl_ts_logEvent_nothrow( createLogRecord( 286*b1cdbd2cSJim Jagielski m_sName, 287*b1cdbd2cSJim Jagielski _rSourceClass, 288*b1cdbd2cSJim Jagielski _rSourceMethod, 289*b1cdbd2cSJim Jagielski _rMessage, 290*b1cdbd2cSJim Jagielski _nLevel, 291*b1cdbd2cSJim Jagielski osl_incrementInterlockedCount( &m_nEventNumber ) 292*b1cdbd2cSJim Jagielski ) ); 293*b1cdbd2cSJim Jagielski } 294*b1cdbd2cSJim Jagielski 295*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- getImplementationName()296*b1cdbd2cSJim Jagielski ::rtl::OUString SAL_CALL EventLogger::getImplementationName() throw(RuntimeException) 297*b1cdbd2cSJim Jagielski { 298*b1cdbd2cSJim Jagielski return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.EventLogger" ) ); 299*b1cdbd2cSJim Jagielski } 300*b1cdbd2cSJim Jagielski 301*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- supportsService(const::rtl::OUString & _rServiceName)302*b1cdbd2cSJim Jagielski ::sal_Bool EventLogger::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException) 303*b1cdbd2cSJim Jagielski { 304*b1cdbd2cSJim Jagielski return lcl_supportsService_nothrow( *this, _rServiceName ); 305*b1cdbd2cSJim Jagielski } 306*b1cdbd2cSJim Jagielski 307*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- getSupportedServiceNames()308*b1cdbd2cSJim Jagielski Sequence< ::rtl::OUString > SAL_CALL EventLogger::getSupportedServiceNames() throw(RuntimeException) 309*b1cdbd2cSJim Jagielski { 310*b1cdbd2cSJim Jagielski Sequence< ::rtl::OUString > aServiceNames(1); 311*b1cdbd2cSJim Jagielski aServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.logging.Logger" ) ); 312*b1cdbd2cSJim Jagielski return aServiceNames; 313*b1cdbd2cSJim Jagielski } 314*b1cdbd2cSJim Jagielski 315*b1cdbd2cSJim Jagielski //==================================================================== 316*b1cdbd2cSJim Jagielski //= LoggerPool - implementation 317*b1cdbd2cSJim Jagielski //==================================================================== 318*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- LoggerPool(const Reference<XComponentContext> & _rxContext)319*b1cdbd2cSJim Jagielski LoggerPool::LoggerPool( const Reference< XComponentContext >& _rxContext ) 320*b1cdbd2cSJim Jagielski :m_aContext( _rxContext ) 321*b1cdbd2cSJim Jagielski { 322*b1cdbd2cSJim Jagielski } 323*b1cdbd2cSJim Jagielski 324*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- getImplementationName()325*b1cdbd2cSJim Jagielski ::rtl::OUString SAL_CALL LoggerPool::getImplementationName() throw(RuntimeException) 326*b1cdbd2cSJim Jagielski { 327*b1cdbd2cSJim Jagielski return getImplementationName_static(); 328*b1cdbd2cSJim Jagielski } 329*b1cdbd2cSJim Jagielski 330*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- supportsService(const::rtl::OUString & _rServiceName)331*b1cdbd2cSJim Jagielski ::sal_Bool SAL_CALL LoggerPool::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException) 332*b1cdbd2cSJim Jagielski { 333*b1cdbd2cSJim Jagielski return lcl_supportsService_nothrow( *this, _rServiceName ); 334*b1cdbd2cSJim Jagielski } 335*b1cdbd2cSJim Jagielski 336*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- getSupportedServiceNames()337*b1cdbd2cSJim Jagielski Sequence< ::rtl::OUString > SAL_CALL LoggerPool::getSupportedServiceNames() throw(RuntimeException) 338*b1cdbd2cSJim Jagielski { 339*b1cdbd2cSJim Jagielski return getSupportedServiceNames_static(); 340*b1cdbd2cSJim Jagielski } 341*b1cdbd2cSJim Jagielski 342*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- getImplementationName_static()343*b1cdbd2cSJim Jagielski ::rtl::OUString SAL_CALL LoggerPool::getImplementationName_static() 344*b1cdbd2cSJim Jagielski { 345*b1cdbd2cSJim Jagielski return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.LoggerPool" ) ); 346*b1cdbd2cSJim Jagielski } 347*b1cdbd2cSJim Jagielski 348*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- getSupportedServiceNames_static()349*b1cdbd2cSJim Jagielski Sequence< ::rtl::OUString > SAL_CALL LoggerPool::getSupportedServiceNames_static() 350*b1cdbd2cSJim Jagielski { 351*b1cdbd2cSJim Jagielski Sequence< ::rtl::OUString > aServiceNames(1); 352*b1cdbd2cSJim Jagielski aServiceNames[0] = getSingletonName_static(); 353*b1cdbd2cSJim Jagielski return aServiceNames; 354*b1cdbd2cSJim Jagielski } 355*b1cdbd2cSJim Jagielski 356*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- getSingletonName_static()357*b1cdbd2cSJim Jagielski ::rtl::OUString LoggerPool::getSingletonName_static() 358*b1cdbd2cSJim Jagielski { 359*b1cdbd2cSJim Jagielski return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.logging.LoggerPool" ) ); 360*b1cdbd2cSJim Jagielski } 361*b1cdbd2cSJim Jagielski 362*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- Create(const Reference<XComponentContext> & _rxContext)363*b1cdbd2cSJim Jagielski Reference< XInterface > SAL_CALL LoggerPool::Create( const Reference< XComponentContext >& _rxContext ) 364*b1cdbd2cSJim Jagielski { 365*b1cdbd2cSJim Jagielski return *( new LoggerPool( _rxContext ) ); 366*b1cdbd2cSJim Jagielski } 367*b1cdbd2cSJim Jagielski 368*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- getNamedLogger(const::rtl::OUString & _rName)369*b1cdbd2cSJim Jagielski Reference< XLogger > SAL_CALL LoggerPool::getNamedLogger( const ::rtl::OUString& _rName ) throw (RuntimeException) 370*b1cdbd2cSJim Jagielski { 371*b1cdbd2cSJim Jagielski ::osl::MutexGuard aGuard( m_aMutex ); 372*b1cdbd2cSJim Jagielski 373*b1cdbd2cSJim Jagielski WeakReference< XLogger >& rLogger( m_aImpl[ _rName ] ); 374*b1cdbd2cSJim Jagielski Reference< XLogger > xLogger( (Reference< XLogger >)rLogger ); 375*b1cdbd2cSJim Jagielski if ( !xLogger.is() ) 376*b1cdbd2cSJim Jagielski { 377*b1cdbd2cSJim Jagielski // never requested before, or already dead 378*b1cdbd2cSJim Jagielski xLogger = new EventLogger( m_aContext.getUNOContext(), _rName ); 379*b1cdbd2cSJim Jagielski rLogger = xLogger; 380*b1cdbd2cSJim Jagielski } 381*b1cdbd2cSJim Jagielski 382*b1cdbd2cSJim Jagielski return xLogger; 383*b1cdbd2cSJim Jagielski } 384*b1cdbd2cSJim Jagielski 385*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- getDefaultLogger()386*b1cdbd2cSJim Jagielski Reference< XLogger > SAL_CALL LoggerPool::getDefaultLogger( ) throw (RuntimeException) 387*b1cdbd2cSJim Jagielski { 388*b1cdbd2cSJim Jagielski return getNamedLogger( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.logging.DefaultLogger" ) ) ); 389*b1cdbd2cSJim Jagielski } 390*b1cdbd2cSJim Jagielski 391*b1cdbd2cSJim Jagielski //-------------------------------------------------------------------- createRegistryInfo_LoggerPool()392*b1cdbd2cSJim Jagielski void createRegistryInfo_LoggerPool() 393*b1cdbd2cSJim Jagielski { 394*b1cdbd2cSJim Jagielski static OSingletonRegistration< LoggerPool > aAutoRegistration; 395*b1cdbd2cSJim Jagielski } 396*b1cdbd2cSJim Jagielski 397*b1cdbd2cSJim Jagielski //........................................................................ 398*b1cdbd2cSJim Jagielski } // namespace logging 399*b1cdbd2cSJim Jagielski //........................................................................ 400*b1cdbd2cSJim Jagielski 401