Coverage Report

Created: 2026-02-26 06:58

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
3.97k
    {
1256
3.97k
      return logger && logger->m_threshold <= Level::DEBUG_INT && logger->isDebugEnabled();
1257
3.97k
    }
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
0
    {
1290
0
      return logger && logger->m_threshold <= Level::INFO_INT && logger->isInfoEnabled();
1291
0
    }
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
    /**
1881
    Only the Hierarchy class can remove the hierarchy of a logger.
1882
    */
1883
    void removeHierarchy();
1884
    /**
1885
    Only the Hierarchy class can set the hierarchy of a logger.
1886
    */
1887
    void setHierarchy(spi::LoggerRepository* repository);
1888
    /**
1889
    Only the Hierarchy class can set the parent of a logger.
1890
    */
1891
    void setParent(LoggerPtr parentLogger);
1892
    /**
1893
    Only the Hierarchy class can change the threshold of a logger.
1894
    */
1895
    void updateThreshold();
1896
1897
  public: // Unit testing support methods
1898
0
    void changeParentTo(const LoggerPtr& otherLogger) { setParent(otherLogger); }
1899
1900
    /** Is m_threshold the same as level->toInt()
1901
     */
1902
    bool isThresholdEqualTo(const LevelPtr& level) const;
1903
1904
    /** Is m_threshold the same as \c other
1905
     */
1906
    bool isThresholdEqualTo(const LoggerPtr& other) const;
1907
1908
    /** Is m_threshold the same as getEffectiveLevel()->toInt()
1909
     */
1910
    bool isThresholdValid() const;
1911
1912
  private:
1913
    spi::LoggerRepository* getHierarchy() const;
1914
1915
  public:
1916
    /**
1917
    Set the level of this logger.
1918
1919
    <p>As in <code>logger->setLevel(Level::getDebug());</code>
1920
1921
    <p>Null values are admitted.  */
1922
    virtual void setLevel(const LevelPtr level);
1923
1924
    /**
1925
    Set the resource bundle to be used with localized logging methods.
1926
    */
1927
    void setResourceBundle(const helpers::ResourceBundlePtr& bundle);
1928
1929
#if LOG4CXX_WCHAR_T_API
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
    @param location The source code location of the logging request.
1942
1943
    See also #LOG4CXX_WARN.
1944
    */
