Coverage Report

Created: 2026-09-21 07:05

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