Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/comphelper/logging.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
20
#ifndef INCLUDED_COMPHELPER_LOGGING_HXX
21
#define INCLUDED_COMPHELPER_LOGGING_HXX
22
23
#include <comphelper/comphelperdllapi.h>
24
#include <rtl/ustring.hxx>
25
26
#include <optional>
27
#include <memory>
28
29
namespace com::sun::star::uno { template <class interface_type> class Reference; }
30
namespace com::sun::star::uno { class XComponentContext; }
31
namespace com::sun::star::logging { class XLogger; }
32
33
namespace comphelper
34
{
35
36
37
    //= string conversions, employed by the templatized log* members of
38
    //= EventLogger
39
40
41
    namespace log::convert
42
    {
43
        inline const OUString& convertLogArgToString( const OUString& _rValue )
44
0
        {
45
0
            return _rValue;
46
0
        }
47
48
        inline OUString convertLogArgToString( const char* _pAsciiValue )
49
0
        {
50
0
            return OUString::createFromAscii( _pAsciiValue );
51
0
        }
52
53
0
        inline OUString convertLogArgToString( double      _nValue ) { return OUString::number( _nValue ); }
54
0
        inline OUString convertLogArgToString( float       _nValue ) { return OUString::number( _nValue ); }
55
0
        inline OUString convertLogArgToString( sal_Int64   _nValue ) { return OUString::number( _nValue ); }
56
0
        inline OUString convertLogArgToString( sal_Int32   _nValue ) { return OUString::number( _nValue ); }
57
0
        inline OUString convertLogArgToString( sal_Int16   _nValue ) { return OUString::number( _nValue ); }
58
0
        inline OUString convertLogArgToString( sal_Unicode _nValue ) { return OUString( _nValue ); }
59
0
        inline OUString convertLogArgToString( bool    _bValue ) { return OUString::boolean( _bValue ); }
60
        void convertLogArgToString(sal_Bool) = delete;
61
62
    } // namespace log::convert
63
64
65
    //= EventLogger
66
67
    class EventLogger_Impl;
68
    typedef ::std::optional< OUString >    OptionalString;
69
70
    /** encapsulates a css::logging::XLogger
71
72
        The class silences several (unlikely) errors which could potentially happen
73
        when working with a logger. Additionally, it provides some convenience methods
74
        for logging events.
75
76
        You can use this class as follows
77
<pre>
78
    EventLogger aLogger( xContext, sLoggerName );
79
    ...
80
    aLogger.log( LogLevel::SEVERE, sSomeMessage );
81
    aLogger.logp( LogLevel::CONFIG, "MyClass", "MyMethod", sSomeMessage, SomeParameter1, SomeParameter2, SomeParameter3 );
82
</pre>
83
84
        The <code>log</code> and <code>logp</code> calls support up to 6 parameters, which can be of
85
        arbitrary type. For every parameter, there must exist a function <code>convertLogArgToString</code>
86
        which takes an argument of the respective type, and returns a string.
87
88
        After a parameter has been converted to a string using the above mentioned
89
        <code>convertLogArgToString</code> function, a placeholder $1$ (resp. $2$ resp. $4$ ...)
90
        in the message will be replaced with this string, and the resulting message will be logged.
91
    */
92
    class COMPHELPER_DLLPUBLIC EventLogger
93
    {
94
        std::shared_ptr< EventLogger_Impl > m_pImpl;
95
96
    public:
97
        /** creates an <code>EventLogger</code> instance working with a css.logging.XLogger
98
            instance given by ASCII name.
99
100
            @param _rxContext
101
                the component context to create services
102
103
            @param _rLoggerName
104
                the ASCII name of the logger to create.
105
        */
106
        EventLogger(
107
            const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
108
            const char* _pAsciiLoggerName
109
        );
110
111
    public:
112
        /// determines whether an event with the given level would be logged
113
        bool        isLoggable( const sal_Int32 _nLogLevel ) const;
114
115
116
        //- XLogger::log equivalents/wrappers
117
        //- string messages
118
119
        /// logs a given message, without any arguments, or source class/method names
120
        void        log( const sal_Int32 _nLogLevel, const OUString& rMessage ) const
121
0
        {
122
0
            if ( isLoggable( _nLogLevel ) )
123
0
                impl_log(_nLogLevel, nullptr, nullptr, rMessage);
124
0
        }
125
126
        const css::uno::Reference<css::logging::XLogger> & getLogger() const;
127
128
        /** logs a given message, replacing a placeholder in the message with an argument
129
130
            The function takes, additionally to the log level and the message, an arbitrary
131
            argument. This argument is converted to a string using an overloaded function
132
            named <code>convertLogArgToString</code>. Then, a placeholder &quot;$1$&quot;
133
            is searched in the message string, and replaced with the argument string.
134
        */
135
        template< typename ARGTYPE1 >
136
        void        log( const sal_Int32 _nLogLevel, const OUString& _rMessage, ARGTYPE1 _argument1 ) const
137
        {
138
            if ( isLoggable( _nLogLevel ) )
139
                impl_log( _nLogLevel, nullptr, nullptr, _rMessage,
140
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ) );
141
        }
142
143
        /// logs a given message, replacing 2 placeholders in the message with respective values
144
        template< typename ARGTYPE1, typename ARGTYPE2 >
145
        void        log( const sal_Int32 _nLogLevel, const OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2 ) const
146
        {
147
            if ( isLoggable( _nLogLevel ) )
148
                impl_log( _nLogLevel, nullptr, nullptr, _rMessage,
149
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
150
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ) );
151
        }