1945
    void warn(const std::wstring& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
1946
    /**
1947
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>WARN</code> events.
1948
1949
    <p>This method first checks if this logger is <code>WARN</code>
1950
    enabled by comparing the level of this logger with the
1951
    WARN level. If this logger is
1952
    <code>WARN</code> enabled, it proceeds to call all the
1953
    registered appenders in this logger and also higher in the
1954
    hierarchy depending on the value of the additivity flag.
1955
1956
    @param msg the message string to log.
1957
1958
    See also #LOG4CXX_WARN.
1959
    */
1960
    void warn(const std::wstring& msg) const;
1961
#endif
1962
#if LOG4CXX_UNICHAR_API
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
    @param location The source code location of the logging request.
1975
1976
    See also #LOG4CXX_WARN.
1977
    */
1978
    void warn(const std::basic_string<UniChar>& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
1979
    /**
1980
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>WARN</code> events.
1981
1982
    <p>This method first checks if this logger is <code>WARN</code>
1983
    enabled by comparing the level of this logger with the
1984
    WARN level. If this logger is
1985
    <code>WARN</code> enabled, it proceeds to call all the
1986
    registered appenders in this logger and also higher in the
1987
    hierarchy depending on the value of the additivity flag.
1988
1989
    @param msg the message string to log.
1990
1991
    See also #LOG4CXX_WARN.
1992
    */
1993
    void warn(const std::basic_string<UniChar>& msg) const;
1994
#endif
1995
#if LOG4CXX_CFSTRING_API
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
    @param location The source code location of the logging request.
2008
2009
    See also #LOG4CXX_WARN.
2010
    */
2011
    void warn(const CFStringRef& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
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
2024
    See also #LOG4CXX_WARN.
2025
    */
2026
    void warn(const CFStringRef& msg) const;
2027
#endif
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
    @param location The source code location of the logging request.
2040
2041
    See also #LOG4CXX_WARN.
2042
    */
2043
    void warn(const std::string& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
2044
    /**
2045
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>WARN</code> events.
2046
2047
    <p>This method first checks if this logger is <code>WARN</code>
2048
    enabled by comparing the level of this logger with the
2049
    WARN level. If this logger is
2050
    <code>WARN</code> enabled, it proceeds to call all the
2051
    registered appenders in this logger and also higher in the
2052
    hierarchy depending on the value of the additivity flag.
2053
2054
    @param msg the message string to log.
2055
2056
    See also #LOG4CXX_WARN.
2057
    */
2058
    void warn(const std::string& msg) const;
2059
2060
#if LOG4CXX_WCHAR_T_API
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
    @param location The source code location of the logging request.
2073
2074
    See also #LOG4CXX_TRACE.
2075
    */
2076
    void trace(const std::wstring& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
2077
    /**
2078
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>TRACE</code> events.
2079
2080
    <p>This method first checks if this logger is <code>TRACE</code>
2081
    enabled by comparing the level of this logger with the
2082
    TRACE level. If this logger is
2083
    <code>TRACE</code> enabled, it proceeds to call all the
2084
    registered appenders in this logger and also higher in the
2085
    hierarchy depending on the value of the additivity flag.
2086
2087
    @param msg the message string to log.
2088
2089
    See also #LOG4CXX_TRACE.
2090
    */
2091
    void trace(const std::wstring& msg) const;
2092
#endif
2093
#if LOG4CXX_UNICHAR_API
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
    @param location The source code location of the logging request.
2106
2107
    See also #LOG4CXX_TRACE.
2108
    */
2109
    void trace(const std::basic_string<UniChar>& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
2110
    /**
2111
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>TRACE</code> events.
2112
2113
    <p>This method first checks if this logger is <code>TRACE</code>
2114
    enabled by comparing the level of this logger with the
2115
    TRACE level. If this logger is
2116
    <code>TRACE</code> enabled, it proceeds to call all the
2117
    registered appenders in this logger and also higher in the
2118
    hierarchy depending on the value of the additivity flag.
2119
2120
    @param msg the message string to log.
2121
2122
    See also #LOG4CXX_TRACE.
2123
    */
2124
    void trace(const std::basic_string<UniChar>& msg) const;
2125
#endif
2126
#if LOG4CXX_CFSTRING_API
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
    @param location The source code location of the logging request.
2139
2140
    See also #LOG4CXX_TRACE.
2141
    */
2142
    void trace(const CFStringRef& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
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
2155
    See also #LOG4CXX_TRACE.
2156
    */
2157
    void trace(const CFStringRef& msg) const;
2158
#endif
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
    @param location The source code location of the logging request.
2171
2172
    See also #LOG4CXX_TRACE.
2173
    */
2174
    void trace(const std::string& msg, const LOG4CXX_NS::spi::LocationInfo& location) const;
2175
    /**
2176
    Add a new logging event containing \c msg to attached appender(s) if this logger is enabled for <code>TRACE</code> events.
2177
2178
    <p>This method first checks if this logger is <code>TRACE</code>
2179
    enabled by comparing the level of this logger with the
2180
    TRACE level. If this logger is
2181
    <code>TRACE</code> enabled, it proceeds to call all the
2182
    registered appenders in this logger and also higher in the
2183
    hierarchy depending on the value of the additivity flag.
2184
2185
    @param msg the message string to log.
2186
2187
    See also #LOG4CXX_TRACE.
2188
    */
2189
    void trace(const std::string& msg) const;
2190
2191
    /**
2192
     * Replace all current appenders with \c newList and
2193
     * set the additivity flag to \c newAdditivity.
2194
     *
2195
     * @param newList The appenders to set.
2196
     * @param newAdditivity Whether this logger should send events to its parent.
2197
     */
2198
    void reconfigure( const AppenderList& newList, bool newAdditivity );
2199
2200
  private:
2201
    //
2202
    //  prevent copy and assignment
2203
    Logger(const Logger&);
2204
    Logger& operator=(const Logger&);
2205
};
2206
LOG4CXX_LIST_DEF(LoggerList, LoggerPtr);
2207
}
2208
2209
#if !defined(LOG4CXX_UNLIKELY)
2210
  #if __GNUC__ >= 3
2211
    /**
2212
    Provides optimization hint to the compiler
2213
    to optimize for the expression being false.
2214
    @param expr boolean expression.
2215
    @returns value of expression.
2216
    */
2217
7.94k
    #define LOG4CXX_UNLIKELY(expr) __builtin_expect(expr, 0)
2218
  #else
2219
    /**
2220
    Provides optimization hint to the compiler
2221
    to optimize for the expression being false.
2222
    @param expr boolean expression.
2223
    @returns value of expression.
2224
    **/
2225
    #define LOG4CXX_UNLIKELY(expr) expr
2226
  #endif
2227
#endif
2228
2229
#if defined(LOG4CXX_ENABLE_STACKTRACE) && !defined(LOG4CXX_STACKTRACE)
2230
  #ifndef __has_include
2231
    #include <boost/stacktrace.hpp>
2232
    #define LOG4CXX_STACKTRACE ::LOG4CXX_NS::MDC mdc_("stacktrace", LOG4CXX_EOL + boost::stacktrace::to_string(boost::stacktrace::stacktrace()));
2233
  #elif __has_include(<stacktrace>)
2234
    #include <stacktrace>
2235
    #define LOG4CXX_STACKTRACE ::LOG4CXX_NS::MDC mdc_("stacktrace", LOG4CXX_EOL + std::stacktrace::to_string(std::stacktrace::stacktrace()));
2236
  #elif __has_include(<boost/stacktrace.hpp>)
2237
    #include <boost/stacktrace.hpp>
2238
    #define LOG4CXX_STACKTRACE ::LOG4CXX_NS::MDC mdc_("stacktrace", LOG4CXX_EOL + boost::stacktrace::to_string(boost::stacktrace::stacktrace()));
2239
  #else
2240
    #warning "Stacktrace requested but no implementation found"
2241
  #endif
2242
#endif /* LOG4CXX_ENABLE_STACKTRACE */
2243
2244
#if !defined(LOG4CXX_STACKTRACE)
2245
#define LOG4CXX_STACKTRACE
2246
#endif
2247
2248
#ifndef LOG4CXX_FMT_VA_ARG
2249
#if __cplusplus >= 202002L
2250
  #define LOG4CXX_FMT_VA_ARG(...) __VA_OPT__(,) __VA_ARGS__
2251
#else
2252
  #define LOG4CXX_FMT_VA_ARG(...) , __VA_ARGS__
2253
#endif
2254
#endif
2255
2256
/** @addtogroup LoggingMacros Logging macros
2257
@{
2258
*/
2259
2260
/**
2261
Add a new logging event containing \c message to attached appender(s) if this logger is enabled for \c events.
2262
2263
@param logger the logger to be used.
2264
@param level The logging event level.
2265
@param message a valid r-value expression of an <code>operator<<(std::ostream&. ...)</code> overload.
2266
*/
2267
#define LOG4CXX_LOG(logger, level, message) do { \
2268
    if (logger->isEnabledFor(level)) {\
2269
      ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
2270
      logger->addEvent(level, oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2271
2272
/**
2273
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.
2274
2275
@param logger the logger to be used.
2276
@param level The logging event level.
2277
@param fmt the layout of the message.
2278
@param ... the variable parts of the message.
2279
*/
2280
#define LOG4CXX_LOG_FMT(logger, level, fmt, ...) do { \
2281
    if (logger->isEnabledFor(level)) {\
2282
      logger->addEvent(level, ::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__) ), LOG4CXX_LOCATION); }} while (0)
2283
2284
/**
2285
Add a new logging event containing \c message to attached appender(s) if this logger is enabled for \c events.
2286
2287
@param logger the logger to be used.
2288
@param level The logging event level.
2289
@param message a valid r-value expression of an <code>operator<<(std::ostream&. ...)</code> overload. in the internal encoding.
2290
*/
2291
#define LOG4CXX_LOGLS(logger, level, message) do { \
2292
    if (logger->isEnabledFor(level)) {\
2293
      ::LOG4CXX_NS::helpers::LogCharMessageBuffer oss_; \
2294
      logger->addEvent(level, oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2295
2296
#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 10000
2297
/**
2298
Add a new logging event containing \c message to attached appender(s) if \c logger is enabled for <code>DEBUG</code> events.
2299
2300
\usage
2301
~~~{.cpp}
2302
LOG4CXX_DEBUG(m_log, "AddMesh:"
2303
  << " name " << meshName
2304
  << " type 0x" << std:: hex << traits.Type
2305
  << " materialName " << meshObject.GetMaterialName()
2306
  << " visible? " << traits.IsDefaultVisible
2307
  << " at " << obj->getBoundingBox().getCenter()
2308
  << " +/- " << obj->getBoundingBox().getHalfSize()
2309
  );
2310
~~~
2311
2312
@param logger the logger that has the enabled status.
2313
@param message a valid r-value expression of an <code>operator<<(std::ostream&. ...)</code> overload.
2314
2315
*/
2316
3.97k
#define LOG4CXX_DEBUG(logger, message) do { \
2317
3.97k
    if (LOG4CXX_UNLIKELY(::LOG4CXX_NS::Logger::isDebugEnabledFor(logger))) {\
2318
3.97k
      ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
2319
3.97k
      logger->addDebugEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2320
2321
/**
2322
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.
2323
2324
\usage
2325
~~~{.cpp}
2326
LOG4CXX_DEBUG_FMT(m_log, "AddMesh: name {} type 0x{x} materialName {} visible? {d} at {} +/- {}"
2327
  , meshName
2328
  , traits.Type
2329
  , meshObject.GetMaterialName()
2330
  , traits.IsDefaultVisible
2331
  , obj->getBoundingBox().getCenter()
2332
  , obj->getBoundingBox().getHalfSize()
2333
  );
2334
~~~
2335
2336
@param logger the logger to be used.
2337
@param fmt the layout of the message.
2338
@param ... the variable parts of the message.
2339
*/
2340
#define LOG4CXX_DEBUG_FMT(logger, fmt, ...) do { \
2341
    if (LOG4CXX_UNLIKELY(::LOG4CXX_NS::Logger::isDebugEnabledFor(logger))) {\
2342
      logger->addDebugEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__) ), LOG4CXX_LOCATION); }} while (0)
2343
#else
2344
#define LOG4CXX_DEBUG(logger, message)
2345
#define LOG4CXX_DEBUG_FMT(logger, fmt, ...)
2346
#endif
2347
2348
#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 5000
2349
/**
2350
Add a new logging event containing \c message to attached appender(s) if \c logger is enabled for <code>TRACE</code> events.
2351
2352
\usage
2353
~~~{.cpp}
2354
    LOG4CXX_TRACE(m_log, "AddVertex:" << " at " << p << " n " << n << ' ' << color);
2355
~~~
2356
2357
@param logger the logger that has the enabled status.
2358
@param message a valid r-value expression of an <code>operator<<(std::ostream&. ...)</code> overload.
2359
*/
2360
#define LOG4CXX_TRACE(logger, message) do { \
2361
    if (LOG4CXX_UNLIKELY(::LOG4CXX_NS::Logger::isTraceEnabledFor(logger))) {\
2362
      ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
2363
      logger->addTraceEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2364
2365
/**
2366
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.
2367
2368
\usage
2369
~~~{.cpp}
2370
    LOG4CXX_TRACE_FMT(m_log, "AddVertex: at {} n {} {}", p, n, color);
2371
~~~
2372
2373
@param logger the logger to be used.
2374
@param fmt the layout of the message.
2375
@param ... the variable parts of the message.
2376
*/
2377
#define LOG4CXX_TRACE_FMT(logger, fmt, ...) do { \
2378
    if (LOG4CXX_UNLIKELY(::LOG4CXX_NS::Logger::isTraceEnabledFor(logger))) {\
2379
      logger->addTraceEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__)), LOG4CXX_LOCATION); }} while (0)
