Coverage Report

Created: 2025-07-01 06:08

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