152
153
        /// logs a given message, replacing 3 placeholders in the message with respective values
154
        template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3 >
155
        void        log( const sal_Int32 _nLogLevel, const OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3 ) const
156
        {
157
            if ( isLoggable( _nLogLevel ) )
158
                impl_log( _nLogLevel, nullptr, nullptr, _rMessage,
159
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
160
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ),
161
                    OptionalString( log::convert::convertLogArgToString( _argument3 ) ) );
162
        }
163
164
        /// logs a given message, replacing 4 placeholders in the message with respective values
165
        template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4 >
166
        void        log( const sal_Int32 _nLogLevel, const OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4 ) const
167
        {
168
            if ( isLoggable( _nLogLevel ) )
169
                impl_log( _nLogLevel, nullptr, nullptr, _rMessage,
170
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
171
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ),
172
                    OptionalString( log::convert::convertLogArgToString( _argument3 ) ),
173
                    OptionalString( log::convert::convertLogArgToString( _argument4 ) ) );
174
        }
175
176
        /// logs a given message, replacing 5 placeholders in the message with respective values
177
        template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5 >
178
        void        log( const sal_Int32 _nLogLevel, const OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5 ) const
179
        {
180
            if ( isLoggable( _nLogLevel ) )
181
                impl_log( _nLogLevel, nullptr, nullptr, _rMessage,
182
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
183
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ),
184
                    OptionalString( log::convert::convertLogArgToString( _argument3 ) ),
185
                    OptionalString( log::convert::convertLogArgToString( _argument4 ) ),
186
                    OptionalString( log::convert::convertLogArgToString( _argument5 ) ) );
187
        }
188
189
        /// logs a given message, replacing 6 placeholders in the message with respective values
190
        template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5, typename ARGTYPE6 >
191
        void        log( const sal_Int32 _nLogLevel, const OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5, ARGTYPE6 _argument6 ) const
192
        {
193
            if ( isLoggable( _nLogLevel ) )
194
                impl_log( _nLogLevel, nullptr, nullptr, _rMessage,
195
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
196
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ),
197
                    OptionalString( log::convert::convertLogArgToString( _argument3 ) ),
198
                    OptionalString( log::convert::convertLogArgToString( _argument4 ) ),
199
                    OptionalString( log::convert::convertLogArgToString( _argument5 ) ),
200
                    OptionalString( log::convert::convertLogArgToString( _argument6 ) ) );
201
        }
202
203
204
        //- XLogger::log equivalents/wrappers
205
        //- ASCII messages