2380
#else
2381
#define LOG4CXX_TRACE(logger, message)
2382
#define LOG4CXX_TRACE_FMT(logger, fmt, ...)
2383
#endif
2384
2385
#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 20000
2386
/**
2387
Add a new logging event containing \c message to attached appender(s) if \c logger is enabled for <code>INFO</code> events.
2388
2389
\usage
2390
~~~{.cpp}
2391
LOG4CXX_INFO(m_log, surface->GetName()
2392
  << " successfully planned " << std::fixed << std::setprecision(1) << ((plannedArea  / (plannedArea + unplannedArea)) * 100.0) << "%"
2393
  << " planned area " << std::fixed << std::setprecision(4) << plannedArea << "m^2"
2394
  << " unplanned area " << unplannedArea << "m^2"
2395
  << " planned segments " << surface->GetSegmentPlanCount() << " of " << surface->GetSegmentCount()
2396
  );
2397
~~~
2398
2399
@param logger the logger that has the enabled status.
2400
@param message a valid r-value expression of an <code>operator<<(std::ostream&. ...)</code> overload.
2401
*/
2402
#define LOG4CXX_INFO(logger, message) do { \
2403
    if (::LOG4CXX_NS::Logger::isInfoEnabledFor(logger)) {\
2404
      ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
2405
      logger->addInfoEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2406
2407
/**
2408
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.
2409
2410
\usage
2411
~~~{.cpp}
2412
LOG4CXX_INFO_FMT(m_log, "{} successfully planned {:.1f}% planned area {:.4f}m^2 unplanned area {:.4f}m^2 planned segments {:d} of {:d}"
2413
    , surface->GetName(), (plannedArea  / (plannedArea + unplannedArea)) * 100.0
2414
  , plannedArea, unplannedArea
2415
  , surface->GetSegmentPlanCount(), surface->GetSegmentCount()
2416
  );
2417
~~~
2418
2419
@param logger the logger to be used.
2420
@param fmt the layout of the message.
2421
@param ... the variable parts of the message.
2422
*/
2423
#define LOG4CXX_INFO_FMT(logger, fmt, ...) do { \
2424
    if (::LOG4CXX_NS::Logger::isInfoEnabledFor(logger)) {\
2425
      logger->addInfoEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__)), LOG4CXX_LOCATION); }} while (0)
