1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef COMPHELPER_LOGGING_HXX 25 #define COMPHELPER_LOGGING_HXX 26 27 #include <comphelper/comphelperdllapi.h> 28 29 /** === begin UNO includes === **/ 30 #include <com/sun/star/uno/XComponentContext.hpp> 31 #include <com/sun/star/logging/XLogHandler.hpp> 32 #include <com/sun/star/logging/LogLevel.hpp> 33 /** === end UNO includes === **/ 34 35 #include <boost/shared_ptr.hpp> 36 #include <boost/optional.hpp> 37 38 //........................................................................ 39 namespace comphelper 40 { 41 //........................................................................ 42 43 //==================================================================== 44 //= string conversions, employed by the templatized log* members of 45 //= EventLogger 46 //==================================================================== 47 48 namespace log { namespace convert 49 { convertLogArgToString(const::rtl::OUString & _rValue)50 inline const ::rtl::OUString& convertLogArgToString( const ::rtl::OUString& _rValue ) 51 { 52 return _rValue; 53 } 54 convertLogArgToString(const sal_Char * _pAsciiValue)55 inline ::rtl::OUString convertLogArgToString( const sal_Char* _pAsciiValue ) 56 { 57 return ::rtl::OUString::createFromAscii( _pAsciiValue ); 58 } 59 convertLogArgToString(double _nValue)60 inline ::rtl::OUString convertLogArgToString( double _nValue ) { return ::rtl::OUString::valueOf( _nValue ); } convertLogArgToString(float _nValue)61 inline ::rtl::OUString convertLogArgToString( float _nValue ) { return ::rtl::OUString::valueOf( _nValue ); } convertLogArgToString(sal_Int64 _nValue)62 inline ::rtl::OUString convertLogArgToString( sal_Int64 _nValue ) { return ::rtl::OUString::valueOf( _nValue ); } convertLogArgToString(sal_Int32 _nValue)63 inline ::rtl::OUString convertLogArgToString( sal_Int32 _nValue ) { return ::rtl::OUString::valueOf( _nValue ); } convertLogArgToString(sal_Int16 _nValue)64 inline ::rtl::OUString convertLogArgToString( sal_Int16 _nValue ) { return ::rtl::OUString::valueOf( (sal_Int32)_nValue ); } convertLogArgToString(sal_Unicode _nValue)65 inline ::rtl::OUString convertLogArgToString( sal_Unicode _nValue ) { return ::rtl::OUString::valueOf( _nValue ); } convertLogArgToString(sal_Bool _nValue)66 inline ::rtl::OUString convertLogArgToString( sal_Bool _nValue ) { return ::rtl::OUString::valueOf( _nValue ); } 67 68 } } // namespace log::convert 69 70 //==================================================================== 71 //= EventLogger 72 //==================================================================== 73 class EventLogger_Impl; 74 typedef ::boost::optional< ::rtl::OUString > OptionalString; 75 76 /** encapsulates an <type scope="com::sun::star::logging">XLogger</type> 77 78 The class silences several (unlikely) errors which could potentially happen 79 when working with a logger. Additionally, it provides some convenience methods 80 for logging events. 81 82 You can use this class as follows 83 <pre> 84 EventLogger aLogger( xContext, sLoggerName ); 85 .... 86 aLogger.log( LogLevel::SEVERE, sSomeMessage ); 87 aLogger.logp( LogLevel::CONFIG, "MyClass", "MyMethod", sSomeMessage, SomeParameter1, SomeParameter2, SomeParameter3 ); 88 </pre> 89 90 The <code>log</code> and <code>logp</code> calls support up to 6 parameters, which can be of 91 arbitrary type. For every parameter, there must exist a function <code>convertLogArgToString</code> 92 which takes an argument of the respective type, and returns a string. 93 94 After a parameter has been converted to a string using the above mentioned 95 <code>convertLogArgToString</code> function, a placeholder $1$ (resp. $2$ resp. $4$ ...) 96 in the message will be replaced with this string, and the resulting message will be logged. 97 */ 98 class COMPHELPER_DLLPUBLIC EventLogger 99 { 100 protected: 101 ::boost::shared_ptr< EventLogger_Impl > m_pImpl; 102 103 public: 104 /** creates an <code>EventLogger</code> instance working with a css.logging.XLogger 105 instance given by name. 106 107 @param _rxContext 108 the component context to create services 109 @param _rLoggerName 110 the name of the logger to create. If empty, the office-wide default logger will be used. 111 */ 112 EventLogger( 113 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext, 114 const ::rtl::OUString& _rLoggerName = ::rtl::OUString() 115 ); 116 117 /** creates an <code>EventLogger</code> instance working with a css.logging.XLogger 118 instance given by ASCII name. 119 120 @param _rxContext 121 the component context to create services 122 123 @param _rLoggerName 124 the ASCII name of the logger to create. 125 */ 126 EventLogger( 127 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext, 128 const sal_Char* _pAsciiLoggerName 129 ); 130 131 ~EventLogger(); 132 133 public: 134 /** returns the name of the logger 135 */ 136 const ::rtl::OUString& getName() const; 137 138 /// returns the current log level threshold of the logger 139 sal_Int32 getLogLevel() const; 140 141 /// sets a new log level threshold of the logger 142 void setLogLevel( const sal_Int32 _nLogLevel ) const; 143 144 /// determines whether an event with the given level would be logged 145 bool isLoggable( const sal_Int32 _nLogLevel ) const; 146 147 /** adds the given log handler to the logger's set of handlers. 148 149 Note that normally, you would not use this method: The logger implementations 150 initialize themselves from the configuration, where usually, a default log handler 151 is specified. In this case, the logger will create and use this handler. 152 153 @return 154 <TRUE/> if and only if the addition was successful (as far as this can be detected 155 from outside the <code>XLogger</code>'s implementation. 156 */ 157 bool addLogHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::logging::XLogHandler >& _rxLogHandler ); 158 159 /** removes the given log handler from the logger's set of handlers. 160 161 @return 162 <TRUE/> if and only if the addition was successful (as far as this can be detected 163 from outside the <code>XLogger</code>'s implementation. 164 */ 165 bool removeLogHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::logging::XLogHandler >& _rxLogHandler ); 166 167 //---------------------------------------------------------------- 168 //- XLogger::log equivalents/wrappers 169 //- string messages 170 171 /// logs a given message, without any arguments, or source class/method names log(const sal_Int32 _nLogLevel,const::rtl::OUString & _rMessage) const172 bool log( const sal_Int32 _nLogLevel, const ::rtl::OUString& _rMessage ) const 173 { 174 if ( isLoggable( _nLogLevel ) ) 175 return impl_log( _nLogLevel, NULL, NULL, _rMessage ); 176 return false; 177 } 178 179 /** logs a given message, replacing a placeholder in the message with an argument 180 181 The function takes, additionally to the log level and the message, an arbitrary 182 argument. This argument is converted to a string using an overloaded function 183 named <code>convertLogArgToString</code>. Then, a placeholder "$1$" 184 is searched in the message string, and replaced with the argument string. 185 */ 186 template< typename ARGTYPE1 > log(const sal_Int32 _nLogLevel,const::rtl::OUString & _rMessage,ARGTYPE1 _argument1) const187 bool log( const sal_Int32 _nLogLevel, const ::rtl::OUString& _rMessage, ARGTYPE1 _argument1 ) const 188 { 189 if ( isLoggable( _nLogLevel ) ) 190 return impl_log( _nLogLevel, NULL, NULL, _rMessage, 191 OptionalString( log::convert::convertLogArgToString( _argument1 ) ) ); 192 return false; 193 } 194 195 /// logs a given message, replacing 2 placeholders in the message with respective values 196 template< typename ARGTYPE1, typename ARGTYPE2 > log(const sal_Int32 _nLogLevel,const::rtl::OUString & _rMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2) const197 bool log( const sal_Int32 _nLogLevel, const ::rtl::OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2 ) const 198 { 199 if ( isLoggable( _nLogLevel ) ) 200 return impl_log( _nLogLevel, NULL, NULL, _rMessage, 201 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 202 OptionalString( log::convert::convertLogArgToString( _argument2 ) ) ); 203 return false; 204 } 205 206 /// logs a given message, replacing 3 placeholders in the message with respective values 207 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3 > log(const sal_Int32 _nLogLevel,const::rtl::OUString & _rMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3) const208 bool log( const sal_Int32 _nLogLevel, const ::rtl::OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3 ) const 209 { 210 if ( isLoggable( _nLogLevel ) ) 211 return impl_log( _nLogLevel, NULL, NULL, _rMessage, 212 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 213 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 214 OptionalString( log::convert::convertLogArgToString( _argument3 ) ) ); 215 return false; 216 } 217 218 /// logs a given message, replacing 4 placeholders in the message with respective values 219 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4 > log(const sal_Int32 _nLogLevel,const::rtl::OUString & _rMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4) const220 bool log( const sal_Int32 _nLogLevel, const ::rtl::OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4 ) const 221 { 222 if ( isLoggable( _nLogLevel ) ) 223 return impl_log( _nLogLevel, NULL, NULL, _rMessage, 224 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 225 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 226 OptionalString( log::convert::convertLogArgToString( _argument3 ) ), 227 OptionalString( log::convert::convertLogArgToString( _argument4 ) ) ); 228 return false; 229 } 230 231 /// logs a given message, replacing 5 placeholders in the message with respective values 232 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5 > log(const sal_Int32 _nLogLevel,const::rtl::OUString & _rMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4,ARGTYPE5 _argument5) const233 bool log( const sal_Int32 _nLogLevel, const ::rtl::OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5 ) const 234 { 235 if ( isLoggable( _nLogLevel ) ) 236 return impl_log( _nLogLevel, NULL, NULL, _rMessage, 237 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 238 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 239 OptionalString( log::convert::convertLogArgToString( _argument3 ) ), 240 OptionalString( log::convert::convertLogArgToString( _argument4 ) ), 241 OptionalString( log::convert::convertLogArgToString( _argument5 ) ) ); 242 return false; 243 } 244 245 /// logs a given message, replacing 6 placeholders in the message with respective values 246 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5, typename ARGTYPE6 > log(const sal_Int32 _nLogLevel,const::rtl::OUString & _rMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4,ARGTYPE5 _argument5,ARGTYPE6 _argument6) const247 bool log( const sal_Int32 _nLogLevel, const ::rtl::OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5, ARGTYPE6 _argument6 ) const 248 { 249 if ( isLoggable( _nLogLevel ) ) 250 return impl_log( _nLogLevel, NULL, NULL, _rMessage, 251 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 252 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 253 OptionalString( log::convert::convertLogArgToString( _argument3 ) ), 254 OptionalString( log::convert::convertLogArgToString( _argument4 ) ), 255 OptionalString( log::convert::convertLogArgToString( _argument5 ) ), 256 OptionalString( log::convert::convertLogArgToString( _argument6 ) ) ); 257 return false; 258 } 259 260 //---------------------------------------------------------------- 261 //- XLogger::log equivalents/wrappers 262 //- ASCII messages 263 264 /// logs a given message, without any arguments, or source class/method names log(const sal_Int32 _nLogLevel,const sal_Char * _pMessage) const265 bool log( const sal_Int32 _nLogLevel, const sal_Char* _pMessage ) const 266 { 267 if ( isLoggable( _nLogLevel ) ) 268 return impl_log( _nLogLevel, NULL, NULL, ::rtl::OUString::createFromAscii( _pMessage ) ); 269 return false; 270 } 271 272 /** logs a given message, replacing a placeholder in the message with an argument 273 274 The function takes, additionally to the log level and the message, an arbitrary 275 argument. This argument is converted to a string using an overloaded function 276 named <code>convertLogArgToString</code>. Then, a placeholder "$1$" 277 is searched in the message string, and replaced with the argument string. 278 */ 279 template< typename ARGTYPE1 > log(const sal_Int32 _nLogLevel,const sal_Char * _pMessage,ARGTYPE1 _argument1) const280 bool log( const sal_Int32 _nLogLevel, const sal_Char* _pMessage, ARGTYPE1 _argument1 ) const 281 { 282 if ( isLoggable( _nLogLevel ) ) 283 return impl_log( _nLogLevel, NULL, NULL, ::rtl::OUString::createFromAscii( _pMessage ), 284 OptionalString( log::convert::convertLogArgToString( _argument1 ) ) ); 285 return false; 286 } 287 288 /// logs a given message, replacing 2 placeholders in the message with respective values 289 template< typename ARGTYPE1, typename ARGTYPE2 > log(const sal_Int32 _nLogLevel,const sal_Char * _pMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2) const290 bool log( const sal_Int32 _nLogLevel, const sal_Char* _pMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2 ) const 291 { 292 if ( isLoggable( _nLogLevel ) ) 293 return impl_log( _nLogLevel, NULL, NULL, ::rtl::OUString::createFromAscii( _pMessage ), 294 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 295 OptionalString( log::convert::convertLogArgToString( _argument2 ) ) ); 296 return false; 297 } 298 299 /// logs a given message, replacing 3 placeholders in the message with respective values 300 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3 > log(const sal_Int32 _nLogLevel,const sal_Char * _pMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3) const301 bool log( const sal_Int32 _nLogLevel, const sal_Char* _pMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3 ) const 302 { 303 if ( isLoggable( _nLogLevel ) ) 304 return impl_log( _nLogLevel, NULL, NULL, ::rtl::OUString::createFromAscii( _pMessage ), 305 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 306 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 307 OptionalString( log::convert::convertLogArgToString( _argument3 ) ) ); 308 return false; 309 } 310 311 /// logs a given message, replacing 4 placeholders in the message with respective values 312 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4 > log(const sal_Int32 _nLogLevel,const sal_Char * _pMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4) const313 bool log( const sal_Int32 _nLogLevel, const sal_Char* _pMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4 ) const 314 { 315 if ( isLoggable( _nLogLevel ) ) 316 return impl_log( _nLogLevel, NULL, NULL, ::rtl::OUString::createFromAscii( _pMessage ), 317 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 318 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 319 OptionalString( log::convert::convertLogArgToString( _argument3 ) ), 320 OptionalString( log::convert::convertLogArgToString( _argument4 ) ) ); 321 return false; 322 } 323 324 /// logs a given message, replacing 5 placeholders in the message with respective values 325 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5 > log(const sal_Int32 _nLogLevel,const sal_Char * _pMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4,ARGTYPE5 _argument5) const326 bool log( const sal_Int32 _nLogLevel, const sal_Char* _pMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5 ) const 327 { 328 if ( isLoggable( _nLogLevel ) ) 329 return impl_log( _nLogLevel, NULL, NULL, ::rtl::OUString::createFromAscii( _pMessage ), 330 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 331 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 332 OptionalString( log::convert::convertLogArgToString( _argument3 ) ), 333 OptionalString( log::convert::convertLogArgToString( _argument4 ) ), 334 OptionalString( log::convert::convertLogArgToString( _argument5 ) ) ); 335 return false; 336 } 337 338 /// logs a given message, replacing 6 placeholders in the message with respective values 339 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5, typename ARGTYPE6 > log(const sal_Int32 _nLogLevel,const sal_Char * _pMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4,ARGTYPE5 _argument5,ARGTYPE6 _argument6) const340 bool log( const sal_Int32 _nLogLevel, const sal_Char* _pMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5, ARGTYPE6 _argument6 ) const 341 { 342 if ( isLoggable( _nLogLevel ) ) 343 return impl_log( _nLogLevel, NULL, NULL, ::rtl::OUString::createFromAscii( _pMessage ), 344 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 345 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 346 OptionalString( log::convert::convertLogArgToString( _argument3 ) ), 347 OptionalString( log::convert::convertLogArgToString( _argument4 ) ), 348 OptionalString( log::convert::convertLogArgToString( _argument5 ) ), 349 OptionalString( log::convert::convertLogArgToString( _argument6 ) ) ); 350 return false; 351 } 352 353 //---------------------------------------------------------------- 354 //- XLogger::logp equivalents/wrappers 355 //- string messages 356 357 /// logs a given message, without any arguments, or source class/method names logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const::rtl::OUString & _rMessage) const358 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const ::rtl::OUString& _rMessage ) const 359 { 360 if ( isLoggable( _nLogLevel ) ) 361 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, _rMessage ); 362 return false; 363 } 364 365 /** logs a given message, replacing a placeholder in the message with an argument 366 367 The function takes, additionally to the logp level and the message, an arbitrary 368 argument. This argument is converted to a string using an overloaded function 369 named <code>convertLogArgToString</code>. Then, a placeholder "$1$" 370 is searched in the message string, and replaced with the argument string. 371 */ 372 template< typename ARGTYPE1 > logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const::rtl::OUString & _rMessage,ARGTYPE1 _argument1) const373 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const ::rtl::OUString& _rMessage, ARGTYPE1 _argument1 ) const 374 { 375 if ( isLoggable( _nLogLevel ) ) 376 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, _rMessage, 377 OptionalString( log::convert::convertLogArgToString( _argument1 ) ) ); 378 return false; 379 } 380 381 /// logs a given message, replacing 2 placeholders in the message with respective values 382 template< typename ARGTYPE1, typename ARGTYPE2 > logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const::rtl::OUString & _rMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2) const383 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const ::rtl::OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2 ) const 384 { 385 if ( isLoggable( _nLogLevel ) ) 386 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, _rMessage, 387 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 388 OptionalString( log::convert::convertLogArgToString( _argument2 ) ) ); 389 return false; 390 } 391 392 /// logs a given message, replacing 3 placeholders in the message with respective values 393 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3 > logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const::rtl::OUString & _rMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3) const394 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const ::rtl::OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3 ) const 395 { 396 if ( isLoggable( _nLogLevel ) ) 397 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, _rMessage, 398 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 399 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 400 OptionalString( log::convert::convertLogArgToString( _argument3 ) ) ); 401 return false; 402 } 403 404 /// logs a given message, replacing 4 placeholders in the message with respective values 405 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4 > logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const::rtl::OUString & _rMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4) const406 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const ::rtl::OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4 ) const 407 { 408 if ( isLoggable( _nLogLevel ) ) 409 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, _rMessage, 410 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 411 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 412 OptionalString( log::convert::convertLogArgToString( _argument3 ) ), 413 OptionalString( log::convert::convertLogArgToString( _argument4 ) ) ); 414 return false; 415 } 416 417 /// logs a given message, replacing 5 placeholders in the message with respective values 418 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5 > logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const::rtl::OUString & _rMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4,ARGTYPE5 _argument5) const419 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const ::rtl::OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5 ) const 420 { 421 if ( isLoggable( _nLogLevel ) ) 422 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, _rMessage, 423 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 424 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 425 OptionalString( log::convert::convertLogArgToString( _argument3 ) ), 426 OptionalString( log::convert::convertLogArgToString( _argument4 ) ), 427 OptionalString( log::convert::convertLogArgToString( _argument5 ) ) ); 428 return false; 429 } 430 431 /// logs a given message, replacing 6 placeholders in the message with respective values 432 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5, typename ARGTYPE6 > logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const::rtl::OUString & _rMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4,ARGTYPE5 _argument5,ARGTYPE6 _argument6) const433 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const ::rtl::OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5, ARGTYPE6 _argument6 ) const 434 { 435 if ( isLoggable( _nLogLevel ) ) 436 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, _rMessage, 437 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 438 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 439 OptionalString( log::convert::convertLogArgToString( _argument3 ) ), 440 OptionalString( log::convert::convertLogArgToString( _argument4 ) ), 441 OptionalString( log::convert::convertLogArgToString( _argument5 ) ), 442 OptionalString( log::convert::convertLogArgToString( _argument6 ) ) ); 443 return false; 444 } 445 446 //---------------------------------------------------------------- 447 //- XLogger::logp equivalents/wrappers 448 //- ASCII messages 449 450 /// logs a given ASCII message, without any arguments, or source class/method names logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const sal_Char * _pAsciiMessage) const451 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const sal_Char* _pAsciiMessage ) const 452 { 453 if ( isLoggable( _nLogLevel ) ) 454 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, ::rtl::OUString::createFromAscii( _pAsciiMessage ) ); 455 return false; 456 } 457 458 /** logs a given ASCII message, replacing a placeholder in the message with an argument 459 460 The function takes, additionally to the logp level and the message, an arbitrary 461 argument. This argument is converted to a string using an overloaded function 462 named <code>convertLogArgToString</code>. Then, a placeholder "$1$" 463 is searched in the message string, and replaced with the argument string. 464 */ 465 template< typename ARGTYPE1 > logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const sal_Char * _pAsciiMessage,ARGTYPE1 _argument1) const466 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const sal_Char* _pAsciiMessage, ARGTYPE1 _argument1 ) const 467 { 468 if ( isLoggable( _nLogLevel ) ) 469 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, ::rtl::OUString::createFromAscii( _pAsciiMessage ), 470 OptionalString( log::convert::convertLogArgToString( _argument1 ) ) ); 471 return false; 472 } 473 474 /// logs a given ASCII message, replacing 2 placeholders in the message with respective values 475 template< typename ARGTYPE1, typename ARGTYPE2 > logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const sal_Char * _pAsciiMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2) const476 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const sal_Char* _pAsciiMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2 ) const 477 { 478 if ( isLoggable( _nLogLevel ) ) 479 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, ::rtl::OUString::createFromAscii( _pAsciiMessage ), 480 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 481 OptionalString( log::convert::convertLogArgToString( _argument2 ) ) ); 482 return false; 483 } 484 485 /// logs a given ASCII message, replacing 3 placeholders in the message with respective values 486 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3 > logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const sal_Char * _pAsciiMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3) const487 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const sal_Char* _pAsciiMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3 ) const 488 { 489 if ( isLoggable( _nLogLevel ) ) 490 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, ::rtl::OUString::createFromAscii( _pAsciiMessage ), 491 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 492 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 493 OptionalString( log::convert::convertLogArgToString( _argument3 ) ) ); 494 return false; 495 } 496 497 /// logs a given ASCII message, replacing 4 placeholders in the message with respective values 498 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4 > logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const sal_Char * _pAsciiMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4) const499 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const sal_Char* _pAsciiMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4 ) const 500 { 501 if ( isLoggable( _nLogLevel ) ) 502 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, ::rtl::OUString::createFromAscii( _pAsciiMessage ), 503 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 504 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 505 OptionalString( log::convert::convertLogArgToString( _argument3 ) ), 506 OptionalString( log::convert::convertLogArgToString( _argument4 ) ) ); 507 return false; 508 } 509 510 /// logs a given ASCII message, replacing 5 placeholders in the message with respective values 511 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5 > logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const sal_Char * _pAsciiMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4,ARGTYPE5 _argument5) const512 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const sal_Char* _pAsciiMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5 ) const 513 { 514 if ( isLoggable( _nLogLevel ) ) 515 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, ::rtl::OUString::createFromAscii( _pAsciiMessage ), 516 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 517 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 518 OptionalString( log::convert::convertLogArgToString( _argument3 ) ), 519 OptionalString( log::convert::convertLogArgToString( _argument4 ) ), 520 OptionalString( log::convert::convertLogArgToString( _argument5 ) ) ); 521 return false; 522 } 523 524 /// logs a given ASCII message, replacing 6 placeholders in the message with respective values 525 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5, typename ARGTYPE6 > logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const sal_Char * _pAsciiMessage,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4,ARGTYPE5 _argument5,ARGTYPE6 _argument6) const526 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const sal_Char* _pAsciiMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5, ARGTYPE6 _argument6 ) const 527 { 528 if ( isLoggable( _nLogLevel ) ) 529 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, ::rtl::OUString::createFromAscii( _pAsciiMessage ), 530 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 531 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 532 OptionalString( log::convert::convertLogArgToString( _argument3 ) ), 533 OptionalString( log::convert::convertLogArgToString( _argument4 ) ), 534 OptionalString( log::convert::convertLogArgToString( _argument5 ) ), 535 OptionalString( log::convert::convertLogArgToString( _argument6 ) ) ); 536 return false; 537 } 538 539 protected: 540 bool impl_log( 541 const sal_Int32 _nLogLevel, 542 const sal_Char* _pSourceClass, 543 const sal_Char* _pSourceMethod, 544 const ::rtl::OUString& _rMessage, 545 const OptionalString& _rArgument1 = OptionalString(), 546 const OptionalString& _rArgument2 = OptionalString(), 547 const OptionalString& _rArgument3 = OptionalString(), 548 const OptionalString& _rArgument4 = OptionalString(), 549 const OptionalString& _rArgument5 = OptionalString(), 550 const OptionalString& _rArgument6 = OptionalString() 551 ) const; 552 }; 553 554 //==================================================================== 555 //= ResourceBasedEventLogger 556 //==================================================================== 557 struct ResourceBasedEventLogger_Data; 558 /** extends the EventLogger class with functionality to load log messages from 559 a resource bundle. 560 */ 561 class COMPHELPER_DLLPUBLIC ResourceBasedEventLogger : public EventLogger 562 { 563 private: 564 ::boost::shared_ptr< ResourceBasedEventLogger_Data > m_pData; 565 566 public: 567 /** creates a resource based event logger 568 @param _rxContext 569 the component context for creating new components 570 @param _rResourceBundleBaseName 571 the base name of the resource bundle to use. Will be used 572 in conjunction with XResourceBundleLoader::loadResource. 573 @param _rLoggerName 574 the name of the logger to work with. If empty, the office-wide 575 default logger will be used. 576 577 */ 578 ResourceBasedEventLogger( 579 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext, 580 const ::rtl::OUString& _rResourceBundleBaseName, 581 const ::rtl::OUString& _rLoggerName = ::rtl::OUString() 582 ); 583 584 /** creates a resource based event logger 585 @param _rxContext 586 the component context for creating new components 587 @param _pResourceBundleBaseName 588 the ASCII base name of the resource bundle to use. Will be used 589 in conjunction with XResourceBundleLoader::loadResource. 590 @param _pAsciiLoggerName 591 the ASCII name of the logger to work with. If NULL, the office-wide 592 default logger will be used. 593 594 */ 595 ResourceBasedEventLogger( 596 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext, 597 const sal_Char* _pResourceBundleBaseName, 598 const sal_Char* _pAsciiLoggerName = NULL 599 ); 600 601 //---------------------------------------------------------------- 602 //- XLogger::log equivalents/wrappers 603 //- resource IDs 604 605 /// logs a given message, without any arguments, or source class/method names log(const sal_Int32 _nLogLevel,const sal_Int32 _nMessageResID) const606 bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID ) const 607 { 608 if ( isLoggable( _nLogLevel ) ) 609 return impl_log( _nLogLevel, NULL, NULL, impl_loadStringMessage_nothrow( _nMessageResID ) ); 610 return false; 611 } 612 613 /** logs a given message, replacing a placeholder in the message with an argument 614 615 The function takes, additionally to the log level and the message, an arbitrary 616 argument. This argument is converted to a string using an overloaded function 617 named <code>convertLogArgToString</code>. Then, a placeholder "$1$" 618 is searched in the message string, and replaced with the argument string. 619 */ 620 template< typename ARGTYPE1 > log(const sal_Int32 _nLogLevel,const sal_Int32 _nMessageResID,ARGTYPE1 _argument1) const621 bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1 ) const 622 { 623 if ( isLoggable( _nLogLevel ) ) 624 return impl_log( _nLogLevel, NULL, NULL, impl_loadStringMessage_nothrow( _nMessageResID ), 625 OptionalString( log::convert::convertLogArgToString( _argument1 ) ) ); 626 return false; 627 } 628 629 /// logs a given message, replacing 2 placeholders in the message with respective values 630 template< typename ARGTYPE1, typename ARGTYPE2 > log(const sal_Int32 _nLogLevel,const sal_Int32 _nMessageResID,ARGTYPE1 _argument1,ARGTYPE2 _argument2) const631 bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2 ) const 632 { 633 if ( isLoggable( _nLogLevel ) ) 634 return impl_log( _nLogLevel, NULL, NULL, impl_loadStringMessage_nothrow( _nMessageResID ), 635 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 636 OptionalString( log::convert::convertLogArgToString( _argument2 ) ) ); 637 return false; 638 } 639 640 /// logs a given message, replacing 3 placeholders in the message with respective values 641 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3 > log(const sal_Int32 _nLogLevel,const sal_Int32 _nMessageResID,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3) const642 bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3 ) const 643 { 644 if ( isLoggable( _nLogLevel ) ) 645 return impl_log( _nLogLevel, NULL, NULL, impl_loadStringMessage_nothrow( _nMessageResID ), 646 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 647 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 648 OptionalString( log::convert::convertLogArgToString( _argument3 ) ) ); 649 return false; 650 } 651 652 /// logs a given message, replacing 4 placeholders in the message with respective values 653 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4 > log(const sal_Int32 _nLogLevel,const sal_Int32 _nMessageResID,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4) const654 bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4 ) const 655 { 656 if ( isLoggable( _nLogLevel ) ) 657 return impl_log( _nLogLevel, NULL, NULL, impl_loadStringMessage_nothrow( _nMessageResID ), 658 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 659 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 660 OptionalString( log::convert::convertLogArgToString( _argument3 ) ), 661 OptionalString( log::convert::convertLogArgToString( _argument4 ) ) ); 662 return false; 663 } 664 665 /// logs a given message, replacing 5 placeholders in the message with respective values 666 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5 > log(const sal_Int32 _nLogLevel,const sal_Int32 _nMessageResID,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4,ARGTYPE5 _argument5) const667 bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5 ) const 668 { 669 if ( isLoggable( _nLogLevel ) ) 670 return impl_log( _nLogLevel, NULL, NULL, impl_loadStringMessage_nothrow( _nMessageResID ), 671 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 672 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 673 OptionalString( log::convert::convertLogArgToString( _argument3 ) ), 674 OptionalString( log::convert::convertLogArgToString( _argument4 ) ), 675 OptionalString( log::convert::convertLogArgToString( _argument5 ) ) ); 676 return false; 677 } 678 679 /// logs a given message, replacing 6 placeholders in the message with respective values 680 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5, typename ARGTYPE6 > log(const sal_Int32 _nLogLevel,const sal_Int32 _nMessageResID,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4,ARGTYPE5 _argument5,ARGTYPE6 _argument6) const681 bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5, ARGTYPE6 _argument6 ) const 682 { 683 if ( isLoggable( _nLogLevel ) ) 684 return impl_log( _nLogLevel, NULL, NULL, impl_loadStringMessage_nothrow( _nMessageResID ), 685 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 686 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 687 OptionalString( log::convert::convertLogArgToString( _argument3 ) ), 688 OptionalString( log::convert::convertLogArgToString( _argument4 ) ), 689 OptionalString( log::convert::convertLogArgToString( _argument5 ) ), 690 OptionalString( log::convert::convertLogArgToString( _argument6 ) ) ); 691 return false; 692 } 693 694 //---------------------------------------------------------------- 695 //- XLogger::logp equivalents/wrappers 696 //- resource IDs 697 698 /// logs a given ASCII message, without any arguments, or source class/method names logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const sal_Int32 _nMessageResID) const699 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const sal_Int32 _nMessageResID ) const 700 { 701 if ( isLoggable( _nLogLevel ) ) 702 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, impl_loadStringMessage_nothrow( _nMessageResID ) ); 703 return false; 704 } 705 706 /** logs a given ASCII message, replacing a placeholder in the message with an argument 707 */ 708 template< typename ARGTYPE1 > logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const sal_Int32 _nMessageResID,ARGTYPE1 _argument1) const709 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1 ) const 710 { 711 if ( isLoggable( _nLogLevel ) ) 712 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, impl_loadStringMessage_nothrow( _nMessageResID ), 713 OptionalString( log::convert::convertLogArgToString( _argument1 ) ) ); 714 return false; 715 } 716 717 /// logs a given ASCII message, replacing 2 placeholders in the message with respective values 718 template< typename ARGTYPE1, typename ARGTYPE2 > logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const sal_Int32 _nMessageResID,ARGTYPE1 _argument1,ARGTYPE2 _argument2) const719 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2 ) const 720 { 721 if ( isLoggable( _nLogLevel ) ) 722 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, impl_loadStringMessage_nothrow( _nMessageResID ), 723 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 724 OptionalString( log::convert::convertLogArgToString( _argument2 ) ) ); 725 return false; 726 } 727 728 /// logs a given ASCII message, replacing 3 placeholders in the message with respective values 729 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3 > logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const sal_Int32 _nMessageResID,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3) const730 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3 ) const 731 { 732 if ( isLoggable( _nLogLevel ) ) 733 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, impl_loadStringMessage_nothrow( _nMessageResID ), 734 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 735 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 736 OptionalString( log::convert::convertLogArgToString( _argument3 ) ) ); 737 return false; 738 } 739 740 /// logs a given ASCII message, replacing 4 placeholders in the message with respective values 741 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4 > logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const sal_Int32 _nMessageResID,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4) const742 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4 ) const 743 { 744 if ( isLoggable( _nLogLevel ) ) 745 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, impl_loadStringMessage_nothrow( _nMessageResID ), 746 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 747 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 748 OptionalString( log::convert::convertLogArgToString( _argument3 ) ), 749 OptionalString( log::convert::convertLogArgToString( _argument4 ) ) ); 750 return false; 751 } 752 753 /// logs a given ASCII message, replacing 5 placeholders in the message with respective values 754 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5 > logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const sal_Int32 _nMessageResID,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4,ARGTYPE5 _argument5) const755 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5 ) const 756 { 757 if ( isLoggable( _nLogLevel ) ) 758 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, impl_loadStringMessage_nothrow( _nMessageResID ), 759 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 760 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 761 OptionalString( log::convert::convertLogArgToString( _argument3 ) ), 762 OptionalString( log::convert::convertLogArgToString( _argument4 ) ), 763 OptionalString( log::convert::convertLogArgToString( _argument5 ) ) ); 764 return false; 765 } 766 767 /// logs a given ASCII message, replacing 6 placeholders in the message with respective values 768 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5, typename ARGTYPE6 > logp(const sal_Int32 _nLogLevel,const sal_Char * _pSourceClass,const sal_Char * _pSourceMethod,const sal_Int32 _nMessageResID,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4,ARGTYPE5 _argument5,ARGTYPE6 _argument6) const769 bool logp( const sal_Int32 _nLogLevel, const sal_Char* _pSourceClass, const sal_Char* _pSourceMethod, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5, ARGTYPE6 _argument6 ) const 770 { 771 if ( isLoggable( _nLogLevel ) ) 772 return impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, impl_loadStringMessage_nothrow( _nMessageResID ), 773 OptionalString( log::convert::convertLogArgToString( _argument1 ) ), 774 OptionalString( log::convert::convertLogArgToString( _argument2 ) ), 775 OptionalString( log::convert::convertLogArgToString( _argument3 ) ), 776 OptionalString( log::convert::convertLogArgToString( _argument4 ) ), 777 OptionalString( log::convert::convertLogArgToString( _argument5 ) ), 778 OptionalString( log::convert::convertLogArgToString( _argument6 ) ) ); 779 return false; 780 } 781 782 private: 783 ::rtl::OUString impl_loadStringMessage_nothrow( const sal_Int32 _nMessageResID ) const; 784 }; 785 786 //........................................................................ 787 } // namespace comphelper 788 //........................................................................ 789 790 #endif // COMPHELPER_LOGGING_HXX 791