206
207
        /** logs a given message, replacing a placeholder in the message with an argument
208
209
            The function takes, additionally to the log level and the message, an arbitrary
210
            argument. This argument is converted to a string using an overloaded function
211
            named <code>convertLogArgToString</code>. Then, a placeholder &quot;$1$&quot;
212
            is searched in the message string, and replaced with the argument string.
213
        */
214
        template< typename ARGTYPE1 >
215
        void        log( const sal_Int32 _nLogLevel, const char* _pMessage, ARGTYPE1 _argument1 ) const
216
18.3k
        {
217
18.3k
            if ( isLoggable( _nLogLevel ) )
218
0
                impl_log( _nLogLevel, nullptr, nullptr, OUString::createFromAscii( _pMessage ),
219
0
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ) );
220
18.3k
        }
221
222
        /// logs a given message, replacing 2 placeholders in the message with respective values
223
        template< typename ARGTYPE1, typename ARGTYPE2 >
224
        void        log( const sal_Int32 _nLogLevel, const char* _pMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2 ) const
225
        {
226
            if ( isLoggable( _nLogLevel ) )
227
                impl_log( _nLogLevel, nullptr, nullptr, OUString::createFromAscii( _pMessage ),
228
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
229
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ) );
230
        }
231
232
        /// logs a given message, replacing 3 placeholders in the message with respective values
233
        template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3 >
234
        void        log( const sal_Int32 _nLogLevel, const char* _pMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3 ) const
235
        {
236
            if ( isLoggable( _nLogLevel ) )
237
                impl_log( _nLogLevel, nullptr, nullptr, OUString::createFromAscii( _pMessage ),
238
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
239
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ),
240
                    OptionalString( log::convert::convertLogArgToString( _argument3 ) ) );
241
        }
242
243
        /// logs a given message, replacing 4 placeholders in the message with respective values
244
        template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4 >
245
        void        log( const sal_Int32 _nLogLevel, const char* _pMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4 ) const
246
        {
247
            if ( isLoggable( _nLogLevel ) )
248
                impl_log( _nLogLevel, nullptr, nullptr, OUString::createFromAscii( _pMessage ),
249
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
250
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ),
251
                    OptionalString( log::convert::convertLogArgToString( _argument3 ) ),
252
                    OptionalString( log::convert::convertLogArgToString( _argument4 ) ) );
253
        }
254
255
        /// logs a given message, replacing 5 placeholders in the message with respective values
256
        template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5 >
257
        void        log( const sal_Int32 _nLogLevel, const char* _pMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5 ) const
258
        {
259
            if ( isLoggable( _nLogLevel ) )
260
                impl_log( _nLogLevel, nullptr, nullptr, OUString::createFromAscii( _pMessage ),
261
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
262
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ),
263
                    OptionalString( log::convert::convertLogArgToString( _argument3 ) ),
264
                    OptionalString( log::convert::convertLogArgToString( _argument4 ) ),
265
                    OptionalString( log::convert::convertLogArgToString( _argument5 ) ) );
266
        }
267
268
        /// logs a given message, replacing 6 placeholders in the message with respective values
269
        template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5, typename ARGTYPE6 >
270
        void        log( const sal_Int32 _nLogLevel, const char* _pMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5, ARGTYPE6 _argument6 ) const
271
        {
272
            if ( isLoggable( _nLogLevel ) )
273
                impl_log( _nLogLevel, nullptr, nullptr, OUString::createFromAscii( _pMessage ),
274
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
275
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ),
276
                    OptionalString( log::convert::convertLogArgToString( _argument3 ) ),
277
                    OptionalString( log::convert::convertLogArgToString( _argument4 ) ),
278
                    OptionalString( log::convert::convertLogArgToString( _argument5 ) ),
279
                    OptionalString( log::convert::convertLogArgToString( _argument6 ) ) );
280
        }
281
282
283
        //- XLogger::logp equivalents/wrappers
284
        //- string messages
285
286
        /** logs a given message, replacing a placeholder in the message with an argument
287
288
            The function takes, additionally to the logp level and the message, an arbitrary
289
            argument. This argument is converted to a string using an overloaded function
290
            named <code>convertLogArgToString</code>. Then, a placeholder &quot;$1$&quot;
291
            is searched in the message string, and replaced with the argument string.
292
        */