2426
#else
2427
#define LOG4CXX_INFO(logger, message)
2428
#define LOG4CXX_INFO_FMT(logger, fmt, ...)
2429
#endif
2430
2431
#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 30000
2432
/**
2433
Add a new logging event containing \c message to attached appender(s) if \c logger is enabled for <code>WARN</code> events.
2434
2435
\usage
2436
~~~{.cpp}
2437
catch (const std::exception& ex)
2438
{
2439
    LOG4CXX_WARN(m_log, ex.what() << ": in " << m_task->GetParamFilePath());
2440
}
2441
~~~
2442
2443
@param logger the logger to be used.
2444
@param message a valid r-value expression of an <code>operator<<(std::ostream&. ...)</code> overload.
2445
*/
2446
#define LOG4CXX_WARN(logger, message) do { \
2447
    if (::LOG4CXX_NS::Logger::isWarnEnabledFor(logger)) {\
2448
      ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
2449
      logger->addWarnEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2450
2451
/**
2452
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.
2453
2454
\usage
2455
~~~{.cpp}
2456
catch (const std::exception& ex)
2457
{
2458
    LOG4CXX_WARN_FMT(m_log, "{}: in {}", ex.what(), m_task->GetParamFilePath());
2459
}
2460
~~~
2461
2462
@param logger the logger to be used.
2463
@param fmt the layout of the message.
2464
@param ... the variable parts of the message.
2465
*/
2466
#define LOG4CXX_WARN_FMT(logger, fmt, ...) do { \
2467
    if (::LOG4CXX_NS::Logger::isWarnEnabledFor(logger)) {\
2468
      logger->addWarnEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__)), LOG4CXX_LOCATION); }} while (0)
