Coverage Report

Created: 2025-11-24 06:16

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/logging-log4cxx/src/main/include/log4cxx/logger.h
Line
Count
Source
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *      http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
#ifndef _LOG4CXX_LOGGER_H
19
#define _LOG4CXX_LOGGER_H
20
21
#include <log4cxx/spi/appenderattachable.h>
22
#include <log4cxx/level.h>
23
#include <log4cxx/helpers/pool.h>
24
#include <log4cxx/spi/location/locationinfo.h>
25
#include <log4cxx/helpers/resourcebundle.h>
26
#include <log4cxx/helpers/asyncbuffer.h>
27
#include <log4cxx/helpers/messagebuffer.h>
28
29
namespace LOG4CXX_NS
30
{
31
32
namespace spi
33
{
34
class LoggerRepository;
35
LOG4CXX_PTR_DEF(LoggerRepository);
36
class LoggerFactory;
37
LOG4CXX_PTR_DEF(LoggerFactory);
38
}
39
40
class Logger;
41
/** smart pointer to a Logger class */
42
LOG4CXX_PTR_DEF(Logger);
43
LOG4CXX_LIST_DEF(LoggerList, LoggerPtr);
44
45
46
/**
47
This is the central class in the log4cxx package. Most logging
48
operations, except configuration, are done through this class.
49
*/
50
class LOG4CXX_EXPORT Logger
51
  : public virtual spi::AppenderAttachable
52
{
53
  public:
54
    DECLARE_ABSTRACT_LOG4CXX_OBJECT(Logger)
55
0
    BEGIN_LOG4CXX_CAST_MAP()
56
0
    LOG4CXX_CAST_ENTRY(Logger)
57
0
    LOG4CXX_CAST_ENTRY(spi::AppenderAttachable)
58
0
    END_LOG4CXX_CAST_MAP()
59
60
  private:
61
    LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(LoggerPrivate, m_priv)
62
    int m_threshold; //!< The cached level of this logger
63
64
  public:
65
    /**
66
    This constructor initializes a new <code>logger</code> instance and
67
    sets its name.
68
69
    <p>It is intended to be only used by factory-classes.
70
    */
71
    Logger(const LogString& name);
72
#if LOG4CXX_ABI_VERSION <= 15
73
    [[ deprecated( "Pool is no longer required" ) ]]
74
    Logger(helpers::Pool& pool, const LogString& name);
75
#endif
76
    ~Logger();
77
78
79
    /**
80
    Add <code>newAppender</code> to the list of appenders of this
81
    Logger instance.
82
83
    <p>If <code>newAppender</code> is already in the list of
84
    appenders, then it won't be added again.
85
    */
86
    void addAppender(const AppenderPtr newAppender) override;
87
88
89
    /**
90
    Call the appenders in the hierrachy starting at
91
    <code>this</code>.  If no appenders could be found, emit a
92
    warning.
93
94
    <p>This method calls all the appenders inherited from the
95
    hierarchy circumventing any evaluation of whether to log or not
96
    to log the particular log request.
97
98
    @param event the event to log.
99
    @param p memory pool for any allocations needed to process request.
100
    */
101
    void callAppenders(const spi::LoggingEventPtr& event, helpers::Pool& p) const;
102
103
    /**
104
    Close all attached appenders implementing the AppenderAttachable
105
    interface.
106
    */
107
    void closeNestedAppenders();
108
109
    /**
110
    Add a new logging event containing \c msg and \c location to attached appender(s) if this logger is enabled for <code>DEBUG</code> events.
111
112
    <p>This method first checks if this logger is <code>DEBUG</code>
113
    enabled by comparing the level of this logger with the
114
    DEBUG level. If this logger is
115
    <code>DEBUG</code> enabled, it proceeds to call all the
116
    registered appenders in this logger and also higher in the
117
    hierarchy depending on the value of the additivity flag.
118
119
    @param msg the message string to log.
120
    @param location The source code location of the logging request.
121
    */
122
    void debug(const std::string& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
123
    /**
124
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>DEBUG</code> events.
125
126
    <p>This method first checks if this logger is <code>DEBUG</code>
127
    enabled by comparing the level of this logger with the
128
    DEBUG level. If this logger is
129
    <code>DEBUG</code> enabled, it proceeds to call all the
130
    registered appenders in this logger and also higher in the
131
    hierarchy depending on the value of the additivity flag.
132
133
    @param msg the message string to log.
134
135
    See also #LOG4CXX_DEBUG.
136
    */
137
    void debug(const std::string& msg) const;
138
#if LOG4CXX_WCHAR_T_API
139
    /**
140
    Add a new logging event containing \c msg and \c location to attached appender(s) if this logger is enabled for <code>DEBUG</code> events.
141
142
    <p>This method first checks if this logger is <code>DEBUG</code>
143
    enabled by comparing the level of this logger with the
144
    DEBUG level. If this logger is
145
    <code>DEBUG</code> enabled, it proceeds to call all the
146
    registered appenders in this logger and also higher in the
147
    hierarchy depending on the value of the additivity flag.
148
149
    @param msg the message string to log.
150
    @param location The source code location of the logging request.
151
152
    See also #LOG4CXX_DEBUG.
153
    */
154
    void debug(const std::wstring& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
155
    /**
156
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>DEBUG</code> events.
157
158
    <p>This method first checks if this logger is <code>DEBUG</code>
159
    enabled by comparing the level of this logger with the
160
    DEBUG level. If this logger is
161
    <code>DEBUG</code> enabled, it proceeds to call all the
162
    registered appenders in this logger and also higher in the
163
    hierarchy depending on the value of the additivity flag.
164
165
    @param msg the message string to log.
166
167
    See also #LOG4CXX_DEBUG.
168
    */
169
    void debug(const std::wstring& msg) const;
170
#endif
171
#if LOG4CXX_UNICHAR_API
172
    /**
173
    Add a new logging event containing \c msg and \c location to attached appender(s) if this logger is enabled for <code>DEBUG</code> events.
174
175
    <p>This method first checks if this logger is <code>DEBUG</code>
176
    enabled by comparing the level of this logger with the
177
    DEBUG level. If this logger is
178
    <code>DEBUG</code> enabled, it proceeds to call all the
179
    registered appenders in this logger and also higher in the
180
    hierarchy depending on the value of the additivity flag.
181
182
    @param msg the message string to log.
183
    @param location The source code location of the logging request.
184
185
    See also #LOG4CXX_DEBUG.
186
    */
187
    void debug(const std::basic_string<UniChar>& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
188
    /**
189
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>DEBUG</code> events.
190
191
    <p>This method first checks if this logger is <code>DEBUG</code>
192
    enabled by comparing the level of this logger with the
193
    DEBUG level. If this logger is
194
    <code>DEBUG</code> enabled, it proceeds to call all the
195
    registered appenders in this logger and also higher in the
196
    hierarchy depending on the value of the additivity flag.
197
198
    @param msg the message string to log.
199
200
    See also #LOG4CXX_DEBUG.
201
    */
202
    void debug(const std::basic_string<UniChar>& msg) const;
203
#endif
204
#if LOG4CXX_CFSTRING_API
205
    /**
206
    Add a new logging event containing \c msg and \c location to attached appender(s) if this logger is enabled for <code>DEBUG</code> events.
207
208
    <p>This method first checks if this logger is <code>DEBUG</code>
209
    enabled by comparing the level of this logger with the
210
    DEBUG level. If this logger is
211
    <code>DEBUG</code> enabled, it proceeds to call all the
212
    registered appenders in this logger and also higher in the
213
    hierarchy depending on the value of the additivity flag.
214
215
    @param msg the message string to log.
216
    @param location The source code location of the logging request.
217
218
    See also #LOG4CXX_DEBUG.
219
    */
220
    void debug(const CFStringRef& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
221
    /**
222
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>DEBUG</code> events.
223
224
    <p>This method first checks if this logger is <code>DEBUG</code>
225
    enabled by comparing the level of this logger with the
226
    DEBUG level. If this logger is
227
    <code>DEBUG</code> enabled, it proceeds to call all the
228
    registered appenders in this logger and also higher in the
229
    hierarchy depending on the value of the additivity flag.
230
231
    @param msg the message string to log.
232
233
    See also #LOG4CXX_DEBUG.
234
    */
235
    void debug(const CFStringRef& msg) const;
236
#endif
237
238
    /**
239
    Add a new logging event containing \c msg and \c location to attached appender(s) if this logger is enabled for <code>ERROR</code> events.
240
241
    <p>This method first checks if this logger is <code>ERROR</code>
242
    enabled by comparing the level of this logger with the
243
    ERROR level. If this logger is
244
    <code>ERROR</code> enabled, it proceeds to call all the
245
    registered appenders in this logger and also higher in the
246
    hierarchy depending on the value of the additivity flag.
247
248
    @param msg the message string to log.
249
    @param location The source code location of the logging request.
250
251
    See also #LOG4CXX_ERROR.
252
    */
253
    void error(const std::string& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
254
    /**
255
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>ERROR</code> events.
256
257
    <p>This method first checks if this logger is <code>ERROR</code>
258
    enabled by comparing the level of this logger with the
259
    ERROR level. If this logger is
260
    <code>ERROR</code> enabled, it proceeds to call all the
261
    registered appenders in this logger and also higher in the
262
    hierarchy depending on the value of the additivity flag.
263
264
    @param msg the message string to log.
265
266
    See also #LOG4CXX_ERROR.
267
    */
268
    void error(const std::string& msg) const;
269
#if LOG4CXX_WCHAR_T_API
270
    /**
271
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>ERROR</code> events.
272
273
    <p>This method first checks if this logger is <code>ERROR</code>
274
    enabled by comparing the level of this logger with the
275
    ERROR level. If this logger is
276
    <code>ERROR</code> enabled, it proceeds to call all the
277
    registered appenders in this logger and also higher in the
278
    hierarchy depending on the value of the additivity flag.
279
280
    @param msg the message string to log.
281
282
    See also #LOG4CXX_ERROR.
283
    */
284
    void error(const std::wstring& msg) const;
285
    /**
286
    Add a new logging event containing \c msg and \c location to attached appender(s) if this logger is enabled for <code>ERROR</code> events.
287
288
    <p>This method first checks if this logger is <code>ERROR</code>
289
    enabled by comparing the level of this logger with the
290
    ERROR level. If this logger is
291
    <code>ERROR</code> enabled, it proceeds to call all the
292
    registered appenders in this logger and also higher in the
293
    hierarchy depending on the value of the additivity flag.
294
295
    @param msg the message string to log.
296
    @param location The source code location of the logging request.
297
298
    See also #LOG4CXX_ERROR.
299
    */
300
    void error(const std::wstring& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
301
#endif
302
#if LOG4CXX_UNICHAR_API
303
    /**
304
    Add a new logging event containing \c msg and \c location to attached appender(s) if this logger is enabled for <code>ERROR</code> events.
305
306
    <p>This method first checks if this logger is <code>ERROR</code>
307
    enabled by comparing the level of this logger with the
308
    ERROR level. If this logger is
309
    <code>ERROR</code> enabled, it proceeds to call all the
310
    registered appenders in this logger and also higher in the
311
    hierarchy depending on the value of the additivity flag.
312
313
    @param msg the message string to log.
314
    @param location The source code location of the logging request.
315
316
    See also #LOG4CXX_ERROR.
317
    */
318
    void error(const std::basic_string<UniChar>& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
319
    /**
320
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>ERROR</code> events.
321
322
    <p>This method first checks if this logger is <code>ERROR</code>
323
    enabled by comparing the level of this logger with the
324
    ERROR level. If this logger is
325
    <code>ERROR</code> enabled, it proceeds to call all the
326
    registered appenders in this logger and also higher in the
327
    hierarchy depending on the value of the additivity flag.
328
329
    @param msg the message string to log.
330
331
    See also #LOG4CXX_ERROR.
332
    */
333
    void error(const std::basic_string<UniChar>& msg) const;
334
#endif
335
#if LOG4CXX_CFSTRING_API
336
    /**
337
    Add a new logging event containing \c msg and \c location to attached appender(s) if this logger is enabled for <code>ERROR</code> events.
338
339
    <p>This method first checks if this logger is <code>ERROR</code>
340
    enabled by comparing the level of this logger with the
341
    ERROR level. If this logger is
342
    <code>ERROR</code> enabled, it proceeds to call all the
343
    registered appenders in this logger and also higher in the
344
    hierarchy depending on the value of the additivity flag.
345
346
    @param msg the message string to log.
347
    @param location The source code location of the logging request.
348
349
    See also #LOG4CXX_ERROR.
350
    */
351
    void error(const CFStringRef& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
352
    /**
353
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>ERROR</code> events.
354
355
    <p>This method first checks if this logger is <code>ERROR</code>
356
    enabled by comparing the level of this logger with the
357
    ERROR level. If this logger is
358
    <code>ERROR</code> enabled, it proceeds to call all the
359
    registered appenders in this logger and also higher in the
360
    hierarchy depending on the value of the additivity flag.
361
362
    @param msg the message string to log.
363
364
    See also #LOG4CXX_ERROR.
365
    */
366
    void error(const CFStringRef& msg) const;
367
#endif
368
369
    /**
370
    Add a new logging event containing \c msg and \c location to attached appender(s) if this logger is enabled for <code>FATAL</code> events.
371
372
    <p>This method first checks if this logger is <code>FATAL</code>
373
    enabled by comparing the level of this logger with the
374
    FATAL level. If this logger is
375
    <code>FATAL</code> enabled, it proceeds to call all the
376
    registered appenders in this logger and also higher in the
377
    hierarchy depending on the value of the additivity flag.
378
379
    @param msg the message string to log.
380
    @param location The source code location of the logging request.
381
382
    See also #LOG4CXX_FATAL.
383
    */
384
    void fatal(const std::string& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
385
    /**
386
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>FATAL</code> events.
387
388
    <p>This method first checks if this logger is <code>ERROR</code>
389
    enabled by comparing the level of this logger with the
390
    ERROR level. If this logger is
391
    <code>ERROR</code> enabled, it proceeds to call all the
392
    registered appenders in this logger and also higher in the
393
    hierarchy depending on the value of the additivity flag.
394
395
    @param msg the message string to log.
396
397
    See also #LOG4CXX_FATAL.
398
    */
399
    void fatal(const std::string& msg) const;
400
#if LOG4CXX_WCHAR_T_API
401
    /**
402
    Add a new logging event containing \c msg and \c location to attached appender(s) if this logger is enabled for <code>FATAL</code> events.
403
404
    <p>This method first checks if this logger is <code>ERROR</code>
405
    enabled by comparing the level of this logger with the
406
    ERROR level. If this logger is
407
    <code>ERROR</code> enabled, it proceeds to call all the
408
    registered appenders in this logger and also higher in the
409
    hierarchy depending on the value of the additivity flag.
410
411
    @param msg the message string to log.
412
    @param location The source code location of the logging request.
413
414
    See also #LOG4CXX_FATAL.
415
    */
416
    void fatal(const std::wstring& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
417
    /**
418
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>FATAL</code> events.
419
420
    <p>This method first checks if this logger is <code>ERROR</code>
421
    enabled by comparing the level of this logger with the
422
    ERROR level. If this logger is
423
    <code>ERROR</code> enabled, it proceeds to call all the
424
    registered appenders in this logger and also higher in the
425
    hierarchy depending on the value of the additivity flag.
426
427
    @param msg the message string to log.
428
429
    See also #LOG4CXX_FATAL.
430
    */
431
    void fatal(const std::wstring& msg) const;
432
#endif
433
#if LOG4CXX_UNICHAR_API
434
    /**
435
    Add a new logging event containing \c msg and \c location to attached appender(s) if this logger is enabled for <code>FATAL</code> events.
436
437
    <p>This method first checks if this logger is <code>ERROR</code>
438
    enabled by comparing the level of this logger with the
439
    ERROR level. If this logger is
440
    <code>ERROR</code> enabled, it proceeds to call all the
441
    registered appenders in this logger and also higher in the
442
    hierarchy depending on the value of the additivity flag.
443
444
    @param msg the message string to log.
445
    @param location The source code location of the logging request.
446
447
    See also #LOG4CXX_FATAL.
448
    */
449
    void fatal(const std::basic_string<UniChar>& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
450
    /**
451
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>FATAL</code> events.
452
453
    <p>This method first checks if this logger is <code>ERROR</code>
454
    enabled by comparing the level of this logger with the
455
    ERROR level. If this logger is
456
    <code>ERROR</code> enabled, it proceeds to call all the
457
    registered appenders in this logger and also higher in the
458
    hierarchy depending on the value of the additivity flag.
459
460
    @param msg the message string to log.
461
462
    See also #LOG4CXX_FATAL.
463
    */
464
    void fatal(const std::basic_string<UniChar>& msg) const;
465
#endif
466
#if LOG4CXX_CFSTRING_API
467
    /**
468
    Add a new logging event containing \c msg and \c location to attached appender(s) if this logger is enabled for <code>FATAL</code> events.
469
470
    <p>This method first checks if this logger is <code>ERROR</code>
471
    enabled by comparing the level of this logger with the
472
    ERROR level. If this logger is
473
    <code>ERROR</code> enabled, it proceeds to call all the
474
    registered appenders in this logger and also higher in the
475
    hierarchy depending on the value of the additivity flag.
476
477
    @param msg the message string to log.
478
    @param location The source code location of the logging request.
479
480
    See also #LOG4CXX_FATAL.
481
    */
482
    void fatal(const CFStringRef& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
483
    /**
484
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>FATAL</code> events.
485
486
    <p>This method first checks if this logger is <code>ERROR</code>
487
    enabled by comparing the level of this logger with the
488
    ERROR level. If this logger is
489
    <code>ERROR</code> enabled, it proceeds to call all the
490
    registered appenders in this logger and also higher in the
491
    hierarchy depending on the value of the additivity flag.
492
493
    @param msg the message string to log.
494
495
    See also #LOG4CXX_FATAL.
496
    */
497
    void fatal(const CFStringRef& msg) const;
498
#endif
499
500
    /**
501
    Add a new logging event containing \c message and \c location to attached appender(s)
502
    without further checks.
503
    @param level The logging event level.
504
    @param message The text to add to the logging event.
505
    @param location The source code location of the logging request.
506
    */
507
    void addEvent(const LevelPtr& level, std::string&& message
508
      , const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
509
510
    /**
511
    Add to attached appender(s) a new \c level LoggingEvent which was requested at \c sourceLocation where the message is built asynchronously by \c messageAppender
512
    without further checks.
513
    @param level The logging event level.
514
    @param message The text to add to the logging event.
515
    @param location The source code location of the logging request.
516
    */
517
    void addEvent(const LevelPtr& level, helpers::AsyncBuffer&& messageAppender
518
      , const spi::LocationInfo& sourceLocation = spi::LocationInfo::getLocationUnavailable()) const;
519
520
    /**
521
    Add a new fatal level logging event containing \c message and \c location to attached appender(s)
522
    without further checks.
523
    @param message The text to add to the logging event.
524
    @param location The source code location of the logging request.
525
    */
526
    void addFatalEvent(std::string&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
527
528
    /**
529
    Add to attached appender(s) a new FATAL level LoggingEvent which was requested at \c sourceLocation where the message is built asynchronously by \c messageAppender
530
    without further checks.
531
    @param message The text to add to the logging event.
532
    @param location The source code location of the logging request.
533
    */
534
    void addFatalEvent(helpers::AsyncBuffer&& messageAppender, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
535
536
    /**
537
    Add a new error level logging event containing \c message and \c location to attached appender(s)
538
    without further checks.
539
    @param message The text to add to the logging event.
540
    @param location The source code location of the logging request.
541
    */
542
    void addErrorEvent(std::string&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
543
544
    /**
545
    Add to attached appender(s) a new ERROR level LoggingEvent which was requested at \c sourceLocation where the message is built asynchronously by \c messageAppender
546
    without further checks.
547
    @param message The text to add to the logging event.
548
    @param location The source code location of the logging request.
549
    */
550
    void addErrorEvent(helpers::AsyncBuffer&& messageAppender, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
551
552
    /**
553
    Add a new warning level logging event containing \c message and \c location to attached appender(s)
554
    without further checks.
555
    @param message The text to add to the logging event.
556
    @param location The source code location of the logging request.
557
    */
558
    void addWarnEvent(std::string&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
559
560
    /**
561
    Add to attached appender(s) a new WARN level LoggingEvent which was requested at \c sourceLocation where the message is built asynchronously by \c messageAppender
562
    without further checks.
563
    @param message The text to add to the logging event.
564
    @param location The source code location of the logging request.
565
    */
566
    void addWarnEvent(helpers::AsyncBuffer&& messageAppender, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
567
568
    /**
569
    Add a new info level logging event containing \c message and \c location to attached appender(s)
570
    without further checks.
571
    @param message The text to add to the logging event.
572
    @param location The source code location of the logging request.
573
    */
574
    void addInfoEvent(std::string&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
575
576
    /**
577
    Add to attached appender(s) a new INFO level LoggingEvent which was requested at \c sourceLocation where the message is built asynchronously by \c messageAppender
578
    without further checks.
579
    @param message The text to add to the logging event.
580
    @param location The source code location of the logging request.
581
    */
582
    void addInfoEvent(helpers::AsyncBuffer&& messageAppender, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
583
584
    /**
585
    Add a new debug level logging event containing \c message and \c location to attached appender(s)
586
    without further checks.
587
    @param message The text to add to the logging event.
588
    @param location The source code location of the logging request.
589
    */
590
    void addDebugEvent(std::string&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
591
592
    /**
593
    Add to attached appender(s) a new DEBUG level LoggingEvent which was requested at \c sourceLocation where the message is built asynchronously by \c messageAppender
594
    without further checks.
595
    @param message The text to add to the logging event.
596
    @param location The source code location of the logging request.
597
    */
598
    void addDebugEvent(helpers::AsyncBuffer&& messageAppender, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
599
600
    /**
601
    Add a new trace level logging event containing \c message and \c location to attached appender(s)
602
    without further checks.
603
    @param message The text to add to the logging event.
604
    @param location The source code location of the logging request.
605
    */
606
    void addTraceEvent(std::string&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
607
608
    /**
609
    Add to attached appender(s) a new TRACE level LoggingEvent which was requested at \c sourceLocation where the message is built asynchronously by \c messageAppender
610
    without further checks.
611
    @param message The text to add to the logging event.
612
    @param location The source code location of the logging request.
613
    */
614
    void addTraceEvent(helpers::AsyncBuffer&& messageAppender, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
615
616
    /**
617
    Add a new logging event containing \c message and \c location to attached appender(s)
618
    without further checks.
619
    @param level The logging event level.
620
    @param message The text to add to the logging event.
621
    @param location The source code location of the logging request.
622
    */
623
    void forcedLog(const LevelPtr& level, const std::string& message,
624
      const LOG4CXX_NS::spi::LocationInfo& location) const;
625
    /**
626
    Add a new logging event containing \c message to attached appender(s)
627
    without further checks.
628
    @param level The logging event level.
629
    @param message The text to add to the logging event.
630
    */
631
    void forcedLog(const LevelPtr& level, const std::string& message) const;
632
633
#if LOG4CXX_WCHAR_T_API
634
    /**
635
    Add a new logging event containing \c message and \c location to attached appender(s)
636
    without further checks.
637
    @param level The logging event level.
638
    @param message The text to add to the logging event.
639
    @param location The source code location of the logging request.
640
    */
641
    void addEvent(const LevelPtr& level, std::wstring&& message
642
      , const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
643
644
    /**
645
    Add a new fatal level logging event containing \c message and \c location to attached appender(s)
646
    without further checks.
647
    @param message The text to add to the logging event.
648
    @param location The source code location of the logging request.
649
    */
650
    void addFatalEvent(std::wstring&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
651
652
    /**
653
    Add a new error level logging event containing \c message and \c location to attached appender(s)
654
    without further checks.
655
    @param message The text to add to the logging event.
656
    @param location The source code location of the logging request.
657
    */
658
    void addErrorEvent(std::wstring&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
659
660
    /**
661
    Add a new warning level logging event containing \c message and \c location to attached appender(s)
662
    without further checks.
663
    @param message The text to add to the logging event.
664
    @param location The source code location of the logging request.
665
    */
666
    void addWarnEvent(std::wstring&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
667
668
    /**
669
    Add a new info level logging event containing \c message and \c location to attached appender(s)
670
    without further checks.
671
    @param message The text to add to the logging event.
672
    @param location The source code location of the logging request.
673
    */
674
    void addInfoEvent(std::wstring&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
675
676
    /**
677
    Add a new debug level logging event containing \c message and \c location to attached appender(s)
678
    without further checks.
679
    @param message The text to add to the logging event.
680
    @param location The source code location of the logging request.
681
    */
682
    void addDebugEvent(std::wstring&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
683
684
    /**
685
    Add a new trace level logging event containing \c message and \c location to attached appender(s)
686
    without further checks.
687
    @param message The text to add to the logging event.
688
    @param location The source code location of the logging request.
689
    */
690
    void addTraceEvent(std::wstring&& message, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
691
692
    /**
693
    Add a new logging event containing \c message and \c location to attached appender(s)
694
    without further checks.
695
    @param level The logging event level.
696
    @param message The text to add to the logging event.
697
    @param location The source code location of the logging request.
698
    */
699
    void forcedLog(const LevelPtr& level, const std::wstring& message,
700
      const LOG4CXX_NS::spi::LocationInfo& location) const;
701
    /**
702
    Add a new logging event containing \c message to attached appender(s)
703
    without further checks.
704
    @param level The logging event level.
705
    @param message The text to add to the logging event.
706
    */
707
    void forcedLog(const LevelPtr& level, const std::wstring& message) const;
708
#endif
709
#if LOG4CXX_UNICHAR_API
710
    /**
711
    Add a new logging event containing \c message and \c location to attached appender(s)
712
    without further checks.
713
    @param level The logging event level.
714
    @param message The text to add to the logging event.
715
    @param location The source code location of the logging request.
716
    */
717
    void addEvent(const LevelPtr& level, std::basic_string<UniChar>&& message,
718
      const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
719
    /**
720
    Add a new fatal level logging event containing \c message and \c location to attached appender(s)
721
    without further checks.
722
    @param message The text to add to the logging event.
723
    @param location The source code location of the logging request.
724
    */
725
    void addFatalEvent(std::basic_string<UniChar>&& message,const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
726
    /**
727
    Add a new error level logging event containing \c message and \c location to attached appender(s)
728
    without further checks.
729
    @param message The text to add to the logging event.
730
    @param location The source code location of the logging request.
731
    */
732
    void addErrorEvent(std::basic_string<UniChar>&& message,const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
733
    /**
734
    Add a new warning level logging event containing \c message and \c location to attached appender(s)
735
    without further checks.
736
    @param message The text to add to the logging event.
737
    @param location The source code location of the logging request.
738
    */
739
    void addWarnEvent(std::basic_string<UniChar>&& message,const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
740
    /**
741
    Add a new info level logging event containing \c message and \c location to attached appender(s)
742
    without further checks.
743
    @param message The text to add to the logging event.
744
    @param location The source code location of the logging request.
745
    */
746
    void addInfoEvent(std::basic_string<UniChar>&& message,const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
747
    /**
748
    Add a new debug level logging event containing \c message and \c location to attached appender(s)
749
    without further checks.
750
    @param message The text to add to the logging event.
751
    @param location The source code location of the logging request.
752
    */
753
    void addDebugEvent(std::basic_string<UniChar>&& message,const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
754
    /**
755
    Add a new trace level logging event containing \c message and \c location to attached appender(s)
756
    without further checks.
757
    @param message The text to add to the logging event.
758
    @param location The source code location of the logging request.
759
    */
760
    void addTraceEvent(std::basic_string<UniChar>&& message,const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
761
762
    /**
763
    Add a new logging event containing \c message and \c location to attached appender(s)
764
    without further checks.
765
    @param level The logging event level.
766
    @param message The text to add to the logging event.
767
    @param location The source code location of the logging request.
768
    */
769
    void forcedLog(const LevelPtr& level, const std::basic_string<UniChar>& message,
770
      const LOG4CXX_NS::spi::LocationInfo& location) const;
771
    /**
772
    Add a new logging event containing \c message to attached appender(s)
773
    without further checks.
774
    @param level The logging event level.
775
    @param message The text to add to the logging event.
776
    */
777
    void forcedLog(const LevelPtr& level, const std::basic_string<UniChar>& message) const;
778
#endif
779
#if LOG4CXX_CFSTRING_API
780
    /**
781
    Add a new logging event containing \c message and \c location to attached appender(s)
782
    without further checks.
783
    @param level The logging event level.
784
    @param message The text to add to the logging event.
785
    @param location The source code location of the logging request.
786
    */
787
    void forcedLog(const LevelPtr& level, const CFStringRef& message,
788
      const LOG4CXX_NS::spi::LocationInfo& location) const;
789
    /**
790
    Add a new logging event containing \c message to attached appender(s)
791
    without further checks.
792
    @param level The logging event level.
793
    @param message The text to add to the logging event.
794
    */
795
    void forcedLog(const LevelPtr& level, const CFStringRef& message) const;
796
#endif
797
    /**
798
    Add a new logging event containing \c message and \c location to attached appender(s)
799
    without further checks.
800
    @param level The logging event level.
801
    @param message the message string to log.
802
    @param location location of the logging statement.
803
    */
804
    void addEventLS(const LevelPtr& level, LogString&& message
805
      , const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
806
807
    /**
808
    Add a new logging event containing \c message and \c location to attached appender(s)
809
    without further checks.
810
    @param level The logging event level.
811
    @param message the message string to log.
812
    @param location location of the logging statement.
813
    */
814
    void forcedLogLS(const LevelPtr& level, const LogString& message,
815
      const LOG4CXX_NS::spi::LocationInfo& location) const;
816
817
    /**
818
    Get the additivity flag for this logger.
819
    */
820
    bool getAdditivity() const;
821
822
    /**
823
    Get the appenders contained in this logger as an AppenderList.
824
    If no appenders can be found, then an empty AppenderList
825
    is returned.
826
    @return AppenderList An collection of the appenders in this logger.*/
827
    AppenderList getAllAppenders() const override;
828
829
    /**
830
    Look for the appender named as <code>name</code>.
831
    <p>Return the appender with that name if in the list. Return
832
    <code>NULL</code> otherwise.  */
833
    AppenderPtr getAppender(const LogString& name) const override;
834
835
    /**
836
    Starting from this logger, search the logger hierarchy for a
837
    non-null level and return it.
838
839
    <p>The Logger class is designed so that this method executes as
840
    quickly as possible.
841
842
    @throws RuntimeException if all levels are null in the hierarchy
843
    */
844
    virtual const LevelPtr& getEffectiveLevel() const;
845
846
#if LOG4CXX_ABI_VERSION <= 15
847
    /**
848
    Return the the LoggerRepository where this
849
    <code>Logger</code> is attached.
850
    */
851
    spi::LoggerRepository* getLoggerRepository() const;
852
#endif
853
854
    /**
855
    * Get the logger name.
856
    * @return logger name as LogString.
857
    */
858
    const LogString& getName() const;
859
860
    /**
861
    * Put name of this logger into \c name in current encoding.
862
    * @param name buffer to which name is appended.
863
    */
864
    void getName(std::string& name) const;
865
#if LOG4CXX_WCHAR_T_API
866
    /**
867
    * Put name of this logger into \c name.
868
    * @param name buffer to which name is appended.
869
    */
870
    void getName(std::wstring& name) const;
871
#endif
872
#if LOG4CXX_UNICHAR_API
873
    /**
874
    * Put name of this logger into \c name.
875
    * @param name buffer to which name is appended.
876
    */
877
    void getName(std::basic_string<UniChar>& name) const;
878
#endif
879
#if LOG4CXX_CFSTRING_API
880
    /**
881
    * Put name of this logger into \c name.
882
    * @param name buffer to which name is appended.
883
    */
884
    void getName(CFStringRef& name) const;
885
#endif
886
887
    /**
888
    The parent of this logger. Note that the parent of a
889
    given logger may change during the lifetime of the logger.
890
891
    <p>The root logger will return <code>0</code>.
892
    */
893
    LoggerPtr getParent() const;
894
895
896
    /**
897
    The assigned Level, if any, for this logger.
898
899
    @return Level - the assigned Level, can be null.
900
    */
901
    const LevelPtr& getLevel() const;
902
903
#if 15 < LOG4CXX_ABI_VERSION
904
    /**
905
    The object that holds all Logger instances.
906
    */
907
    static spi::LoggerRepositoryPtr getLoggerRepository();
908
#endif
909
910
    /**
911
    * Retrieve a logger by name in current encoding.
912
    * @param name logger name.
913
    */
914
    static LoggerPtr getLogger(const std::string& name);
915
    /**
916
    * Retrieve a logger by name in current encoding.
917
    * @param name logger name.
918
    */
919
    static LoggerPtr getLogger(const char* const name);
920
#if LOG4CXX_WCHAR_T_API
921
    /**
922
    * Retrieve a logger by name.
923
    * @param name logger name.
924
    */
925
    static LoggerPtr getLogger(const std::wstring& name);
926
    /**
927
    * Retrieve a logger by name.
928
    * @param name logger name.
929
    */
930
    static LoggerPtr getLogger(const wchar_t* const name);
931
#endif
932
#if LOG4CXX_UNICHAR_API
933
    /**
934
    * Retrieve a logger by name.
935
    * @param name logger name.
936
    */
937
    static LoggerPtr getLogger(const std::basic_string<UniChar>& name);
938
#endif
939
#if LOG4CXX_CFSTRING_API
940
    /**
941
    * Retrieve a logger by name.
942
    * @param name logger name.
943
    */
944
    static LoggerPtr getLogger(const CFStringRef& name);
945
#endif
946
    /**
947
    * Retrieve a logger by name in Unicode.
948
    * @param name logger name.
949
    */
950
    static LoggerPtr getLoggerLS(const LogString& name);
951
952
    /**
953
    Retrieve the root logger.
954
    */
955
    static LoggerPtr getRootLogger();
956
957
    /**
958
    Like #getLogger except that the type of logger
959
    instantiated depends on the type returned by the
960
    LoggerFactory#makeNewLoggerInstance method of the
961
    <code>factory</code> parameter.
962
963
    <p>This method is intended to be used by sub-classes.
964
965
    @param name The name of the logger to retrieve.
966
967
    @param factory A LoggerFactory implementation that will
968
    actually create a new Instance.
969
    */
970
    static LoggerPtr getLoggerLS(const LogString& name,
971
      const LOG4CXX_NS::spi::LoggerFactoryPtr& factory);
972
    /**
973
    Like #getLogger except that the type of logger
974
    instantiated depends on the type returned by the
975
    LoggerFactory#makeNewLoggerInstance method of the
976
    <code>factory</code> parameter.
977
978
    <p>This method is intended to be used by sub-classes.
979
980
    @param name The name of the logger to retrieve.
981
982
    @param factory A LoggerFactory implementation that will
983
    actually create a new Instance.
984
    */
985
    static LoggerPtr getLogger(const std::string& name,
986
      const LOG4CXX_NS::spi::LoggerFactoryPtr& factory);
987
#if LOG4CXX_WCHAR_T_API
988
    /**
989
    Like #getLogger except that the type of logger
990
    instantiated depends on the type returned by the
991
    LoggerFactory#makeNewLoggerInstance method of the
992
    <code>factory</code> parameter.
993
994
    <p>This method is intended to be used by sub-classes.
995
996
    @param name The name of the logger to retrieve.
997
998
    @param factory A LoggerFactory implementation that will
999
    actually create a new Instance.
1000
    */
1001
    static LoggerPtr getLogger(const std::wstring& name,
1002
      const LOG4CXX_NS::spi::LoggerFactoryPtr& factory);
1003
#endif
1004
#if LOG4CXX_UNICHAR_API
1005
    /**
1006
    Like #getLogger except that the type of logger
1007
    instantiated depends on the type returned by the
1008
    LoggerFactory#makeNewLoggerInstance method of the
1009
    <code>factory</code> parameter.
1010
1011
    <p>This method is intended to be used by sub-classes.
1012
1013
    @param name The name of the logger to retrieve.
1014
1015
    @param factory A LoggerFactory implementation that will
1016
    actually create a new Instance.
1017
    */
1018
    static LoggerPtr getLogger(const std::basic_string<UniChar>& name,
1019
      const LOG4CXX_NS::spi::LoggerFactoryPtr& factory);
1020
#endif
1021
#if LOG4CXX_CFSTRING_API
1022
    /**
1023
    Like #getLogger except that the type of logger
1024
    instantiated depends on the type returned by the
1025
    LoggerFactory#makeNewLoggerInstance method of the
1026
    <code>factory</code> parameter.
1027
1028
    <p>This method is intended to be used by sub-classes.
1029
1030
    @param name The name of the logger to retrieve.
1031
1032
    @param factory A LoggerFactory implementation that will
1033
    actually create a new Instance.
1034
    */
1035
    static LoggerPtr getLogger(const CFStringRef& name,
1036
      const LOG4CXX_NS::spi::LoggerFactoryPtr& factory);
1037
#endif
1038
1039
    /**
1040
    Return the <em>inherited</em> ResourceBundle for this logger.
1041
1042
1043
    This method walks the hierarchy to find the appropriate resource bundle.
1044
    It will return the resource bundle attached to the closest ancestor of
1045
    this logger, much like the way priorities are searched. In case there
1046
    is no bundle in the hierarchy then <code>NULL</code> is returned.
1047
    */
1048
    helpers::ResourceBundlePtr getResourceBundle() const;
1049
1050
  protected:
1051
    /**
1052
    Returns the string resource corresponding to <code>key</code> in this
1053
    logger's inherited resource bundle.
1054
1055
    If the resource cannot be found, then an {@link #error error} message
1056
    will be logged complaining about the missing resource.
1057
1058
    @see #getResourceBundle.
1059
    */
1060
    LogString getResourceBundleString(const LogString& key) const;
1061
1062
  public:
1063
    /**
1064
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>INFO</code> events.
1065
1066
    <p>This method first checks if this logger is <code>INFO</code>
1067
    enabled by comparing the level of this logger with the
1068
    INFO level. If this logger is
1069
    <code>INFO</code> enabled, it proceeds to call all the
1070
    registered appenders in this logger and also higher in the
1071
    hierarchy depending on the value of the additivity flag.
1072
1073
    @param msg the message string to log.
1074
    @param location The source code location of the logging request.
1075
1076
    See also #LOG4CXX_INFO.
1077
    */
1078
    void info(const std::string& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
1079
    /**
1080
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>INFO</code> events.
1081
1082
    <p>This method first checks if this logger is <code>INFO</code>
1083
    enabled by comparing the level of this logger with the
1084
    INFO level. If this logger is
1085
    <code>INFO</code> enabled, it proceeds to call all the
1086
    registered appenders in this logger and also higher in the
1087
    hierarchy depending on the value of the additivity flag.
1088
1089
    @param msg the message string to log.
1090
1091
    See also #LOG4CXX_INFO.
1092
    */
1093
    void info(const std::string& msg) const;
1094
#if LOG4CXX_WCHAR_T_API
1095
    /**
1096
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>INFO</code> events.
1097
1098
    <p>This method first checks if this logger is <code>INFO</code>
1099
    enabled by comparing the level of this logger with the
1100
    INFO level. If this logger is
1101
    <code>INFO</code> enabled, it proceeds to call all the
1102
    registered appenders in this logger and also higher in the
1103
    hierarchy depending on the value of the additivity flag.
1104
1105
    @param msg the message string to log.
1106
    @param location The source code location of the logging request.
1107
1108
    See also #LOG4CXX_INFO.
1109
    */
1110
    void info(const std::wstring& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
1111
    /**
1112
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>INFO</code> events.
1113
1114
    <p>This method first checks if this logger is <code>INFO</code>
1115
    enabled by comparing the level of this logger with the
1116
    INFO level. If this logger is
1117
    <code>INFO</code> enabled, it proceeds to call all the
1118
    registered appenders in this logger and also higher in the
1119
    hierarchy depending on the value of the additivity flag.
1120
1121
    @param msg the message string to log.
1122
1123
    See also #LOG4CXX_INFO.
1124
    */
1125
    void info(const std::wstring& msg) const;
1126
#endif
1127
#if LOG4CXX_UNICHAR_API
1128
    /**
1129
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>INFO</code> events.
1130
1131
    <p>This method first checks if this logger is <code>INFO</code>
1132
    enabled by comparing the level of this logger with the
1133
    INFO level. If this logger is
1134
    <code>INFO</code> enabled, it proceeds to call all the
1135
    registered appenders in this logger and also higher in the
1136
    hierarchy depending on the value of the additivity flag.
1137
1138
    @param msg the message string to log.
1139
    @param location The source code location of the logging request.
1140
            */
1141
    void info(const std::basic_string<UniChar>& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
1142
    /**
1143
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>INFO</code> events.
1144
1145
    <p>This method first checks if this logger is <code>INFO</code>
1146
    enabled by comparing the level of this logger with the
1147
    INFO level. If this logger is
1148
    <code>INFO</code> enabled, it proceeds to call all the
1149
    registered appenders in this logger and also higher in the
1150
    hierarchy depending on the value of the additivity flag.
1151
1152
    @param msg the message string to log.
1153
1154
    See also #LOG4CXX_INFO.
1155
    */
1156
    void info(const std::basic_string<UniChar>& msg) const;
1157
#endif
1158
#if LOG4CXX_CFSTRING_API
1159
    /**
1160
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>INFO</code> events.
1161
1162
    <p>This method first checks if this logger is <code>INFO</code>
1163
    enabled by comparing the level of this logger with the
1164
    INFO level. If this logger is
1165
    <code>INFO</code> enabled, it proceeds to call all the
1166
    registered appenders in this logger and also higher in the
1167
    hierarchy depending on the value of the additivity flag.
1168
1169
    @param msg the message string to log.
1170
    @param location The source code location of the logging request.
1171
1172
    See also #LOG4CXX_INFO.
1173
    */
1174
    void info(const CFStringRef& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
1175
    /**
1176
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>INFO</code> events.
1177
1178
    <p>This method first checks if this logger is <code>INFO</code>
1179
    enabled by comparing the level of this logger with the
1180
    INFO level. If this logger is
1181
    <code>INFO</code> enabled, it proceeds to call all the
1182
    registered appenders in this logger and also higher in the
1183
    hierarchy depending on the value of the additivity flag.
1184
1185
    @param msg the message string to log.
1186
1187
    See also #LOG4CXX_INFO.
1188
    */
1189
    void info(const CFStringRef& msg) const;
1190
#endif
1191
1192
    /**
1193
    Is \c appender attached to this logger?
1194
    */
1195
    bool isAttached(const AppenderPtr appender) const override;
1196
1197
    /**
1198
     *  Is this logger is enabled for <code>DEBUG</code> level logging events?
1199
     *
1200
     *  <p>By writing
1201
     *  ~~~{.cpp}
1202
     *  if(logger->isDebugEnabled()) {
1203
     *      logger->debug("Component: " + std::to_string(componentNumber));
1204
     *    }
1205
     *  ~~~
1206
     *  you will not incur the cost of parameter construction
1207
     *  (integer to string conversion plus string concatonation in this case)
1208
     *  if debugging is disabled for <code>logger</code>.
1209
     *  You avoid the cost constructing the message
1210
     *  when the message is not logged.
1211
     *
1212
     *  <p>This function allows you to reduce the computational cost of
1213
     *  disabled log debug statements compared to writing:
1214
     *  ~~~{.cpp}
1215
     *      logger->debug("Component: " + std::to_string(componentNumber));
1216
     *  ~~~
1217
     *
1218
     *  <p>On the other hand, if the <code>logger</code> is enabled for <code>DEBUG</code> logging events,
1219
     *  you will incur the cost of evaluating whether the logger is
1220
     *  enabled twice, once in <code>isDebugEnabled</code> and once in
1221
     *  the <code>DEBUG</code>.  This really is an insignificant overhead
1222
     *  since evaluating a the enabled status takes about 1% of the time it
1223
     *  takes to send the message to the appender.
1224
1225
     * See also #isDebugEnabledFor.
1226
     * See also #LOG4CXX_DEBUG.
1227
     *
1228
     *  @return bool - <code>true</code> if this logger is debug
1229
     *  enabled, <code>false</code> otherwise.
1230
     **/
1231
    bool isDebugEnabled() const;
1232
1233
    /**
1234
     *  Is \c logger is enabled for <code>DEBUG</code> level logging events?
1235
     *
1236
     *  <p>By writing
1237
     *  ~~~{.cpp}
1238
     *    if(log4cxx::Logger::isDebugEnabledFor(logger)) {
1239
     *      logger->addDebugEvent("Component: " + std::to_string(componentNumber));
1240
     *    }
1241
     *  ~~~
1242
     *  you minimise the computational cost
1243
     *  when \c logger is not enabled for <code>DEBUG</code> logging events.
1244
     *  This function may be inlined thereby avoiding a function call
1245
     *  as well as the cost constructing the message
1246
     *  when \c logger is not enabled for <code>DEBUG</code> events.
1247
     *
1248
     * See also #LOG4CXX_DEBUG.
1249
     *
1250
     *  @return bool - <code>false</code> if \c logger is <code>null</code>
1251
     *  or <code>DEBUG</code> logging events are disabled for \c logger,
1252
     *  <code>true</code> otherwise.
1253
     **/
1254
    inline static bool isDebugEnabledFor(const LoggerPtr& logger)
1255
0
    {
1256
0
      return logger && logger->m_threshold <= Level::DEBUG_INT && logger->isDebugEnabled();
1257
0
    }
1258
1259
    /**
1260
    Is this logger is enabled for logging events at \c level?
1261
1262
    @return bool True if this logger is enabled for <code>level</code> logging events.
1263
    */
1264
    bool isEnabledFor(const LevelPtr& level) const;
1265
1266
1267
    /**
1268
    Is this logger is enabled for <code>INFO</code> level logging events?
1269
1270
    See #isDebugEnabled.
1271
    See also #LOG4CXX_INFO.
1272
1273
    @return bool - <code>true</code> if this logger is enabled
1274
    for level info, <code>false</code> otherwise.
1275
    */
1276
    bool isInfoEnabled() const;
1277
1278
    /**
1279
    Is \c logger is enabled for <code>INFO</code> level logging events?
1280
1281
    See #isDebugEnabledFor.
1282
    See also #LOG4CXX_INFO.
1283
1284
    @return bool - <code>false</code> if \c logger is <code>null</code>
1285
    or <code>INFO</code> logging events are disabled for \c logger,
1286
    <code>true</code> otherwise.
1287
    */
1288
    inline static bool isInfoEnabledFor(const LoggerPtr& logger)
1289
44.8k
    {
1290
44.8k
      return logger && logger->m_threshold <= Level::INFO_INT && logger->isInfoEnabled();
1291
44.8k
    }
1292
1293
    /**
1294
    Is this logger is enabled for <code>WARN</code> level logging events?
1295
1296
    See also #isDebugEnabled.
1297
    See also #LOG4CXX_WARN.
1298
1299
    @return bool - <code>true</code> if this logger is enabled
1300
    for level warn, <code>false</code> otherwise.
1301
    */
1302
    bool isWarnEnabled() const;
1303
1304
    /**
1305
    Is \c logger is enabled for <code>WARN</code> level logging events?
1306
1307
    See #isDebugEnabledFor.
1308
    See also #LOG4CXX_WARN.
1309
1310
    @return bool - <code>false</code> if \c logger is <code>null</code>
1311
    or <code>WARN</code> logging events are disabled for \c logger,
1312
    <code>true</code> otherwise.
1313
    */
1314
    inline static bool isWarnEnabledFor(const LoggerPtr& logger)
1315
0
    {
1316
0
      return logger && logger->m_threshold <= Level::WARN_INT && logger->isWarnEnabled();
1317
0
    }
1318
1319
    /**
1320
    Is this logger is enabled for <code>ERROR</code> level logging events?
1321
1322
    See also #isDebugEnabled.
1323
    See also #LOG4CXX_ERROR.
1324
1325
    @return bool - <code>true</code> if this logger is enabled
1326
    for level error, <code>false</code> otherwise.
1327
    */
1328
    bool isErrorEnabled() const;
1329
1330
    /**
1331
    Is \c logger is enabled for <code>ERROR</code> level logging events?
1332
1333
    See #isDebugEnabledFor.
1334
    See also #LOG4CXX_ERROR.
1335
1336
    @return bool - <code>false</code> if \c logger is <code>null</code>
1337
    or <code>ERROR</code> logging events are disabled for \c logger,
1338
    <code>true</code> otherwise.
1339
    */
1340
    inline static bool isErrorEnabledFor(const LoggerPtr& logger)
1341
0
    {
1342
0
      return logger && logger->m_threshold <= Level::ERROR_INT && logger->isErrorEnabled();
1343
0
    }
1344
1345
    /**
1346
    Is this logger is enabled for <code>FATAL</code> level logging events?
1347
1348
    See also #isDebugEnabled.
1349
    See also #LOG4CXX_FATAL.
1350
1351
    @return bool - <code>true</code> if this logger is enabled
1352
    for level fatal, <code>false</code> otherwise.
1353
    */
1354
    bool isFatalEnabled() const;
1355
1356
    /**
1357
    Is \c logger is enabled for <code>FATAL</code> level logging events?
1358
1359
    See #isDebugEnabledFor.
1360
    See also #LOG4CXX_FATAL.
1361
1362
    @return bool - <code>false</code> if \c logger is <code>null</code>
1363
    or <code>FATAL</code> logging events are disabled for \c logger,
1364
    <code>true</code> otherwise.
1365
    */
1366
    inline static bool isFatalEnabledFor(const LoggerPtr& logger)
1367
0
    {
1368
0
      return logger && logger->m_threshold <= Level::FATAL_INT && logger->isFatalEnabled();
1369
0
    }
1370
1371
    /**
1372
    Is this logger is enabled for <code>TRACE</code> level logging events?
1373
1374
    See also #isDebugEnabled.
1375
    See also #LOG4CXX_FATAL.
1376
1377
    @return bool - <code>true</code> if this logger is enabled
1378
    for level trace, <code>false</code> otherwise.
1379
    */
1380
    bool isTraceEnabled() const;
1381
1382
    /**
1383
    Is \c logger is enabled for <code>TRACE</code> level logging events?
1384
1385
    See #isDebugEnabledFor.
1386
    See also #LOG4CXX_TRACE.
1387
1388
    @return bool - <code>false</code> if \c logger is <code>null</code>
1389
    or <code>TRACE</code> logging events are disabled for \c logger,
1390
    <code>true</code> otherwise.
1391
    */
1392
    inline static bool isTraceEnabledFor(const LoggerPtr& logger)
1393
0
    {
1394
0
      return logger && logger->m_threshold <= Level::TRACE_INT && logger->isTraceEnabled();
1395
0
    }
1396
1397
    /**
1398
    Add a new logging event containing \c locationInfo and the localized message \c key using \c values for parameter substitution
1399
    to attached appender(s) if this logger is enabled for \c level events.
1400
1401
    First, the user supplied
1402
    <code>key</code> is searched in the resource bundle. Next, the resulting
1403
    pattern is formatted using helpers::StringHelper::format method.
1404
1405
    @param level The level of the logging request.
1406
    @param key The key to be searched in the ResourceBundle.
1407
    @param locationInfo The location info of the logging request.
1408
    @param values The values for the placeholders <code>{0}</code>,
1409
                  <code>{1}</code> etc. within the pattern.
1410
1411
    @see #setResourceBundle
1412
1413
    See also #LOG4CXX_L7DLOG1.
1414
    */
1415
    void l7dlog(const LevelPtr& level, const LogString& key,
1416
      const LOG4CXX_NS::spi::LocationInfo& locationInfo,
1417
      const std::vector<LogString>& values) const;
1418
    /**
1419
    Add a new logging event containing \c locationInfo and the localized message \c key to attached appender(s) if this logger is enabled for \c level events.
1420
1421
    First, the user supplied
1422
    <code>key</code> is searched in the resource bundle. Next, the resulting
1423
    pattern is formatted using helpers::StringHelper::format method.
1424
1425
    @param level The level of the logging request.
1426
    @param key The key to be searched in the ResourceBundle.
1427
    @param locationInfo The location info of the logging request.
1428
1429
    @see #setResourceBundle
1430
1431
    See also #LOG4CXX_L7DLOG.
1432
    */
1433
    void l7dlog(const LevelPtr& level, const std::string& key,
1434
      const LOG4CXX_NS::spi::LocationInfo& locationInfo) const;
1435
    /**
1436
    Add a new logging event containing \c locationInfo and the localized message \c key using parameter \c val to attached appender(s) if this logger is enabled for \c level events.
1437
1438
    First, the user supplied
1439
    <code>key</code> is searched in the resource bundle. Next, the resulting
1440
    pattern is formatted using helpers::StringHelper::format method with the
1441
    supplied parameters in a string array.
1442
1443
    @param level The level of the logging request.
1444
    @param key The key to be searched in the ResourceBundle.
1445
    @param locationInfo The location info of the logging request.
1446
    @param val The first value for the placeholders within the pattern.
1447
1448
    @see #setResourceBundle
1449
1450
    See also #LOG4CXX_L7DLOG1.
1451
    */
1452
    void l7dlog(const LevelPtr& level, const std::string& key,
1453
      const LOG4CXX_NS::spi::LocationInfo& locationInfo,
1454
      const std::string& val) const;
1455
    /**
1456
    Add a new logging event containing \c locationInfo and the localized message \c key using parameters \c val1 and \c val2 to attached appender(s) if this logger is enabled for \c level events.
1457
1458
    First, the user supplied
1459
    <code>key</code> is searched in the resource bundle. Next, the resulting
1460
    pattern is formatted using helpers::StringHelper::format method with the
1461
    supplied parameters in a string array.
1462
1463
    @param level The level of the logging request.
1464
    @param key The key to be searched in the ResourceBundle.
1465
    @param locationInfo The location info of the logging request.
1466
    @param val1 The first value for the placeholders within the pattern.
1467
    @param val2 The second value for the placeholders within the pattern.
1468
1469
    @see #setResourceBundle
1470
1471
    See also #LOG4CXX_L7DLOG2.
1472
    */
1473
    void l7dlog(const LevelPtr& level, const std::string& key,
1474
      const LOG4CXX_NS::spi::LocationInfo& locationInfo,
1475
      const std::string& val1, const std::string& val2) const;
1476
    /**
1477
    Add a new logging event containing \c locationInfo and the localized message \c key using parameters \c val1, \c val2 and \c val3 to attached appender(s) if this logger is enabled for \c level events.
1478
1479
    First, the user supplied
1480
    <code>key</code> is searched in the resource bundle. Next, the resulting
1481
    pattern is formatted using helpers::StringHelper::format method with the
1482
    supplied parameters in a string array.
1483
1484
    @param level The level of the logging request.
1485
    @param key The key to be searched in the ResourceBundle.
1486
    @param locationInfo The location info of the logging request.
1487
    @param val1 The value for the first placeholder within the pattern.
1488
    @param val2 The value for the second placeholder within the pattern.
1489
    @param val3 The value for the third placeholder within the pattern.
1490
1491
    @see #setResourceBundle
1492
1493
    See also #LOG4CXX_L7DLOG3.
1494
    */
1495
    void l7dlog(const LevelPtr& level, const std::string& key,
1496
      const LOG4CXX_NS::spi::LocationInfo& locationInfo,
1497
      const std::string& val1, const std::string& val2, const std::string& val3) const;
1498
1499
#if LOG4CXX_WCHAR_T_API
1500
    /**
1501
    Add a new logging event containing \c locationInfo and the localized message \c key to attached appender(s) if this logger is enabled for \c level events.
1502
1503
    First, the user supplied
1504
    <code>key</code> is searched in the resource bundle. Next, the resulting
1505
    pattern is formatted using helpers::StringHelper::format method .
1506
1507
    @param level The level of the logging request.
1508
    @param key The key to be searched in the ResourceBundle.
1509
    @param locationInfo The location info of the logging request.
1510
1511
    @see #setResourceBundle
1512
1513
    See also #LOG4CXX_L7DLOG.
1514
    */
1515
    void l7dlog(const LevelPtr& level, const std::wstring& key,
1516
      const LOG4CXX_NS::spi::LocationInfo& locationInfo) const;
1517
    /**
1518
    Add a new logging event containing \c locationInfo and the localized message \c key using parameter \c val to attached appender(s) if this logger is enabled for \c level events.
1519
1520
    First, the user supplied
1521
    <code>key</code> is searched in the resource bundle. Next, the resulting
1522
    pattern is formatted using helpers::StringHelper::format method with the
1523
    supplied parameter in a string array.
1524
1525
    @param level The level of the logging request.
1526
    @param key The key to be searched in the ResourceBundle.
1527
    @param locationInfo The location info of the logging request.
1528
    @param val The value for the first placeholder within the pattern.
1529
1530
    @see #setResourceBundle
1531
1532
    See also #LOG4CXX_L7DLOG1.
1533
    */
1534
    void l7dlog(const LevelPtr& level, const std::wstring& key,
1535
      const LOG4CXX_NS::spi::LocationInfo& locationInfo,
1536
      const std::wstring& val) const;
1537
    /**
1538
    Add a new logging event containing \c locationInfo and the localized message \c key using parameters \c val1 and \c val2 to attached appender(s) if this logger is enabled for \c level events.
1539
1540
    First, the user supplied
1541
    <code>key</code> is searched in the resource bundle. Next, the resulting
1542
    pattern is formatted using helpers::StringHelper::format method with the
1543
    supplied parameters in a string array.
1544
1545
    @param level The level of the logging request.
1546
    @param key The key to be searched in the ResourceBundle.
1547
    @param locationInfo The location info of the logging request.
1548
    @param val1 The value for the first placeholder within the pattern.
1549
    @param val2 The value for the second placeholder within the pattern.
1550
1551
    @see #setResourceBundle
1552
1553
    See also #LOG4CXX_L7DLOG2.
1554
    */
1555
    void l7dlog(const LevelPtr& level, const std::wstring& key,
1556
      const LOG4CXX_NS::spi::LocationInfo& locationInfo,
1557
      const std::wstring& val1, const std::wstring& val2) const;
1558
    /**
1559
    Add a new logging event containing \c locationInfo and the localized message \c key using parameters \c val1, \c val2 and \c val3 to attached appender(s) if this logger is enabled for \c level events.
1560
1561
    First, the user supplied
1562
    <code>key</code> is searched in the resource bundle. Next, the resulting
1563
    pattern is formatted using helpers::StringHelper::format method with the
1564
    supplied parameters in a string array.
1565
1566
    @param level The level of the logging request.
1567
    @param key The key to be searched in the ResourceBundle.
1568
    @param locationInfo The location info of the logging request.
1569
    @param val1 The value for the first placeholder within the pattern.
1570
    @param val2 The value for the second placeholder within the pattern.
1571
    @param val3 The value for the third placeholder within the pattern.
1572
1573
    @see #setResourceBundle
1574
1575
    See also #LOG4CXX_L7DLOG3.
1576
    */
1577
    void l7dlog(const LevelPtr& level, const std::wstring& key,
1578
      const LOG4CXX_NS::spi::LocationInfo& locationInfo,
1579
      const std::wstring& val1, const std::wstring& val2, const std::wstring& val3) const;
1580
#endif
1581
#if LOG4CXX_UNICHAR_API
1582
    /**
1583
    Add a new logging event containing \c locationInfo and the localized message \c key to attached appender(s) if this logger is enabled for \c level events.
1584
1585
    First, the user supplied
1586
    <code>key</code> is searched in the resource bundle. Next, the resulting
1587
    pattern is formatted using helpers::StringHelper::format method.
1588
1589
    @param level The level of the logging request.
1590
    @param key The key to be searched in the ResourceBundle.
1591
    @param locationInfo The location info of the logging request.
1592
1593
    @see #setResourceBundle
1594
1595
    See also #LOG4CXX_L7DLOG.
1596
    */
1597
    void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
1598
      const LOG4CXX_NS::spi::LocationInfo& locationInfo) const;
1599
    /**
1600
    Add a new logging event containing \c locationInfo and the localized message \c key using parameter \c val to attached appender(s) if this logger is enabled for \c level events.
1601
1602
    First, the user supplied
1603
    <code>key</code> is searched in the resource bundle. Next, the resulting
1604
    pattern is formatted using helpers::StringHelper::format method with the
1605
    supplied parameter in a string array.
1606
1607
    @param level The level of the logging request.
1608
    @param key The key to be searched in the ResourceBundle.
1609
    @param locationInfo The location info of the logging request.
1610
    @param val The value for the first placeholder within the pattern.
1611
1612
    @see #setResourceBundle
1613
1614
    See also #LOG4CXX_L7DLOG1.
1615
    */
1616
    void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
1617
      const LOG4CXX_NS::spi::LocationInfo& locationInfo,
1618
      const std::basic_string<UniChar>& val) const;
1619
    /**
1620
    Add a new logging event containing \c locationInfo and the localized message \c key using parameters \c val1 and \c val2 to attached appender(s) if this logger is enabled for \c level events.
1621
1622
    First, the user supplied
1623
    <code>key</code> is searched in the resource bundle. Next, the resulting
1624
    pattern is formatted using helpers::StringHelper::format method with the
1625
    supplied parameters in a string array.
1626
1627
    @param level The level of the logging request.
1628
    @param key The key to be searched in the ResourceBundle.
1629
    @param locationInfo The location info of the logging request.
1630
    @param val1 The value for the first placeholder within the pattern.
1631
    @param val2 The value for the second placeholder within the pattern.
1632
1633
    @see #setResourceBundle
1634
1635
    See also #LOG4CXX_L7DLOG2.
1636
    */
1637
    void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
1638
      const LOG4CXX_NS::spi::LocationInfo& locationInfo,
1639
      const std::basic_string<UniChar>& val1, const std::basic_string<UniChar>& val2) const;
1640
    /**
1641
    Add a new logging event containing \c locationInfo and the localized message \c key using parameters \c val1, \c val2 and \c val3 to attached appender(s) if this logger is enabled for \c level events.
1642
1643
    First, the user supplied
1644
    <code>key</code> is searched in the resource bundle. Next, the resulting
1645
    pattern is formatted using helpers::StringHelper::format method with the
1646
    supplied parameters in a string array.
1647
1648
    @param level The level of the logging request.
1649
    @param key The key to be searched in the ResourceBundle.
1650
    @param locationInfo The location info of the logging request.
1651
    @param val1 The value for the first placeholder within the pattern.
1652
    @param val2 The value for the second placeholder within the pattern.
1653
    @param val3 The value for the third placeholder within the pattern.
1654
1655
    @see #setResourceBundle
1656
1657
    See also #LOG4CXX_L7DLOG3.
1658
    */
1659
    void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
1660
      const LOG4CXX_NS::spi::LocationInfo& locationInfo,
1661
      const std::basic_string<UniChar>& val1, const std::basic_string<UniChar>& val2,
1662
      const std::basic_string<UniChar>& val3) const;
1663
#endif
1664
#if LOG4CXX_CFSTRING_API
1665
    /**
1666
    Add a new logging event containing \c locationInfo and the localized message \c key to attached appender(s) if this logger is enabled for \c level events.
1667
1668
    First, the user supplied
1669
    <code>key</code> is searched in the resource bundle. Next, the resulting
1670
    pattern is formatted using helpers::StringHelper::format method.
1671
1672
    @param level The level of the logging request.
1673
    @param key The key to be searched in the ResourceBundle.
1674
    @param locationInfo The location info of the logging request.
1675
1676
    @see #setResourceBundle
1677
1678
    See also #LOG4CXX_L7DLOG.
1679
    */
1680
    void l7dlog(const LevelPtr& level, const CFStringRef& key,
1681
      const LOG4CXX_NS::spi::LocationInfo& locationInfo) const;
1682
    /**
1683
    Add a new logging event containing \c locationInfo and the localized message \c key using parameter \c val to attached appender(s) if this logger is enabled for \c level events.
1684
1685
    First, the user supplied
1686
    <code>key</code> is searched in the resource bundle. Next, the resulting
1687
    pattern is formatted using helpers::StringHelper::format method with the
1688
    supplied parameter in a string array.
1689
1690
    @param level The level of the logging request.
1691
    @param key The key to be searched in the ResourceBundle.
1692
    @param locationInfo The location info of the logging request.
1693
    @param val1 The value for the first placeholder within the pattern.
1694
1695
    @see #setResourceBundle
1696
1697
    See also #LOG4CXX_L7DLOG1.
1698
    */
1699
    void l7dlog(const LevelPtr& level, const CFStringRef& key,
1700
      const LOG4CXX_NS::spi::LocationInfo& locationInfo,
1701
      const CFStringRef& val1) const;
1702
    /**
1703
    Add a new logging event containing \c locationInfo and the localized message \c key using parameters \c val1 and \c val2 to attached appender(s) if this logger is enabled for \c level events.
1704
1705
    First, the user supplied
1706
    <code>key</code> is searched in the resource bundle. Next, the resulting
1707
    pattern is formatted using helpers::StringHelper::format method with the
1708
    supplied parameters in a string array.
1709
1710
    @param level The level of the logging request.
1711
    @param key The key to be searched in the ResourceBundle.
1712
    @param locationInfo The location info of the logging request.
1713
    @param val1 The value for the first placeholder within the pattern.
1714
    @param val2 The value for the second placeholder within the pattern.
1715
1716
    @see #setResourceBundle
1717
1718
    See also #LOG4CXX_L7DLOG2.
1719
    */
1720
    void l7dlog(const LevelPtr& level, const CFStringRef& key,
1721
      const LOG4CXX_NS::spi::LocationInfo& locationInfo,
1722
      const CFStringRef& val1, const CFStringRef& val2) const;
1723
    /**
1724
    Add a new logging event containing \c locationInfo and the localized message \c key using parameters \c val1, \c val2 and \c val3 to attached appender(s) if this logger is enabled for \c level events.
1725
1726
    First, the user supplied
1727
    <code>key</code> is searched in the resource bundle. Next, the resulting
1728
    pattern is formatted using helpers::StringHelper::format method with the
1729
    supplied parameters in a string array.
1730
1731
    @param level The level of the logging request.
1732
    @param key The key to be searched in the ResourceBundle.
1733
    @param locationInfo The location info of the logging request.
1734
    @param val1 The value for the first placeholder within the pattern.
1735
    @param val2 The value for the second placeholder within the pattern.
1736
    @param val3 The value for the third placeholder within the pattern.
1737
1738
    @see #setResourceBundle
1739
1740
    See also #LOG4CXX_L7DLOG3.
1741
    */
1742
    void l7dlog(const LevelPtr& level, const CFStringRef& key,
1743
      const LOG4CXX_NS::spi::LocationInfo& locationInfo,
1744
      const CFStringRef& val1, const CFStringRef& val2,
1745
      const CFStringRef& val3) const;
1746
#endif
1747
1748
    /**
1749
    Add a new logging event containing \c message and \c location to the appenders attached to this logger if this logger is enabled for \c level events.
1750
    This is the most generic printing method. It is intended to be
1751
    invoked by <b>wrapper</b> classes.
1752
1753
    @param level The level of the logging request.
1754
    @param message The message of the logging request.
1755
    @param location The source file of the logging request, may be null. */
1756
    void log(const LevelPtr& level, const std::string& message,
1757
      const LOG4CXX_NS::spi::LocationInfo& location) const;
1758
    /**
1759
    Add a new logging event containing \c message to the appenders attached to this logger if this logger is enabled for \c level events.
1760
    This is the most generic printing method. It is intended to be
1761
    invoked by <b>wrapper</b> classes.
1762
1763
    @param level The level of the logging request.
1764
    @param message The message of the logging request.
1765
    */
1766
    void log(const LevelPtr& level, const std::string& message) const;
1767
#if LOG4CXX_WCHAR_T_API
1768
    /**
1769
    Add a new logging event containing \c message and \c location to the appenders attached to this logger if this logger is enabled for \c level events.
1770
    This is the most generic printing method. It is intended to be
1771
    invoked by <b>wrapper</b> classes.
1772
1773
    @param level The level of the logging request.
1774
    @param message The message of the logging request.
1775
    @param location The source file of the logging request, may be null. */
1776
    void log(const LevelPtr& level, const std::wstring& message,
1777
      const LOG4CXX_NS::spi::LocationInfo& location) const;
1778
    /**
1779
    Add a new logging event containing \c message to the appenders attached to this logger if this logger is enabled for \c level events.
1780
    This is the most generic printing method. It is intended to be
1781
    invoked by <b>wrapper</b> classes.
1782
1783
    @param level The level of the logging request.
1784
    @param message The message of the logging request.
1785
    */
1786
    void log(const LevelPtr& level, const std::wstring& message) const;
1787
#endif
1788
#if LOG4CXX_UNICHAR_API
1789
    /**
1790
    Add a new logging event containing \c message and \c location to the appenders attached to this logger if this logger is enabled for \c level events.
1791
    This is the most generic printing method. It is intended to be
1792
    invoked by <b>wrapper</b> classes.
1793
1794
    @param level The level of the logging request.
1795
    @param message The message of the logging request.
1796
    @param location The source file of the logging request, may be null. */
1797
    void log(const LevelPtr& level, const std::basic_string<UniChar>& message,
1798
      const LOG4CXX_NS::spi::LocationInfo& location) const;
1799
    /**
1800
    Add a new logging event containing \c message to the appenders attached to this logger if this logger is enabled for \c level events.
1801
    This is the most generic printing method. It is intended to be
1802
    invoked by <b>wrapper</b> classes.
1803
1804
    @param level The level of the logging request.
1805
    @param message The message of the logging request.
1806
    */
1807
    void log(const LevelPtr& level, const std::basic_string<UniChar>& message) const;
1808
#endif
1809
#if LOG4CXX_CFSTRING_API
1810
    /**
1811
    Add a new logging event containing \c message and \c location to the appenders attached to this logger if this logger is enabled for \c level events.
1812
    This is the most generic printing method. It is intended to be
1813
    invoked by <b>wrapper</b> classes.
1814
1815
    @param level The level of the logging request.
1816
    @param message The message of the logging request.
1817
    @param location The source file of the logging request, may be null. */
1818
    void log(const LevelPtr& level, const CFStringRef& message,
1819
      const LOG4CXX_NS::spi::LocationInfo& location) const;
1820
    /**
1821
    Add a new logging event containing \c message to the appenders attached to this logger if this logger is enabled for \c level events.
1822
    This is the most generic printing method. It is intended to be
1823
    invoked by <b>wrapper</b> classes.
1824
1825
    @param level The level of the logging request.
1826
    @param message The message of the logging request.
1827
    */
1828
    void log(const LevelPtr& level, const CFStringRef& message) const;
1829
#endif
1830
    /**
1831
    Add a new logging event containing \c message and \c location to the appenders attached to this logger if this logger is enabled for \c level events.
1832
    This is the most generic printing method. It is intended to be
1833
    invoked by <b>wrapper</b> classes.
1834
1835
    @param level The level of the logging request.
1836
    @param message The message of the logging request.
1837
    @param location The source file of the logging request, may be null. */
1838
    void logLS(const LevelPtr& level, const LogString& message,
1839
      const LOG4CXX_NS::spi::LocationInfo& location) const;
1840
1841
1842
1843
    /**
1844
    Remove all previously added appenders from this logger
1845
    instance.
1846
    <p>This is useful when re-reading configuration information.
1847
    */
1848
    void removeAllAppenders() override;
1849
1850
    /**
1851
    Remove the appender passed as parameter form the list of appenders.
1852
    */
1853
    void removeAppender(const AppenderPtr appender) override;
1854
1855
    /**
1856
    Remove the appender with the name passed as parameter form the
1857
    list of appenders.
1858
     */
1859
    void removeAppender(const LogString& name) override;
1860
1861
    /**
1862
     * Replace \c oldAppender  with \c newAppender.
1863
     * @return true if oldAppender was replaced with newAppender.
1864
     */
1865
    bool replaceAppender(const AppenderPtr& oldAppender, const AppenderPtr& newAppender) LOG4CXX_16_VIRTUAL_SPECIFIER;
1866
1867
    /**
1868
     * Replace all previously added appenders with \c newList.
1869
     */
1870
    void replaceAppenders(const AppenderList& newList) LOG4CXX_16_VIRTUAL_SPECIFIER;
1871
1872
    /**
1873
     Set the additivity flag for this logger.
1874
      */
1875
    void setAdditivity(bool additive);
1876
1877
  protected:
1878
    friend class Hierarchy;
1879
    /**
1880
    Only the Hierarchy class can remove the hierarchy of a logger.
1881
    */
1882
    void removeHierarchy();
1883
    /**
1884
    Only the Hierarchy class can set the hierarchy of a logger.
1885
    */
1886
    void setHierarchy(spi::LoggerRepository* repository);
1887
    /**
1888
    Only the Hierarchy class can set the parent of a logger.
1889
    */
1890
    void setParent(LoggerPtr parentLogger);
1891
    /**
1892
    Only the Hierarchy class can change the threshold of a logger.
1893
    */
1894
    void updateThreshold();
1895
1896
  private:
1897
    spi::LoggerRepository* getHierarchy() const;
1898
1899
  public:
1900
    /**
1901
    Set the level of this logger.
1902
1903
    <p>As in <code>logger->setLevel(Level::getDebug());</code>
1904
1905
    <p>Null values are admitted.  */
1906
    virtual void setLevel(const LevelPtr level);
1907
1908
    /**
1909
    Set the resource bundle to be used with localized logging methods.
1910
    */
1911
    void setResourceBundle(const helpers::ResourceBundlePtr& bundle);
1912
1913
#if LOG4CXX_WCHAR_T_API
1914
    /**
1915
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>WARN</code> events.
1916
1917
    <p>This method first checks if this logger is <code>WARN</code>
1918
    enabled by comparing the level of this logger with the
1919
    WARN level. If this logger is
1920
    <code>WARN</code> enabled, it proceeds to call all the
1921
    registered appenders in this logger and also higher in the
1922
    hierarchy depending on the value of the additivity flag.
1923
1924
    @param msg the message string to log.
1925
    @param location The source code location of the logging request.
1926
1927
    See also #LOG4CXX_WARN.
1928
    */
1929
    void warn(const std::wstring& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
1930
    /**
1931
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>WARN</code> events.
1932
1933
    <p>This method first checks if this logger is <code>WARN</code>
1934
    enabled by comparing the level of this logger with the
1935
    WARN level. If this logger is
1936
    <code>WARN</code> enabled, it proceeds to call all the
1937
    registered appenders in this logger and also higher in the
1938
    hierarchy depending on the value of the additivity flag.
1939
1940
    @param msg the message string to log.
1941
1942
    See also #LOG4CXX_WARN.
1943
    */
1944
    void warn(const std::wstring& msg) const;
1945
#endif
1946
#if LOG4CXX_UNICHAR_API
1947
    /**
1948
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>WARN</code> events.
1949
1950
    <p>This method first checks if this logger is <code>WARN</code>
1951
    enabled by comparing the level of this logger with the
1952
    WARN level. If this logger is
1953
    <code>WARN</code> enabled, it proceeds to call all the
1954
    registered appenders in this logger and also higher in the
1955
    hierarchy depending on the value of the additivity flag.
1956
1957
    @param msg the message string to log.
1958
    @param location The source code location of the logging request.
1959
1960
    See also #LOG4CXX_WARN.
1961
    */
1962
    void warn(const std::basic_string<UniChar>& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
1963
    /**
1964
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>WARN</code> events.
1965
1966
    <p>This method first checks if this logger is <code>WARN</code>
1967
    enabled by comparing the level of this logger with the
1968
    WARN level. If this logger is
1969
    <code>WARN</code> enabled, it proceeds to call all the
1970
    registered appenders in this logger and also higher in the
1971
    hierarchy depending on the value of the additivity flag.
1972
1973
    @param msg the message string to log.
1974
1975
    See also #LOG4CXX_WARN.
1976
    */
1977
    void warn(const std::basic_string<UniChar>& msg) const;
1978
#endif
1979
#if LOG4CXX_CFSTRING_API
1980
    /**
1981
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>WARN</code> events.
1982
1983
    <p>This method first checks if this logger is <code>WARN</code>
1984
    enabled by comparing the level of this logger with the
1985
    WARN level. If this logger is
1986
    <code>WARN</code> enabled, it proceeds to call all the
1987
    registered appenders in this logger and also higher in the
1988
    hierarchy depending on the value of the additivity flag.
1989
1990
    @param msg the message string to log.
1991
    @param location The source code location of the logging request.
1992
1993
    See also #LOG4CXX_WARN.
1994
    */
1995
    void warn(const CFStringRef& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
1996
    /**
1997
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>WARN</code> events.
1998
1999
    <p>This method first checks if this logger is <code>WARN</code>
2000
    enabled by comparing the level of this logger with the
2001
    WARN level. If this logger is
2002
    <code>WARN</code> enabled, it proceeds to call all the
2003
    registered appenders in this logger and also higher in the
2004
    hierarchy depending on the value of the additivity flag.
2005
2006
    @param msg the message string to log.
2007
2008
    See also #LOG4CXX_WARN.
2009
    */
2010
    void warn(const CFStringRef& msg) const;
2011
#endif
2012
    /**
2013
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>WARN</code> events.
2014
2015
    <p>This method first checks if this logger is <code>WARN</code>
2016
    enabled by comparing the level of this logger with the
2017
    WARN level. If this logger is
2018
    <code>WARN</code> enabled, it proceeds to call all the
2019
    registered appenders in this logger and also higher in the
2020
    hierarchy depending on the value of the additivity flag.
2021
2022
    @param msg the message string to log.
2023
    @param location The source code location of the logging request.
2024
2025
    See also #LOG4CXX_WARN.
2026
    */
2027
    void warn(const std::string& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
2028
    /**
2029
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>WARN</code> events.
2030
2031
    <p>This method first checks if this logger is <code>WARN</code>
2032
    enabled by comparing the level of this logger with the
2033
    WARN level. If this logger is
2034
    <code>WARN</code> enabled, it proceeds to call all the
2035
    registered appenders in this logger and also higher in the
2036
    hierarchy depending on the value of the additivity flag.
2037
2038
    @param msg the message string to log.
2039
2040
    See also #LOG4CXX_WARN.
2041
    */
2042
    void warn(const std::string& msg) const;
2043
2044
#if LOG4CXX_WCHAR_T_API
2045
    /**
2046
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>TRACE</code> events.
2047
2048
    <p>This method first checks if this logger is <code>TRACE</code>
2049
    enabled by comparing the level of this logger with the
2050
    TRACE level. If this logger is
2051
    <code>TRACE</code> enabled, it proceeds to call all the
2052
    registered appenders in this logger and also higher in the
2053
    hierarchy depending on the value of the additivity flag.
2054
2055
    @param msg the message string to log.
2056
    @param location The source code location of the logging request.
2057
2058
    See also #LOG4CXX_TRACE.
2059
    */
2060
    void trace(const std::wstring& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
2061
    /**
2062
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>TRACE</code> events.
2063
2064
    <p>This method first checks if this logger is <code>TRACE</code>
2065
    enabled by comparing the level of this logger with the
2066
    TRACE level. If this logger is
2067
    <code>TRACE</code> enabled, it proceeds to call all the
2068
    registered appenders in this logger and also higher in the
2069
    hierarchy depending on the value of the additivity flag.
2070
2071
    @param msg the message string to log.
2072
2073
    See also #LOG4CXX_TRACE.
2074
    */
2075
    void trace(const std::wstring& msg) const;
2076
#endif
2077
#if LOG4CXX_UNICHAR_API
2078
    /**
2079
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>TRACE</code> events.
2080
2081
    <p>This method first checks if this logger is <code>TRACE</code>
2082
    enabled by comparing the level of this logger with the
2083
    TRACE level. If this logger is
2084
    <code>TRACE</code> enabled, it proceeds to call all the
2085
    registered appenders in this logger and also higher in the
2086
    hierarchy depending on the value of the additivity flag.
2087
2088
    @param msg the message string to log.
2089
    @param location The source code location of the logging request.
2090
2091
    See also #LOG4CXX_TRACE.
2092
    */
2093
    void trace(const std::basic_string<UniChar>& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
2094
    /**
2095
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>TRACE</code> events.
2096
2097
    <p>This method first checks if this logger is <code>TRACE</code>
2098
    enabled by comparing the level of this logger with the
2099
    TRACE level. If this logger is
2100
    <code>TRACE</code> enabled, it proceeds to call all the
2101
    registered appenders in this logger and also higher in the
2102
    hierarchy depending on the value of the additivity flag.
2103
2104
    @param msg the message string to log.
2105
2106
    See also #LOG4CXX_TRACE.
2107
    */
2108
    void trace(const std::basic_string<UniChar>& msg) const;
2109
#endif
2110
#if LOG4CXX_CFSTRING_API
2111
    /**
2112
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>TRACE</code> events.
2113
2114
    <p>This method first checks if this logger is <code>TRACE</code>
2115
    enabled by comparing the level of this logger with the
2116
    TRACE level. If this logger is
2117
    <code>TRACE</code> enabled, it proceeds to call all the
2118
    registered appenders in this logger and also higher in the
2119
    hierarchy depending on the value of the additivity flag.
2120
2121
    @param msg the message string to log.
2122
    @param location The source code location of the logging request.
2123
2124
    See also #LOG4CXX_TRACE.
2125
    */
2126
    void trace(const CFStringRef& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
2127
    /**
2128
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>TRACE</code> events.
2129
2130
    <p>This method first checks if this logger is <code>TRACE</code>
2131
    enabled by comparing the level of this logger with the
2132
    TRACE level. If this logger is
2133
    <code>TRACE</code> enabled, it proceeds to call all the
2134
    registered appenders in this logger and also higher in the
2135
    hierarchy depending on the value of the additivity flag.
2136
2137
    @param msg the message string to log.
2138
2139
    See also #LOG4CXX_TRACE.
2140
    */
2141
    void trace(const CFStringRef& msg) const;
2142
#endif
2143
    /**
2144
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>TRACE</code> events.
2145
2146
    <p>This method first checks if this logger is <code>TRACE</code>
2147
    enabled by comparing the level of this logger with the
2148
    TRACE level. If this logger is
2149
    <code>TRACE</code> enabled, it proceeds to call all the
2150
    registered appenders in this logger and also higher in the
2151
    hierarchy depending on the value of the additivity flag.
2152
2153
    @param msg the message string to log.
2154
    @param location The source code location of the logging request.
2155
2156
    See also #LOG4CXX_TRACE.
2157
    */
2158
    void trace(const std::string& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
2159
    /**
2160
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>TRACE</code> events.
2161
2162
    <p>This method first checks if this logger is <code>TRACE</code>
2163
    enabled by comparing the level of this logger with the
2164
    TRACE level. If this logger is
2165
    <code>TRACE</code> enabled, it proceeds to call all the
2166
    registered appenders in this logger and also higher in the
2167
    hierarchy depending on the value of the additivity flag.
2168
2169
    @param msg the message string to log.
2170
2171
    See also #LOG4CXX_TRACE.
2172
    */
2173
    void trace(const std::string& msg) const;
2174
2175
    /**
2176
     * Replace all current appenders with \c newList and
2177
     * set the additivity flag to \c newAdditivity.
2178
     *
2179
     * @param newList The appenders to set.
2180
     * @param newAdditivity Whether this logger should send events to its parent.
2181
     */
2182
    void reconfigure( const AppenderList& newList, bool newAdditivity );
2183
2184
  private:
2185
    //
2186
    //  prevent copy and assignment
2187
    Logger(const Logger&);
2188
    Logger& operator=(const Logger&);
2189
};
2190
LOG4CXX_LIST_DEF(LoggerList, LoggerPtr);
2191
}
2192
2193
#if !defined(LOG4CXX_UNLIKELY)
2194
  #if __GNUC__ >= 3
2195
    /**
2196
    Provides optimization hint to the compiler
2197
    to optimize for the expression being false.
2198
    @param expr boolean expression.
2199
    @returns value of expression.
2200
    */
2201
0
    #define LOG4CXX_UNLIKELY(expr) __builtin_expect(expr, 0)
2202
  #else
2203
    /**
2204
    Provides optimization hint to the compiler
2205
    to optimize for the expression being false.
2206
    @param expr boolean expression.
2207
    @returns value of expression.
2208
    **/
2209
    #define LOG4CXX_UNLIKELY(expr) expr
2210
  #endif
2211
#endif
2212
2213
#if defined(LOG4CXX_ENABLE_STACKTRACE) && !defined(LOG4CXX_STACKTRACE)
2214
  #ifndef __has_include
2215
    #include <boost/stacktrace.hpp>
2216
    #define LOG4CXX_STACKTRACE ::LOG4CXX_NS::MDC mdc_("stacktrace", LOG4CXX_EOL + boost::stacktrace::to_string(boost::stacktrace::stacktrace()));
2217
  #elif __has_include(<stacktrace>)
2218
    #include <stacktrace>
2219
    #define LOG4CXX_STACKTRACE ::LOG4CXX_NS::MDC mdc_("stacktrace", LOG4CXX_EOL + std::stacktrace::to_string(std::stacktrace::stacktrace()));
2220
  #elif __has_include(<boost/stacktrace.hpp>)
2221
    #include <boost/stacktrace.hpp>
2222
    #define LOG4CXX_STACKTRACE ::LOG4CXX_NS::MDC mdc_("stacktrace", LOG4CXX_EOL + boost::stacktrace::to_string(boost::stacktrace::stacktrace()));
2223
  #else
2224
    #warning "Stacktrace requested but no implementation found"
2225
  #endif
2226
#endif /* LOG4CXX_ENABLE_STACKTRACE */
2227
2228
#if !defined(LOG4CXX_STACKTRACE)
2229
#define LOG4CXX_STACKTRACE
2230
#endif
2231
2232
#ifndef LOG4CXX_FMT_VA_ARG
2233
#if __cplusplus >= 202002L
2234
  #define LOG4CXX_FMT_VA_ARG(...) __VA_OPT__(,) __VA_ARGS__
2235
#else
2236
  #define LOG4CXX_FMT_VA_ARG(...) , __VA_ARGS__
2237
#endif
2238
#endif
2239
2240
/** @addtogroup LoggingMacros Logging macros
2241
@{
2242
*/
2243
2244
/**
2245
Add a new logging event containing \c message to attached appender(s) if this logger is enabled for \c events.
2246
2247
@param logger the logger to be used.
2248
@param level The logging event level.
2249
@param message a valid r-value expression of an <code>operator<<(std::ostream&. ...)</code> overload.
2250
*/
2251
#define LOG4CXX_LOG(logger, level, message) do { \
2252
    if (logger->isEnabledFor(level)) {\
2253
      ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
2254
      logger->addEvent(level, oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2255
2256
/**
2257
Add a new logging event containing a message defined by \c fmt and <code>...</code> to attached appender(s) if this logger is enabled for \c events.
2258
2259
@param logger the logger to be used.
2260
@param level The logging event level.
2261
@param fmt the layout of the message.
2262
@param ... the variable parts of the message.
2263
*/
2264
#define LOG4CXX_LOG_FMT(logger, level, fmt, ...) do { \
2265
    if (logger->isEnabledFor(level)) {\
2266
      logger->addEvent(level, ::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__) ), LOG4CXX_LOCATION); }} while (0)
2267
2268
/**
2269
Add a new logging event containing \c message to attached appender(s) if this logger is enabled for \c events.
2270
2271
@param logger the logger to be used.
2272
@param level The logging event level.
2273
@param message a valid r-value expression of an <code>operator<<(std::ostream&. ...)</code> overload. in the internal encoding.
2274
*/
2275
#define LOG4CXX_LOGLS(logger, level, message) do { \
2276
    if (logger->isEnabledFor(level)) {\
2277
      ::LOG4CXX_NS::helpers::LogCharMessageBuffer oss_; \
2278
      logger->addEvent(level, oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2279
2280
#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 10000
2281
/**
2282
Add a new logging event containing \c message to attached appender(s) if \c logger is enabled for <code>DEBUG</code> events.
2283
2284
\usage
2285
~~~{.cpp}
2286
LOG4CXX_DEBUG(m_log, "AddMesh:"
2287
  << " name " << meshName
2288
  << " type 0x" << std:: hex << traits.Type
2289
  << " materialName " << meshObject.GetMaterialName()
2290
  << " visible? " << traits.IsDefaultVisible
2291
  << " at " << obj->getBoundingBox().getCenter()
2292
  << " +/- " << obj->getBoundingBox().getHalfSize()
2293
  );
2294
~~~
2295
2296
@param logger the logger that has the enabled status.
2297
@param message a valid r-value expression of an <code>operator<<(std::ostream&. ...)</code> overload.
2298
2299
*/
2300
#define LOG4CXX_DEBUG(logger, message) do { \
2301
    if (LOG4CXX_UNLIKELY(::LOG4CXX_NS::Logger::isDebugEnabledFor(logger))) {\
2302
      ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
2303
      logger->addDebugEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2304
2305
/**
2306
Add a new logging event containing a message defined by \c fmt and <code>...</code> to attached appender(s) if \c logger is enabled for <code>DEBUG</code> events.
2307
2308
\usage
2309
~~~{.cpp}
2310
LOG4CXX_DEBUG_FMT(m_log, "AddMesh: name {} type 0x{x} materialName {} visible? {d} at {} +/- {}"
2311
  , meshName
2312
  , traits.Type
2313
  , meshObject.GetMaterialName()
2314
  , traits.IsDefaultVisible
2315
  , obj->getBoundingBox().getCenter()
2316
  , obj->getBoundingBox().getHalfSize()
2317
  );
2318
~~~
2319
2320
@param logger the logger to be used.
2321
@param fmt the layout of the message.
2322
@param ... the variable parts of the message.
2323
*/
2324
#define LOG4CXX_DEBUG_FMT(logger, fmt, ...) do { \
2325
    if (LOG4CXX_UNLIKELY(::LOG4CXX_NS::Logger::isDebugEnabledFor(logger))) {\
2326
      logger->addDebugEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__) ), LOG4CXX_LOCATION); }} while (0)
2327
#else
2328
#define LOG4CXX_DEBUG(logger, message)
2329
#define LOG4CXX_DEBUG_FMT(logger, fmt, ...)
2330
#endif
2331
2332
#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 5000
2333
/**
2334
Add a new logging event containing \c message to attached appender(s) if \c logger is enabled for <code>TRACE</code> events.
2335
2336
\usage
2337
~~~{.cpp}
2338
    LOG4CXX_TRACE(m_log, "AddVertex:" << " at " << p << " n " << n << ' ' << color);
2339
~~~
2340
2341
@param logger the logger that has the enabled status.
2342
@param message a valid r-value expression of an <code>operator<<(std::ostream&. ...)</code> overload.
2343
*/
2344
#define LOG4CXX_TRACE(logger, message) do { \
2345
    if (LOG4CXX_UNLIKELY(::LOG4CXX_NS::Logger::isTraceEnabledFor(logger))) {\
2346
      ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
2347
      logger->addTraceEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2348
2349
/**
2350
Add a new logging event containing a message defined by \c fmt and <code>...</code> to attached appender(s) if \c logger is enabled for <code>TRACE</code> events.
2351
2352
\usage
2353
~~~{.cpp}
2354
    LOG4CXX_TRACE_FMT(m_log, "AddVertex: at {} n {} {}", p, n, color);
2355
~~~
2356
2357
@param logger the logger to be used.
2358
@param fmt the layout of the message.
2359
@param ... the variable parts of the message.
2360
*/
2361
#define LOG4CXX_TRACE_FMT(logger, fmt, ...) do { \
2362
    if (LOG4CXX_UNLIKELY(::LOG4CXX_NS::Logger::isTraceEnabledFor(logger))) {\
2363
      logger->addTraceEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__)), LOG4CXX_LOCATION); }} while (0)
2364
#else
2365
#define LOG4CXX_TRACE(logger, message)
2366
#define LOG4CXX_TRACE_FMT(logger, fmt, ...)
2367
#endif
2368
2369
#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 20000
2370
/**
2371
Add a new logging event containing \c message to attached appender(s) if \c logger is enabled for <code>INFO</code> events.
2372
2373
\usage
2374
~~~{.cpp}
2375
LOG4CXX_INFO(m_log, surface->GetName()
2376
  << " successfully planned " << std::fixed << std::setprecision(1) << ((plannedArea  / (plannedArea + unplannedArea)) * 100.0) << "%"
2377
  << " planned area " << std::fixed << std::setprecision(4) << plannedArea << "m^2"
2378
  << " unplanned area " << unplannedArea << "m^2"
2379
  << " planned segments " << surface->GetSegmentPlanCount() << " of " << surface->GetSegmentCount()
2380
  );
2381
~~~
2382
2383
@param logger the logger that has the enabled status.
2384
@param message a valid r-value expression of an <code>operator<<(std::ostream&. ...)</code> overload.
2385
*/
2386
44.8k
#define LOG4CXX_INFO(logger, message) do { \
2387
44.8k
    if (::LOG4CXX_NS::Logger::isInfoEnabledFor(logger)) {\
2388
44.8k
      ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
2389
44.8k
      logger->addInfoEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2390
2391
/**
2392
Add a new logging event containing a message defined by \c fmt and <code>...</code> to attached appender(s) if \c logger is enabled for <code>INFO</code> events.
2393
2394
\usage
2395
~~~{.cpp}
2396
LOG4CXX_INFO_FMT(m_log, "{} successfully planned {:.1f}% planned area {:.4f}m^2 unplanned area {:.4f}m^2 planned segments {:d} of {:d}"
2397
    , surface->GetName(), (plannedArea  / (plannedArea + unplannedArea)) * 100.0
2398
  , plannedArea, unplannedArea
2399
  , surface->GetSegmentPlanCount(), surface->GetSegmentCount()
2400
  );
2401
~~~
2402
2403
@param logger the logger to be used.
2404
@param fmt the layout of the message.
2405
@param ... the variable parts of the message.
2406
*/
2407
#define LOG4CXX_INFO_FMT(logger, fmt, ...) do { \
2408
    if (::LOG4CXX_NS::Logger::isInfoEnabledFor(logger)) {\
2409
      logger->addInfoEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__)), LOG4CXX_LOCATION); }} while (0)
2410
#else
2411
#define LOG4CXX_INFO(logger, message)
2412
#define LOG4CXX_INFO_FMT(logger, fmt, ...)
2413
#endif
2414
2415
#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 30000
2416
/**
2417
Add a new logging event containing \c message to attached appender(s) if \c logger is enabled for <code>WARN</code> events.
2418
2419
\usage
2420
~~~{.cpp}
2421
catch (const std::exception& ex)
2422
{
2423
    LOG4CXX_WARN(m_log, ex.what() << ": in " << m_task->GetParamFilePath());
2424
}
2425
~~~
2426
2427
@param logger the logger to be used.
2428
@param message a valid r-value expression of an <code>operator<<(std::ostream&. ...)</code> overload.
2429
*/
2430
#define LOG4CXX_WARN(logger, message) do { \
2431
    if (::LOG4CXX_NS::Logger::isWarnEnabledFor(logger)) {\
2432
      ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
2433
      logger->addWarnEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2434
2435
/**
2436
Add a new logging event containing a message defined by \c fmt and <code>...</code> to attached appender(s) if \c logger is enabled for <code>WARN</code> events.
2437
2438
\usage
2439
~~~{.cpp}
2440
catch (const std::exception& ex)
2441
{
2442
    LOG4CXX_WARN_FMT(m_log, "{}: in {}", ex.what(), m_task->GetParamFilePath());
2443
}
2444
~~~
2445
2446
@param logger the logger to be used.
2447
@param fmt the layout of the message.
2448
@param ... the variable parts of the message.
2449
*/
2450
#define LOG4CXX_WARN_FMT(logger, fmt, ...) do { \
2451
    if (::LOG4CXX_NS::Logger::isWarnEnabledFor(logger)) {\
2452
      logger->addWarnEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__)), LOG4CXX_LOCATION); }} while (0)
2453
#else
2454
#define LOG4CXX_WARN(logger, message)
2455
#define LOG4CXX_WARN_FMT(logger, fmt, ...)
2456
#endif
2457
2458
#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 40000
2459
/**
2460
Add a new logging event containing \c message to attached appender(s) if \c logger is enabled for <code>ERROR</code> events.
2461
2462
\usage
2463
~~~{.cpp}
2464
catch (std::exception& ex)
2465
{
2466
  LOG4CXX_ERROR(m_log, ex.what() << " in AddScanData");
2467
}
2468
~~~
2469
2470
@param logger the logger to be used.
2471
@param message a valid r-value expression of an <code>operator<<(std::ostream&. ...)</code> overload.
2472
*/
2473
#define LOG4CXX_ERROR(logger, message) do { \
2474
    if (::LOG4CXX_NS::Logger::isErrorEnabledFor(logger)) {\
2475
      ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
2476
      logger->addErrorEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2477
2478
/**
2479
Add a new logging event containing a message defined by \c fmt and <code>...</code> to attached appender(s) if \c logger is enabled for <code>ERROR</code> events.
2480
2481
\usage
2482
~~~{.cpp}
2483
catch (std::exception& ex)
2484
{
2485
  LOG4CXX_ERROR_FMT(m_log, "{} in AddScanData", ex.what());
2486
}
2487
~~~
2488
2489
@param logger the logger to be used.
2490
@param fmt the layout of the message.
2491
@param ... the variable parts of the message.
2492
*/
2493
#define LOG4CXX_ERROR_FMT(logger, fmt, ...) do { \
2494
    if (::LOG4CXX_NS::Logger::isErrorEnabledFor(logger)) {\
2495
      logger->addErrorEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__)), LOG4CXX_LOCATION); }} while (0)
2496
2497
/**
2498
If \c condition is not true, add a new logging event containing \c message to attached appender(s) if \c logger is enabled for <code>ERROR</code> events.
2499
2500
@param logger the logger to be used.
2501
@param condition condition
2502
@param message a valid r-value expression of an <code>operator<<(std::ostream&. ...)</code> overload.
2503
*/
2504
#define LOG4CXX_ASSERT(logger, condition, message) do { \
2505
    if (!(condition) && ::LOG4CXX_NS::Logger::isErrorEnabledFor(logger)) {\
2506
      ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
2507
      LOG4CXX_STACKTRACE \
2508
      logger->addErrorEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2509
2510
/**
2511
If \c condition is not true, add a new logging event containing
2512
a message defined by \c fmt and <code>...</code> to attached appender(s)
2513
if \c logger is enabled for <code>ERROR</code> events.
2514
2515
@param logger the logger to be used.
2516
@param condition condition
2517
@param fmt the layout of the message.
2518
@param ... the variable parts of the message.
2519
*/
2520
#define LOG4CXX_ASSERT_FMT(logger, condition, fmt, ...) do { \
2521
    if (!(condition) && ::LOG4CXX_NS::Logger::isErrorEnabledFor(logger)) {\
2522
      LOG4CXX_STACKTRACE \
2523
      logger->addErrorEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__)), LOG4CXX_LOCATION); }} while (0)
2524
2525
#else
2526
#define LOG4CXX_ERROR(logger, message)
2527
#define LOG4CXX_ERROR_FMT(logger, fmt, ...)
2528
#define LOG4CXX_ASSERT(logger, condition, message)
2529
#define LOG4CXX_ASSERT_FMT(logger, condition, fmt, ...)
2530
#endif
2531
2532
#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 50000
2533
/**
2534
Add a new logging event containing \c message to attached appender(s) if \c logger is enabled for <code>FATAL</code> events.
2535
2536
\usage
2537
~~~{.cpp}
2538
LOG4CXX_FATAL(m_log, m_renderSystem->getName() << " is not supported");
2539
~~~
2540
2541
@param logger the logger to be used.
2542
@param message a valid r-value expression of an <code>operator<<(std::ostream&. ...)</code> overload.
2543
*/
2544
#define LOG4CXX_FATAL(logger, message) do { \
2545
    if (::LOG4CXX_NS::Logger::isFatalEnabledFor(logger)) {\
2546
      ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
2547
      logger->addFatalEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2548
2549
/**
2550
Add a new logging event containing a message defined by \c fmt and <code>...</code> to attached appender(s) if \c logger is enabled for <code>FATAL</code> events.
2551
2552
\usage
2553
~~~{.cpp}
2554
LOG4CXX_FATAL_FMT(m_log, "{} is not supported", m_renderSystem->getName());
2555
~~~
2556
@param logger the logger to be used.
2557
@param fmt the layout of the message.
2558
@param ... the variable parts of the message.
2559
2560
*/
2561
#define LOG4CXX_FATAL_FMT(logger, fmt, ...) do { \
2562
    if (::LOG4CXX_NS::Logger::isFatalEnabledFor(logger)) {\
2563
      logger->addFatalEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__)), LOG4CXX_LOCATION); }} while (0)
2564
#else
2565
#define LOG4CXX_FATAL(logger, message)
2566
#define LOG4CXX_FATAL_FMT(logger, fmt, ...)
2567
#endif
2568
2569
/**
2570
Add a new logging event containing the localized message \c key to attached appender(s) if \c logger is enabled for \c level events.
2571
2572
@param logger the logger to be used.
2573
@param level The logging event level.
2574
@param key the key to be searched in the resourceBundle of the logger.
2575
*/
2576
#define LOG4CXX_L7DLOG(logger, level, key) do { \
2577
    if (logger->isEnabledFor(level)) {\
2578
      logger->l7dlog(level, key, LOG4CXX_LOCATION); }} while (0)
2579
2580
/**
2581
Add a new logging event containing the localized message \c key to attached appender(s) if \c logger is enabled for \c level events with one parameter.
2582
2583
@param logger the logger to be used.
2584
@param level The logging event level.
2585
@param key the key to be searched in the resourceBundle of the logger.
2586
@param p1 the unique parameter.
2587
*/
2588
#define LOG4CXX_L7DLOG1(logger, level, key, p1) do { \
2589
    if (logger->isEnabledFor(level)) {\
2590
      logger->l7dlog(level, key, LOG4CXX_LOCATION, p1); }} while (0)
2591
2592
/**
2593
Add a new logging event containing the localized message \c key to attached appender(s) if \c logger is enabled for \c level events with two parameters.
2594
2595
@param logger the logger to be used.
2596
@param level The logging event level.
2597
@param key the key to be searched in the resourceBundle of the logger.
2598
@param p1 the first parameter.
2599
@param p2 the second parameter.
2600
*/
2601
#define LOG4CXX_L7DLOG2(logger, level, key, p1, p2) do { \
2602
    if (logger->isEnabledFor(level)) {\
2603
      logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2); }} while (0)
2604
2605
/**
2606
Add a new logging event containing the localized message \c key to attached appender(s) if \c logger is enabled for \c level events with three parameters.
2607
2608
@param logger the logger to be used.
2609
@param level The logging event level.
2610
@param key the key to be searched in the resourceBundle of the logger.
2611
@param p1 the first parameter.
2612
@param p2 the second parameter.
2613
@param p3 the third parameter.
2614
*/
2615
#define LOG4CXX_L7DLOG3(logger, level, key, p1, p2, p3) do { \
2616
    if (logger->isEnabledFor(level)) {\
2617
      logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2, p3); }} while (0)
2618
2619
/**@}*/
2620
2621
#include <log4cxx/spi/loggerrepository.h>
2622
2623
#endif //_LOG4CXX_LOGGER_H