293
        template< typename ARGTYPE1 >
294
        void        logp( const sal_Int32 _nLogLevel, const char* _pSourceClass, const char* _pSourceMethod, const OUString& _rMessage, ARGTYPE1 _argument1 ) const
295
        {
296
            if ( isLoggable( _nLogLevel ) )
297
                impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, _rMessage,
298
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ) );
299
        }
300
301
        /// logs a given message, replacing 2 placeholders in the message with respective values
302
        template< typename ARGTYPE1, typename ARGTYPE2 >
303
        void        logp( const sal_Int32 _nLogLevel, const char* _pSourceClass, const char* _pSourceMethod, const OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2 ) const
304
        {
305
            if ( isLoggable( _nLogLevel ) )
306
                impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, _rMessage,
307
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
308
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ) );
309
        }
310
311
        /// logs a given message, replacing 3 placeholders in the message with respective values
312
        template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3 >
313
        void        logp( const sal_Int32 _nLogLevel, const char* _pSourceClass, const char* _pSourceMethod, const OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3 ) const
314
        {
315
            if ( isLoggable( _nLogLevel ) )
316
                impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, _rMessage,
317
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
318
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ),
319
                    OptionalString( log::convert::convertLogArgToString( _argument3 ) ) );
320
        }
321
322
        /// logs a given message, replacing 4 placeholders in the message with respective values
323
        template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4 >
324
        void        logp( const sal_Int32 _nLogLevel, const char* _pSourceClass, const char* _pSourceMethod, const OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4 ) const
325
        {
326
            if ( isLoggable( _nLogLevel ) )
327
                impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, _rMessage,
328
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
329
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ),
330
                    OptionalString( log::convert::convertLogArgToString( _argument3 ) ),
331
                    OptionalString( log::convert::convertLogArgToString( _argument4 ) ) );
332
        }
333
334
        /// logs a given message, replacing 5 placeholders in the message with respective values
335
        template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5 >
336
        void        logp( const sal_Int32 _nLogLevel, const char* _pSourceClass, const char* _pSourceMethod, const OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5 ) const
337
        {
338
            if ( isLoggable( _nLogLevel ) )
339
                impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, _rMessage,
340
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
341
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ),
342
                    OptionalString( log::convert::convertLogArgToString( _argument3 ) ),
343
                    OptionalString( log::convert::convertLogArgToString( _argument4 ) ),
344
                    OptionalString( log::convert::convertLogArgToString( _argument5 ) ) );
345
        }
346
347
        /// logs a given message, replacing 6 placeholders in the message with respective values
348
        template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5, typename ARGTYPE6 >
349
        void        logp( const sal_Int32 _nLogLevel, const char* _pSourceClass, const char* _pSourceMethod, const OUString& _rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5, ARGTYPE6 _argument6 ) const
350
        {
351
            if ( isLoggable( _nLogLevel ) )
352
                impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, _rMessage,
353
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
354
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ),
355
                    OptionalString( log::convert::convertLogArgToString( _argument3 ) ),
356
                    OptionalString( log::convert::convertLogArgToString( _argument4 ) ),
357
                    OptionalString( log::convert::convertLogArgToString( _argument5 ) ),
358
                    OptionalString( log::convert::convertLogArgToString( _argument6 ) ) );
359
        }
360
361
362
        //- XLogger::logp equivalents/wrappers
363
        //- ASCII messages
364
365
        /** logs a given ASCII 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 &quot;$1$&quot;
370
            is searched in the message string, and replaced with the argument string.
371
        */
372
        template< typename ARGTYPE1 >
373
        void        logp( const sal_Int32 _nLogLevel, const char* _pSourceClass, const char* _pSourceMethod, const char* _pAsciiMessage, ARGTYPE1 _argument1 ) const
374
        {
375
            if ( isLoggable( _nLogLevel ) )
376
                impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, OUString::createFromAscii( _pAsciiMessage ),
377
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ) );
378
        }
379
380
        /// logs a given ASCII message, replacing 2 placeholders in the message with respective values
381
        template< typename ARGTYPE1, typename ARGTYPE2 >