2469
#else
2470
#define LOG4CXX_WARN(logger, message)
2471
#define LOG4CXX_WARN_FMT(logger, fmt, ...)
2472
#endif
2473
2474
#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 40000
2475
/**
2476
Add a new logging event containing \c message to attached appender(s) if \c logger is enabled for <code>ERROR</code> events.
2477
2478
\usage
2479
~~~{.cpp}
2480
catch (std::exception& ex)
2481
{
2482
  LOG4CXX_ERROR(m_log, ex.what() << " in AddScanData");
2483
}
2484
~~~
2485
2486
@param logger the logger to be used.
2487
@param message a valid r-value expression of an <code>operator<<(std::ostream&. ...)</code> overload.
2488
*/
2489
#define LOG4CXX_ERROR(logger, message) do { \
2490
    if (::LOG4CXX_NS::Logger::isErrorEnabledFor(logger)) {\
2491
      ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
2492
      logger->addErrorEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2493
2494
/**
2495
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.
2496
2497
\usage
2498
~~~{.cpp}
2499
catch (std::exception& ex)
2500
{
2501
  LOG4CXX_ERROR_FMT(m_log, "{} in AddScanData", ex.what());
2502
}
2503
~~~
2504
2505
@param logger the logger to be used.
2506
@param fmt the layout of the message.
2507
@param ... the variable parts of the message.
2508
*/
2509
#define LOG4CXX_ERROR_FMT(logger, fmt, ...) do { \
2510
    if (::LOG4CXX_NS::Logger::isErrorEnabledFor(logger)) {\
2511
      logger->addErrorEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__)), LOG4CXX_LOCATION); }} while (0)
2512
2513
/**
2514
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.
2515
2516
@param logger the logger to be used.
2517
@param condition condition
2518
@param message a valid r-value expression of an <code>operator<<(std::ostream&. ...)</code> overload.
2519
*/
2520
#define LOG4CXX_ASSERT(logger, condition, message) do { \
2521
    if (!(condition) && ::LOG4CXX_NS::Logger::isErrorEnabledFor(logger)) {\
2522
      ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
2523
      LOG4CXX_STACKTRACE \
2524
      logger->addErrorEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2525
2526
/**
2527
If \c condition is not true, add a new logging event containing
2528
a message defined by \c fmt and <code>...</code> to attached appender(s)
2529
if \c logger is enabled for <code>ERROR</code> events.
2530
2531
@param logger the logger to be used.
2532
@param condition condition
2533
@param fmt the layout of the message.
2534
@param ... the variable parts of the message.
2535
*/
2536
#define LOG4CXX_ASSERT_FMT(logger, condition, fmt, ...) do { \
2537
    if (!(condition) && ::LOG4CXX_NS::Logger::isErrorEnabledFor(logger)) {\
2538
      LOG4CXX_STACKTRACE \
2539
      logger->addErrorEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__)), LOG4CXX_LOCATION); }} while (0)
2540
2541
#else
2542
#define LOG4CXX_ERROR(logger, message)
2543
#define LOG4CXX_ERROR_FMT(logger, fmt, ...)
2544
#define LOG4CXX_ASSERT(logger, condition, message)
2545
#define LOG4CXX_ASSERT_FMT(logger, condition, fmt, ...)
2546
#endif
2547
2548
#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 50000
2549
/**
2550
Add a new logging event containing \c message to attached appender(s) if \c logger is enabled for <code>FATAL</code> events.
2551
2552
\usage
2553
~~~{.cpp}
2554
LOG4CXX_FATAL(m_log, m_renderSystem->getName() << " is not supported");
2555
~~~
2556
2557
@param logger the logger to be used.
2558
@param message a valid r-value expression of an <code>operator<<(std::ostream&. ...)</code> overload.
2559
*/
2560
#define LOG4CXX_FATAL(logger, message) do { \
2561
    if (::LOG4CXX_NS::Logger::isFatalEnabledFor(logger)) {\
2562
      ::LOG4CXX_NS::helpers::MessageBuffer oss_; \
2563
      logger->addFatalEvent(oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
2564
2565
/**
2566
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.
2567
2568
\usage
2569
~~~{.cpp}
2570
LOG4CXX_FATAL_FMT(m_log, "{} is not supported", m_renderSystem->getName());
2571
~~~
2572
@param logger the logger to be used.
2573
@param fmt the layout of the message.
2574
@param ... the variable parts of the message.
2575
2576
*/
2577
#define LOG4CXX_FATAL_FMT(logger, fmt, ...) do { \
2578
    if (::LOG4CXX_NS::Logger::isFatalEnabledFor(logger)) {\
2579
      logger->addFatalEvent(::LOG4CXX_FORMAT_NS::format(fmt LOG4CXX_FMT_VA_ARG(__VA_ARGS__)), LOG4CXX_LOCATION); }} while (0)
2580
#else
2581
#define LOG4CXX_FATAL(logger, message)
2582
#define LOG4CXX_FATAL_FMT(logger, fmt, ...)
2583
#endif
2584
2585
/**
2586
Add a new logging event containing the localized message \c key to attached appender(s) if \c logger is enabled for \c level events.
2587
2588
@param logger the logger to be used.
2589
@param level The logging event level.
2590
@param key the key to be searched in the resourceBundle of the logger.
2591
*/
2592
#define LOG4CXX_L7DLOG(logger, level, key) do { \
2593
    if (logger->isEnabledFor(level)) {\
2594
      logger->l7dlog(level, key, LOG4CXX_LOCATION); }} while (0)
2595
2596
/**
2597
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.
2598
2599
@param logger the logger to be used.
2600
@param level The logging event level.
2601
@param key the key to be searched in the resourceBundle of the logger.
2602
@param p1 the unique parameter.
2603
*/
2604
#define LOG4CXX_L7DLOG1(logger, level, key, p1) do { \
2605
    if (logger->isEnabledFor(level)) {\
2606
      logger->l7dlog(level, key, LOG4CXX_LOCATION, p1); }} while (0)
2607
2608
/**
2609
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.
2610
2611
@param logger the logger to be used.
2612
@param level The logging event level.
2613
@param key the key to be searched in the resourceBundle of the logger.
2614
@param p1 the first parameter.
2615
@param p2 the second parameter.
2616
*/
2617
#define LOG4CXX_L7DLOG2(logger, level, key, p1, p2) do { \
2618
    if (logger->isEnabledFor(level)) {\
2619
      logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2); }} while (0)
2620
2621
/**
2622
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.
2623
2624
@param logger the logger to be used.
2625
@param level The logging event level.
2626
@param key the key to be searched in the resourceBundle of the logger.
2627
@param p1 the first parameter.
2628
@param p2 the second parameter.
2629
@param p3 the third parameter.
2630
*/
2631
#define LOG4CXX_L7DLOG3(logger, level, key, p1, p2, p3) do { \
2632
    if (logger->isEnabledFor(level)) {\
2633
      logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2, p3); }} while (0)
2634
2635
/**@}*/
2636
2637
#include <log4cxx/spi/loggerrepository.h>
2638
2639
#endif //_LOG4CXX_LOGGER_H