Coverage Report

Created: 2025-10-10 06:52

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