382
        void        logp( const sal_Int32 _nLogLevel, const char* _pSourceClass, const char* _pSourceMethod, const char* _pAsciiMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2 ) const
383
        {
384
            if ( isLoggable( _nLogLevel ) )
385
                impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, OUString::createFromAscii( _pAsciiMessage ),
386
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
387
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ) );
388
        }
389
390
        /// logs a given ASCII message, replacing 3 placeholders in the message with respective values
391
        template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3 >
392
        void        logp( const sal_Int32 _nLogLevel, const char* _pSourceClass, const char* _pSourceMethod, const char* _pAsciiMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3 ) const
393
        {
394
            if ( isLoggable( _nLogLevel ) )
395
                impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, OUString::createFromAscii( _pAsciiMessage ),
396
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
397
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ),
398
                    OptionalString( log::convert::convertLogArgToString( _argument3 ) ) );
399
        }
400
401
        /// logs a given ASCII message, replacing 4 placeholders in the message with respective values
402
        template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4 >
403
        void        logp( const sal_Int32 _nLogLevel, const char* _pSourceClass, const char* _pSourceMethod, const char* _pAsciiMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4 ) const
404
        {
405
            if ( isLoggable( _nLogLevel ) )
406
                impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, OUString::createFromAscii( _pAsciiMessage ),
407
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
408
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ),
409
                    OptionalString( log::convert::convertLogArgToString( _argument3 ) ),
410
                    OptionalString( log::convert::convertLogArgToString( _argument4 ) ) );
411
        }
412
413
        /// logs a given ASCII message, replacing 5 placeholders in the message with respective values
414
        template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5 >
415
        void        logp( const sal_Int32 _nLogLevel, const char* _pSourceClass, const char* _pSourceMethod, const char* _pAsciiMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5 ) const
416
        {
417
            if ( isLoggable( _nLogLevel ) )
418
                impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, OUString::createFromAscii( _pAsciiMessage ),
419
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
420
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ),
421
                    OptionalString( log::convert::convertLogArgToString( _argument3 ) ),
422
                    OptionalString( log::convert::convertLogArgToString( _argument4 ) ),
423
                    OptionalString( log::convert::convertLogArgToString( _argument5 ) ) );
424
        }
425
426
        /// logs a given ASCII message, replacing 6 placeholders in the message with respective values
427
        template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5, typename ARGTYPE6 >
428
        void        logp( const sal_Int32 _nLogLevel, const char* _pSourceClass, const char* _pSourceMethod, const char* _pAsciiMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5, ARGTYPE6 _argument6 ) const
429
        {
430
            if ( isLoggable( _nLogLevel ) )
431
                impl_log( _nLogLevel, _pSourceClass, _pSourceMethod, OUString::createFromAscii( _pAsciiMessage ),
432
                    OptionalString( log::convert::convertLogArgToString( _argument1 ) ),
433
                    OptionalString( log::convert::convertLogArgToString( _argument2 ) ),
434
                    OptionalString( log::convert::convertLogArgToString( _argument3 ) ),
435
                    OptionalString( log::convert::convertLogArgToString( _argument4 ) ),
436
                    OptionalString( log::convert::convertLogArgToString( _argument5 ) ),
437
                    OptionalString( log::convert::convertLogArgToString( _argument6 ) ) );
438
        }
439
440
    protected:
441
        void        impl_log(
442
                        const sal_Int32 _nLogLevel,
443
                        const char* _pSourceClass,
444
                        const char* _pSourceMethod,
445
                        const OUString& _rMessage,
446
                        const OptionalString& _rArgument1 = OptionalString(),
447
                        const OptionalString& _rArgument2 = OptionalString(),
448
                        const OptionalString& _rArgument3 = OptionalString(),
449
                        const OptionalString& _rArgument4 = OptionalString(),
450
                        const OptionalString& _rArgument5 = OptionalString(),
451
                        const OptionalString& _rArgument6 = OptionalString()
452
                    ) const;
453
    };
454
} // namespace comphelper
455
456
457
#endif // INCLUDED_COMPHELPER_LOGGING_HXX
458
459
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */