Qore Logger Module Reference 0.5
Loading...
Searching...
No Matches
Logger.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* Logger.qm Copyright 2018 - 2023 Qore Technologies, s.r.o.
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23*/
24
25// minimum required Qore version
26
27
28
29
224namespace Logger {
226
231
232public:
234 const OFF = MAXINT;
236 const FATAL = 50000;
238 const ERROR = 40000;
240 const WARN = 30000;
242 const INFO = 20000;
244 const DEBUG = 10000;
246 const TRACE = 5000;
248 const ALL = MININT;
249
250private:
253
255 string levelStr;
256
258 static hash<string, LoggerLevel> levelMap;
259
262 'ALL': ALL,
263 'TRACE': TRACE,
264 'DEBUG': DEBUG,
265 'INFO': INFO,
266 'WARN': WARN,
267 'ERROR': ERROR,
268 'FATAL': FATAL,
269 'OFF': OFF,
270 };
271
273 const LEVEL_TO_LEVEL_STR = map {$1.value: $1.key}, LEVELSTR_TO_LEVEL.pairIterator();
274
275public:
276
278
282 constructor(int code, string str);
283
284
286 int getValue();
287
289 string getStr();
290
292
297
299
302 bool isEqual(LoggerLevel other);
303
306
309
312
315
318
321
324
327
329
337 static LoggerLevel getLevel(int level, *LoggerLevel default_level);
338
340
346 static *LoggerLevel getNextLowerLevel(int level);
347
349
355 static *LoggerLevel getNextHigherLevel(int level);
356
358
365 static LoggerLevel getLevel(string level_str, *LoggerLevel default_level);
366};
367
369
389
390public:
391private:
392 code callable;
393 *list<auto> args;
394
395public:
397
400 constructor(code func);
401
403
407 auto call();
408};
409
411
419
420public:
421private:
423 static date startTime = now_us();
424
426 string fqcn;
427
430
433
436
439
441 *list<auto> messageArgs;
442
445
448
451
453 *hash<CallStackInfo> locationInfo;
454
456 *hash<ExceptionInfo> throwableInfo;
457
460
462 static Sequence sequence(1);
463
464public:
465
467
479 constructor(Logger logger, LoggerLevel level, string message, *list<auto> args, *hash<CallStackInfo> location_info, int thread_id = gettid(), date time_stamp = now_us(), *hash<ExceptionInfo> throwable);
480
481
483
494 constructor(string fqcn, softstring category, LoggerLevel level, string message, *list<auto> args, *hash<CallStackInfo> location_info, int thread_id = gettid(), date time_stamp = now_us(), *hash<ExceptionInfo> throwable);
495
496
499
501 *hash<CallStackInfo> getLocationInfo();
502
505
508
511
514
516
523 string getMessage();
524
526 static date getStartTime();
527
529 static setStartTime(date time);
530
533
535
542
544 *hash<ExceptionInfo> getThrowableInfo();
545
548};
549
551
556
557public:
558private:
559 Queue queue();
560
561public:
562
564
570 bool push(LoggerAppender appender, int type, auto params);
571
573
584 process(timeout ms = 0);
585
587 int size();
588
590
601protected:
602 *hash<auto> getEvent(timeout ms);
603public:
604
605};
606
608
616
617public:
618private:
620 ThreadPool threadPool;
622 Counter runningCounter(0);
626 hash<auto> pendingEvents;
632 Sequence lastId(0);
634 Mutex lock();
635
636public:
637
639
644private:
645 worker(string id, LoggerAppender appender, list<auto> events);
646public:
647
648
650
654 constructor(ThreadPool tp, int max_threads = -1);
655
656
657 destructor();
658
659
661 ThreadPool getThreadPool();
662
664
676 process(timeout ms = 0);
677
679 int size();
680};
681
683
696
697public:
699 const EVENT_OPEN = 1;
701 const EVENT_LOG = 2;
703 const EVENT_CLOSE = 3;
704
705protected:
707 RWLock lock();
708
709public:
710
711private:
713 bool active = False;
714
716 list<LoggerFilter> filters;
717
719 string name;
720
723
724public:
725
727
731
732
733 destructor();
734
735
737 string getName();
738
740
749
752
754
758
761
763 bool isOpen();
764
766
772 addFilter(LoggerFilter filter, bool top = False);
773
775
779
782
784
787 list<LoggerFilter> getFilters();
788
790
796protected:
797 abstract auto serializeImpl(LoggerEvent event);
798public:
799
801
809protected:
810 bool pushEvent(int type, auto params);
811public:
812
813
815
826 bool post(LoggerEvent event);
827
829
835 processEvent(int type, auto params);
836
838
846 abstract processEventImpl(int type, auto params);
848protected:
849 *object ensureAtomicOperations(int type);
850public:
851
852};
853
855
859
860public:
861 constructor(*string name);
862
863
864protected:
866public:
867
868
869 processEventImpl(int type, auto params);
870};
871
873
939
940public:
942 const ESCAPE_CHAR = "%";
943
944private:
947
948public:
949
950protected:
952 list<auto> parsedPattern; // subclass may provide value e.g. for unit tests
953
954public:
955
957
961 constructor(string pattern);
962
963
965
969 setPattern(string value);
970
972 string getPattern();
973
975
979 string format(auto data);
980
982
989protected:
990 abstract *string resolveField(auto data, string key, *string option);
991public:
992};
993
995
999
1000public:
1002 abstract string format(LoggerEvent event);};
1003
1005
1097
1098public:
1100 const DEFAULT_PATTERN = "%r [%t] %p %c - %m%n";
1102 const DEFAULT_DATE_FORMAT = "YYYY-MM-DD HH:mm:SS.u";
1104 const HostName = gethostname();
1105
1107
1110 constructor(string pattern = DEFAULT_PATTERN);
1111
1112
1114 static string getLineDelimiter();
1115
1117
1120 string format(LoggerEvent event);
1121
1123
1128protected:
1129 *string resolveField(auto event, string key, *string option);
1130public:
1131
1132};
1133
1135
1142
1143public:
1144private:
1147
1148public:
1149
1151
1156
1157
1159
1163
1166
1168
1171protected:
1173public:
1174
1175};
1176
1178
1183
1184public:
1185private:
1187 StreamWriter writer;
1189 bool closed = False;
1192
1193public:
1194
1196
1201 constructor(*string name, LoggerLayout layout, StreamWriter writer);
1202
1203
1205 StreamWriter getStreamWriter();
1206
1209
1211 processEventImpl(int type, auto params);
1212};
1213
1215
1219
1220public:
1222 const EVENT_REOPEN = 1001;
1223
1224protected:
1225 File file;
1226 string fileName;
1227
1228public:
1229
1231
1237 constructor(*string name, LoggerLayout layout, string filename, *string encoding) ;
1238
1239
1241 File getFile();
1242
1244 string getFileName();
1245
1247
1251 processEventImpl(int type, auto params);
1252
1253 openFile();
1254
1255
1256 closeFile();
1257
1258
1259 reopen();
1260
1261
1263protected:
1264 *object ensureAtomicOperations(int type);
1265public:
1266
1267};
1268
1270
1275
1276public:
1278
1283
1284
1286
1290 processEventImpl(int type, auto params);
1291};
1292
1294
1299
1300public:
1302
1307
1308
1310
1314 processEventImpl(int type, auto params);
1315};
1316
1319
1320public:
1322 const EVENT_ROTATE = 10001;
1325
1326 constructor(*string name, LoggerLayout layout, *string encoding) : LoggerAppenderFile(name, layout, '', encoding) {}
1327
1328
1330 abstract int getCount();
1332protected:
1333 *object ensureAtomicOperations(int type);
1334public:
1335
1336};
1337
1339
1345
1346public:
1348 const DEFAULT_ARCHIVE_PATTERN = "%p%f.%i";
1349
1350private:
1351 int count;
1352
1353public:
1354
1356
1426 constructor(*string name, LoggerLayout layout, string filename, int count = DEFAULT_ROTATION_COUNT, string archive = DEFAULT_ARCHIVE_PATTERN, *string encoding)
1427 ;
1428
1429
1431
1438protected:
1439 *string resolveField(auto data, string key, *string option);
1440public:
1441
1442
1444
1448 processEventImpl(int type, auto params);
1449
1451
1454 string getArchiveFileName(int idx);
1455
1458};
1459
1461
1467
1468public:
1470 const DEFAULT_DATE_FORMAT = "YYYYMMDDHHmmSS";
1471
1472private:
1473 hash<auto> patternData;
1474
1475public:
1476
1478
1526 constructor(*string name, LoggerLayout layout, string pattern, int count = DEFAULT_ROTATION_COUNT, *string encoding);
1527
1528
1530
1537protected:
1538 *string resolveField(auto data, string key, *string option);
1539public:
1540
1541
1543
1547 processEventImpl(int type, auto params);
1548
1551
1554};
1555
1557
1564
1565public:
1567 const EVENT_ARCHIVE = 20;
1569 const DEFAULT_DATE_FORMAT = "YYYYMMDDHHmmSS";
1571 const DEFAULT_ARCHIVE_PATTERN = "%p%f.%d";
1572
1574
1640 constructor(*string name, LoggerLayout layout, string filename, string archive = DEFAULT_ARCHIVE_PATTERN, *string encoding);
1641
1642
1644
1651protected:
1652 *string resolveField(auto data, string key, *string option);
1653public:
1654
1655
1657
1661 processEventImpl(int type, auto params);
1662
1664
1670 string archive();
1671
1673
1678
1680protected:
1681 *object ensureAtomicOperations(int type);
1682public:
1683
1684};
1685
1687
1694
1695public:
1697 const ACCEPT = 1;
1698
1700 const NEUTRAL = 0;
1701
1703 const DENY = -1;
1704
1706
1713 int eval(LoggerEvent event);
1714};
1715
1717
1724
1725public:
1726private:
1731
1732public:
1733
1735
1740
1741
1743
1747 constructor(int min_value, int max_value = LoggerLevel::OFF);
1748
1749
1751
1755 constructor(string min_value, string max_value = 'OFF');
1756
1757
1759
1763
1765
1768 setMinLevel(int value);
1769
1771
1774 setMinLevel(string value);
1775
1778
1780
1784
1786
1789 setMaxLevel(int value);
1790
1792
1795 setMaxLevel(string value);
1796
1799
1801 int eval(LoggerEvent event);
1802};
1803
1805
1810
1811public:
1812private:
1814 string regexStr;
1817
1818public:
1819
1821
1825 constructor(string regex_str = '', bool regex_result = True);
1826
1827
1829
1833 setRegex(string regex_str, bool regex_result = True);
1834
1836 string getRegex();
1837
1840
1842 int eval(LoggerEvent event);
1843};
1844
1847
1848public:
1850
1856 abstract log(LoggerLevel level, string message);
1857
1859
1865 abstract log(int level, string message);
1866
1868
1874 abstract log(string level, string message);
1875
1877
1884 abstract logArgs(LoggerLevel level, string message, *softlist<auto> args);
1885
1887
1894 abstract logArgs(int level, string message, *softlist<auto> args);
1895
1897
1904 abstract logArgs(string level, string message, *softlist<auto> args);
1905
1907
1910 abstract logEvent(LoggerEvent event);
1911
1913
1919 abstract trace(string message, ...);
1920
1922
1928 abstract debug(string message, ...);
1929
1931
1937 abstract info(string message, ...);
1938
1940
1946 abstract warn(string message, ...);
1947
1949
1955 abstract error(string message, ...);
1956
1958
1964 abstract fatal(string message, ...);
1965
1967
1978 abstract assertLog(bool assertion, string message, ...);
1979
1981
1987 abstract traceVar(string var_name, auto value);
1988
1990
1996 abstract debugVar(string var_name, auto value);
1997
1999
2002 abstract bool isEnabledFor(LoggerLevel level);
2003
2005
2008 abstract bool isEnabledFor(int level);
2009
2011
2014 abstract bool isEnabledFor(string level);
2015
2017 abstract bool isTraceEnabled();
2018
2020 abstract bool isDebugEnabled();
2021
2023 abstract bool isInfoEnabled();
2024
2026 abstract bool isWarnEnabled();
2027
2029 abstract bool isErrorEnabled();
2030
2032 abstract bool isFatalEnabled();
2033};
2034
2037
2038public:
2039protected:
2042
2043public:
2044
2047
2048
2051
2052
2055
2056
2058
2064 log(LoggerLevel level, string message);
2065
2066
2068
2074 log(int level, string message);
2075
2076
2078
2084 log(string level, string message);
2085
2086
2088
2096 logArgs(LoggerLevel level, string message, *softlist<auto> args);
2097
2098
2100
2108 logArgs(int level, string message, *softlist<auto> args);
2109
2110
2112
2120 logArgs(string level, string message, *softlist<auto> args);
2121
2122
2124
2128
2129
2131
2137 trace(string message, ...);
2138
2139
2141
2147 debug(string message, ...);
2148
2149
2151
2157 info(string message, ...);
2158
2159
2161
2167 warn(string message, ...);
2168
2169
2171
2177 error(string message, ...);
2178
2179
2181
2187 fatal(string message, ...);
2188
2189
2191
2202 assertLog(bool assertion, string message, ...);
2203
2204
2206
2212 traceVar(string var_name, auto value);
2213
2214
2216
2222 debugVar(string var_name, auto value);
2223
2224
2226
2230
2231
2233
2236 bool isEnabledFor(int level);
2237
2238
2240
2243 bool isEnabledFor(string level);
2244
2245
2248
2249
2252
2253
2256
2257
2260
2261
2264
2265
2268
2269};
2270
2272
2278class Logger : public LoggerInterface {
2279
2280public:
2281private:
2283 transient RWLock lock();
2284
2286 static RWLock hierarchyLock();
2287
2289
2291 bool additivity = True;
2292
2295
2297 string name;
2298
2301
2303 transient list<LoggerAppender> appenders;
2304
2305public:
2306
2308
2311 constructor(string name = '');
2312
2313
2315
2319 constructor(string name, LoggerLevel level);
2320
2321
2323
2327
2328
2329 destructor();
2330
2331
2333 string getName();
2334
2337
2339
2344
2346
2350 *LoggerLevel getLevel(bool effective = True);
2351
2353
2357
2359
2362 setLevel(string level);
2363
2365
2368 setLevel(int level);
2369
2371
2375
2377
2381
2383
2386 setAdditivity(bool enable);
2387
2390
2392
2396
2398protected:
2399 hash<CallStackInfo> getLocation();
2400public:
2401
2402
2404
2409
2411
2415
2418
2420
2424 list<LoggerAppender> getAppenders();
2425
2426private:
2427 logIntern(LoggerLevel level, string message, *list<auto> args, *hash<CallStackInfo> location, bool check_throwable, date time_stamp = now_us());
2428public:
2429
2430
2431private:
2432 logIntern(LoggerLevel level, string message, *list<auto> args, *hash<CallStackInfo> location, *hash<ExceptionInfo> throwable, date time_stamp);
2433public:
2434
2435
2437
2443 log(LoggerLevel level, string message);
2444
2446
2452 log(int level, string message);
2453
2455
2461 log(string level, string message);
2462
2464
2471 logArgs(LoggerLevel level, string message, *softlist<auto> args);
2472
2474
2481 logArgs(int level, string message, *softlist<auto> args);
2482
2484
2491 logArgs(string level, string message, *softlist<auto> args);
2492
2494
2498
2500
2506 trace(string message, ...);
2507
2509
2515 debug(string message, ...);
2516
2518
2524 info(string message, ...);
2525
2527
2533 warn(string message, ...);
2534
2536
2542 error(string message, ...);
2543
2545
2551 fatal(string message, ...);
2552
2554
2565 assertLog(bool assertion, string message, ...);
2566
2568
2574 traceVar(string var_name, auto value);
2575
2577
2583 debugVar(string var_name, auto value);
2584
2586
2590
2592
2595 bool isEnabledFor(int level);
2596
2598
2601 bool isEnabledFor(string level);
2602
2605
2608
2611
2614
2617
2620};
2621
2623class LoggerRoot : public Logger {
2624
2625public:
2626 // Creates the object
2631
2632
2633 // Creates the object
2637 constructor(int level);
2638
2639
2640 // Creates the object
2644 constructor(string level);
2645
2646
2648
2655
2657
2661};
2662
2664
2667
2668public:
2669 constructor() ;
2670
2671
2672 processEventImpl(int type, auto params);
2673
2674};
2675};
Abstract class for file appenders with rotation support.
Definition: Logger.qm.dox.h:1318
const EVENT_ROTATE
rotate event
Definition: Logger.qm.dox.h:1322
const DEFAULT_ROTATION_COUNT
default value for rotation chain
Definition: Logger.qm.dox.h:1324
*object ensureAtomicOperations(int type)
Returns an object that can be used to ensure atomic operations for appender operations.
abstract int getCount()
Abstract method to get count of rotation objects.
Implements appender writing to a file with archive support.
Definition: Logger.qm.dox.h:1563
constructor(*string name, LoggerLayout layout, string filename, string archive=DEFAULT_ARCHIVE_PATTERN, *string encoding)
Creates the object.
*object ensureAtomicOperations(int type)
Returns an object that can be used to ensure atomic operations for appender operations.
processEventImpl(int type, auto params)
Implements archiving, handles the archive event directly, passes all other events to the subclass for...
const DEFAULT_DATE_FORMAT
default date format
Definition: Logger.qm.dox.h:1569
string archive()
Posts an archive event.
const EVENT_ARCHIVE
archive event
Definition: Logger.qm.dox.h:1567
const DEFAULT_ARCHIVE_PATTERN
default archive pattern
Definition: Logger.qm.dox.h:1571
*string resolveField(auto data, string key, *string option)
Returns a string for a format field for a pattern-based filename or archive file name.
string getArchiveFileName()
Returns the archive filename.
Implements appender writing to a file.
Definition: Logger.qm.dox.h:1218
processEventImpl(int type, auto params)
Processes open, close, and log events with the file and ignores all other events.
const EVENT_REOPEN
reopen event
Definition: Logger.qm.dox.h:1222
string getFileName()
Returns the current filename.
File getFile()
Returns the file object for the appender.
constructor(*string name, LoggerLayout layout, string filename, *string encoding)
Creates the object.
*object ensureAtomicOperations(int type)
Returns an object that can be used to ensure atomic operations for appender operations.
Implemants appender writing to a file with file circular rotation support.
Definition: Logger.qm.dox.h:1466
int getCount()
Returns number of files in ring.
const DEFAULT_DATE_FORMAT
default date format
Definition: Logger.qm.dox.h:1470
constructor(*string name, LoggerLayout layout, string pattern, int count=DEFAULT_ROTATION_COUNT, *string encoding)
Creates the object.
processEventImpl(int type, auto params)
Implements filename rotation; handles the open and rotate events directly; passes all other events to...
*string resolveField(auto data, string key, *string option)
Returns a string for a format field for a pattern-based filename.
int getCurrentIndex()
Returns current ring index being used for logging.
Implements appender writing to a file with file rotation support.
Definition: Logger.qm.dox.h:1344
string getArchiveFileName(int idx)
Returns the archive filename.
const DEFAULT_ARCHIVE_PATTERN
default archive pattern
Definition: Logger.qm.dox.h:1348
processEventImpl(int type, auto params)
Implements filename rotation; handles the open and rotate events directly; passes all other events to...
*string resolveField(auto data, string key, *string option)
Returns a string for a format field for a pattern-based filename.
int getCount()
Returns max.number of files in chain.
constructor(*string name, LoggerLayout layout, string filename, int count=DEFAULT_ROTATION_COUNT, string archive=DEFAULT_ARCHIVE_PATTERN, *string encoding)
Creates the object.
Implements passing LoggerEvent to target destination.
Definition: Logger.qm.dox.h:695
*LoggerAppenderQueue queue
async queue
Definition: Logger.qm.dox.h:722
RWLock lock()
The lock to ensure proper serialization with concurrent access.
const EVENT_LOG
logging event
Definition: Logger.qm.dox.h:701
setQueue(*LoggerAppenderQueue queue)
Sets the appender queue.
removeFilter(LoggerFilter filter)
Removes the given filter from the filter chain.
bool isOpen()
Returns True if the appender is open and therefore active.
close()
Releases any resources allocated by the appender and closes it.
constructor(*string name)
Creates the object.
addFilter(LoggerFilter filter, bool top=False)
Adds a filter to the chain.
string getName()
Returns the appender name.
open()
Opens logging resources.
processEvent(int type, auto params)
Processes an event to the physical target.
abstract auto serializeImpl(LoggerEvent event)
Serializes the given event to put in the queue or write to the target device.
list< LoggerFilter > filters
filter chain
Definition: Logger.qm.dox.h:716
abstract processEventImpl(int type, auto params)
Processes the event to the physical target.
bool active
An inactive appender won't accept any logging request.
Definition: Logger.qm.dox.h:713
*object ensureAtomicOperations(int type)
Returns an object that can be used to ensure atomic operations for appender operations.
string name
Appender name.
Definition: Logger.qm.dox.h:719
bool pushEvent(int type, auto params)
Pushes the given event on the queue or calls processEvent() in case of synchronous processing.
removeAllFilters()
Clears the filter chain by removing all filters.
*LoggerAppenderQueue getQueue()
Returns async queue or NOTHING when events are processed synchronously.
bool post(LoggerEvent event)
Posts the given event to the output queue.
const EVENT_OPEN
open event
Definition: Logger.qm.dox.h:699
const EVENT_CLOSE
close event
Definition: Logger.qm.dox.h:703
list< LoggerFilter > getFilters()
Returns the filter chain as a list.
Implements appender which does nothing.
Definition: Logger.qm.dox.h:858
processEventImpl(int type, auto params)
Processes the event to the physical target.
auto serializeImpl(LoggerEvent event)
Serializes the given event to put in the queue or write to the target device.
Implements queue serializing async appender events.
Definition: Logger.qm.dox.h:555
process(timeout ms=0)
Processes queued events.
int size()
Returns the current number of events waiting in queue.
*hash< auto > getEvent(timeout ms)
Returns the next event from queue or NOTHING if there is no event available within the timeout period...
bool push(LoggerAppender appender, int type, auto params)
Adds appender event.
Handles the processing for asynchronous appender events in multiple threads.
Definition: Logger.qm.dox.h:615
worker(string id, LoggerAppender appender, list< auto > events)
Implements worker thread code.
constructor(ThreadPool tp, int max_threads=-1)
Creates the object.
Counter runningCounter(0)
number of running worker threads
process(timeout ms=0)
Processes queue events.
Sequence lastId(0)
internal unique counter
hash< auto > pendingEvents
events removed from queue but not passed to worker thread
Definition: Logger.qm.dox.h:626
Mutex lock()
to protect process()
ThreadPool threadPool
worker thread pool
Definition: Logger.qm.dox.h:620
Queue finishedEvents()
queue of processed events in worker threads
ThreadPool getThreadPool()
Returns the assigned ThreadPool.
int size()
Gets number of pending events.
hash< auto > processingEvents
events paseed to worker thread
Definition: Logger.qm.dox.h:628
int maxThreads
max.number of worker threads
Definition: Logger.qm.dox.h:624
Implements appender writing to a stderr file.
Definition: Logger.qm.dox.h:1298
constructor(*string name, LoggerLayout layout)
Creates the object.
processEventImpl(int type, auto params)
Processes log events with the file and ignores all other events including open, close.
Implements appender writing to a stdout file.
Definition: Logger.qm.dox.h:1274
processEventImpl(int type, auto params)
Processes log events with the file and ignores all other events including open, close.
constructor(*string name, LoggerLayout layout)
Creates the object.
implements appender writing to an output stream via StreamWriter
Definition: Logger.qm.dox.h:1182
bool closed
closed flag
Definition: Logger.qm.dox.h:1189
bool hasAssignThread()
Returns True if assigning a thread for a stream.
constructor(*string name, LoggerLayout layout, StreamWriter writer)
Creates the object.
StreamWriter getStreamWriter()
Returns the stream writer object.
bool assignThread
assign thread for stream
Definition: Logger.qm.dox.h:1191
processEventImpl(int type, auto params)
Processes open, log, and close events with the output stream; all other events are ignored.
StreamWriter writer
stream writer
Definition: Logger.qm.dox.h:1187
Implements an appender with a layout.
Definition: Logger.qm.dox.h:1141
constructor(*string name, LoggerLayout layout)
Creates the object.
LoggerLayout layout
assigned layout
Definition: Logger.qm.dox.h:1146
auto serializeImpl(LoggerEvent event)
Returns the value formatted using the layout pattern.
LoggerLayout getLayout()
Returns the layout for the appender.
setLayout(LoggerLayout layout)
Assigns a layout to the appender.
Implements an event to be logged.
Definition: Logger.qm.dox.h:418
*string renderedMessage
The application supplied message rendered through the rendering mechanism.
Definition: Logger.qm.dox.h:444
string getFullQualifiedClassname()
Returns the full qualified classname.
*hash< ExceptionInfo > getThrowableInfo()
Returns throwable info, if any.
LoggerLevel level
Level of the logging event.
Definition: Logger.qm.dox.h:435
constructor(string fqcn, softstring category, LoggerLevel level, string message, *list< auto > args, *hash< CallStackInfo > location_info, int thread_id=gettid(), date time_stamp=now_us(), *hash< ExceptionInfo > throwable)
Instantiates a LoggingEvent from the supplied parameters.
LoggerLevel getLevel()
Returns the level of this event.
*Logger getLogger()
Returns the logger which created the event.
*hash< ExceptionInfo > throwableInfo
internal representation of throwable
Definition: Logger.qm.dox.h:456
date timeStamp
event time stamp
Definition: Logger.qm.dox.h:450
date getTimeStamp()
Returns the event timestamp as an absolute date/time value.
static date startTime
origin stamp to calculate relative time
Definition: Logger.qm.dox.h:423
static setStartTime(date time)
Sets the starting time for relative time.
constructor(Logger logger, LoggerLevel level, string message, *list< auto > args, *hash< CallStackInfo > location_info, int thread_id=gettid(), date time_stamp=now_us(), *hash< ExceptionInfo > throwable)
Instantiates a LoggingEvent from the supplied parameters.
static Sequence sequence(1)
unique id generator
static date getStartTime()
Returns the time when the application/logger started to calculate relative time.
string categoryName
The category (logger) name.
Definition: Logger.qm.dox.h:432
string messageFmt
The application supplied message of logging event (not rendered)
Definition: Logger.qm.dox.h:438
int threadId
related thread id
Definition: Logger.qm.dox.h:447
*hash< CallStackInfo > locationInfo
location information where the logging was performed.
Definition: Logger.qm.dox.h:453
*hash< CallStackInfo > getLocationInfo()
Returns the location information for this logging event.
*Logger logger
Logger reference.
Definition: Logger.qm.dox.h:429
int getThreadId()
Returns the thread id which is related to event.
int uniqueId
unique id
Definition: Logger.qm.dox.h:459
int getUniqueId()
Generates a globally unique integer identifier and associates it to the event.
*list< auto > messageArgs
arguments to be rendered
Definition: Logger.qm.dox.h:441
string getMessage()
Returns the string message for the logging event.
string fqcn
Fully Qualified Class Name of the calling category class.
Definition: Logger.qm.dox.h:426
string getCategoryName()
Returns the category name.
date getRelativeTime()
Returns a relative timestamp for the event.
Implements callable parameter which is evaluated in run-time when event is rendered.
Definition: Logger.qm.dox.h:388
constructor(code func)
Creates object.
auto call()
Call function with arguments provided.
Implements a general event filtering class.
Definition: Logger.qm.dox.h:1693
const NEUTRAL
No decision could be made, further filtering should occur.
Definition: Logger.qm.dox.h:1700
const DENY
The event should not be processed.
Definition: Logger.qm.dox.h:1703
const ACCEPT
The event will be processed.
Definition: Logger.qm.dox.h:1697
int eval(LoggerEvent event)
Performs filtering logic on an event and returns the decision for the event.
Implements the filter according event LoggerLevel.
Definition: Logger.qm.dox.h:1723
int eval(LoggerEvent event)
Implements filtering by level.
setMinLevel(LoggerLevel value)
Sets the minimum logging level.
setMaxLevel(string value)
Sets the maximum logging level.
LoggerLevel maxLevel
max.level
Definition: Logger.qm.dox.h:1730
setMinLevel(int value)
Sets the minimum logging level.
constructor(LoggerLevel min_value=LoggerLevel::getLevelInfo(), LoggerLevel max_value=LoggerLevel::getLevelOff())
Creates the object.
constructor(string min_value, string max_value='OFF')
Creates the object.
setMaxLevel(LoggerLevel value)
Sets the maximum logging level.
setMinLevel(string value)
Sets the minimum logging level.
LoggerLevel getMaxLevel()
Returns the maximum logging level.
setMaxLevel(int value)
Sets the maximum logging level.
LoggerLevel getMinLevel()
Returns the minimum logging level.
LoggerLevel minLevel
min.level
Definition: Logger.qm.dox.h:1728
constructor(int min_value, int max_value=LoggerLevel::OFF)
Creates the object.
Implements filtering according to a regular expression on the event message.
Definition: Logger.qm.dox.h:1809
int eval(LoggerEvent event)
Evaluates the regex and compares with the expected result.
constructor(string regex_str='', bool regex_result=True)
Creates the object.
string regexStr
regular string
Definition: Logger.qm.dox.h:1814
setRegex(string regex_str, bool regex_result=True)
Sets the regular expression and the expected result for the filter.
string getRegex()
Returns the current regex.
bool getRegexResult()
Returns the expected result.
bool regexResult
expected result
Definition: Logger.qm.dox.h:1816
string getName()
Returns the logger name.
debug(string message,...)
Logs a message object with the DEBUG level.
error(string message,...)
Logs a message object with the ERROR level.
list< LoggerAppender > getAppenders()
Returns the appender list.
addAppender(LoggerAppender appender)
Adds an appender to the appender list.
debugVar(string var_name, auto value)
Logs the variable name and value using DEBUG level.
bool isFatalEnabled()
Checks whether this Logger is enabled for the FATAL Level.
bool isInfoEnabled()
Checks whether this Logger is enabled for the INFO Level.
*LoggerLevel getLevel(bool effective=True)
Returns the logging level.
*LoggerLevel incLevel()
Increment logger level.
*Logger getParent()
Returns the parent logger, if any.
setParent(*Logger value)
Sets the parent logger.
setLevel(int level)
Sets the logging level.
constructor(string name, LoggerLevel level)
Creates the object.
logArgs(int level, string message, *softlist< auto > args)
Logs a message using the provided logging level and a single argument for any format string arguments...
logArgs(LoggerLevel level, string message, *softlist< auto > args)
Logs a message using the provided logging level and a single argument for any format string arguments...
static RWLock hierarchyLock()
The lock to protect access to parent/child hierarchy.
info(string message,...)
Logs a message object with the INFO level.
logArgs(string level, string message, *softlist< auto > args)
Logs a message using the provided logging level and a single argument for any format string arguments...
fatal(string message,...)
Logs a message object with the FATAL level.
bool isEnabledFor(string level)
Checks whether this Logger is enabled for a given Level passed as parameter.
bool getAdditivity()
Returns the additivity flag.
bool isEnabledFor(LoggerLevel level)
Checks whether this Logger is enabled for a given Level passed as parameter.
string name
The name of this Logger instance.
Definition: Logger.qm.dox.h:2297
transient list< LoggerAppender > appenders
A collection of appenders linked to this logger.
Definition: Logger.qm.dox.h:2303
constructor(string name='')
Creates the object.
transient RWLock lock()
The lock to protect object manipulation.
bool isErrorEnabled()
Checks whether this Logger is enabled for the ERROR Level.
hash< CallStackInfo > getLocation()
Returns the call location where the log function was called from.
*LoggerLevel currentLevel
The assigned Logger level. If NOTHING, the parent level is used.
Definition: Logger.qm.dox.h:2294
setLevel(*LoggerLevel level)
Sets the logging level.
bool isTraceEnabled()
Checks whether this Logger is enabled for the TRACE Level.
warn(string message,...)
Logs a message object with the WARN level.
setLevel(string level)
Sets the logging level.
logEvent(LoggerEvent event)
Logs an already prepared logging event object.
log(int level, string message)
Logs a message using the provided logging level.
trace(string message,...)
Logs a message object with the TRACE level.
*Logger parent
The parent logger. Unassigned if this is the root logger.
Definition: Logger.qm.dox.h:2300
traceVar(string var_name, auto value)
Logs the variable name and value using TRACE level.
bool isWarnEnabled()
Checks whether this Logger is enabled for the WARN Level.
removeAllAppenders()
Clears the appender list by removing all appenders.
callAppenders(LoggerEvent event)
Forwards the given logging event to all linked appenders.
assertLog(bool assertion, string message,...)
Performs logging of assertions.
*LoggerLevel decLevel()
Decrement logger level.
setAdditivity(bool enable)
Sets the additivity flag; when additivity is active, events are passed to parent loggers.
bool isEnabledFor(int level)
Checks whether this Logger is enabled for a given Level passed as parameter.
constructor(LoggerLevel level)
Creates the object with an empty name and the given initial level.
bool isDebugEnabled()
Checks whether this Logger is enabled for the DEBUG Level.
log(LoggerLevel level, string message)
Logs a message using the provided logging level.
log(string level, string message)
Logs a message using the provided logging level.
removeAppender(LoggerAppender appender)
Removes the appender from the list.
This abstract class defines the logging interface.
Definition: Logger.qm.dox.h:1846
abstract warn(string message,...)
Logs a message object with the WARN level.
abstract logEvent(LoggerEvent event)
Logs an already prepared logging event object.
abstract bool isEnabledFor(int level)
Checks whether this Logger is enabled for a given Level passed as parameter.
abstract trace(string message,...)
Logs a message object with the TRACE level.
abstract bool isInfoEnabled()
Checks whether this Logger is enabled for the INFO Level.
abstract bool isEnabledFor(LoggerLevel level)
Checks whether this Logger is enabled for a given Level passed as parameter.
abstract debug(string message,...)
Logs a message object with the DEBUG level.
abstract logArgs(int level, string message, *softlist< auto > args)
Logs a message using the provided logging level and a single argument for any format string arguments...
abstract logArgs(string level, string message, *softlist< auto > args)
Logs a message using the provided logging level and a single argument for any format string arguments...
abstract bool isFatalEnabled()
Checks whether this Logger is enabled for the FATAL Level.
abstract error(string message,...)
Logs a message object with the ERROR level.
abstract bool isEnabledFor(string level)
Checks whether this Logger is enabled for a given Level passed as parameter.
abstract bool isErrorEnabled()
Checks whether this Logger is enabled for the ERROR Level.
abstract assertLog(bool assertion, string message,...)
Performs logging of assertions.
abstract info(string message,...)
Logs a message object with the INFO level.
abstract traceVar(string var_name, auto value)
Logs the variable name and value using TRACE level.
abstract log(string level, string message)
Logs a message using the provided logging level.
abstract bool isTraceEnabled()
Checks whether this Logger is enabled for the TRACE Level.
abstract debugVar(string var_name, auto value)
Logs the variable name and value using DEBUG level.
abstract fatal(string message,...)
Logs a message object with the FATAL level.
abstract bool isWarnEnabled()
Checks whether this Logger is enabled for the WARN Level.
abstract log(LoggerLevel level, string message)
Logs a message using the provided logging level.
abstract bool isDebugEnabled()
Checks whether this Logger is enabled for the DEBUG Level.
abstract log(int level, string message)
Logs a message using the provided logging level.
abstract logArgs(LoggerLevel level, string message, *softlist< auto > args)
Logs a message using the provided logging level and a single argument for any format string arguments...
Abstract class that defines the interface for logger layouts.
Definition: Logger.qm.dox.h:998
abstract string format(LoggerEvent event)
Format event record.
Implements the formatting of LoggerEvent objects with a pattern.
Definition: Logger.qm.dox.h:1096
const HostName
This hostname.
Definition: Logger.qm.dox.h:1104
const DEFAULT_PATTERN
default layout pattern
Definition: Logger.qm.dox.h:1100
string format(LoggerEvent event)
Formats an event record.
*string resolveField(auto event, string key, *string option)
Returns the value corresponding to a particular key.
static string getLineDelimiter()
Returns the line delimiter used on the current OS.
const DEFAULT_DATE_FORMAT
default date format
Definition: Logger.qm.dox.h:1102
constructor(string pattern=DEFAULT_PATTERN)
Creates the object.
Defines the minimum set of levels recognized by the system.
Definition: Logger.qm.dox.h:230
const LEVELSTR_TO_LEVEL
String to int hash.
Definition: Logger.qm.dox.h:261
string getStr()
Gets level string.
string levelStr
String representation of the level.
Definition: Logger.qm.dox.h:255
const FATAL
Logger level for fatal errors.
Definition: Logger.qm.dox.h:236
const ERROR
Logger level for (non-fatal) errors.
Definition: Logger.qm.dox.h:238
static hash< string, LoggerLevel > levelMap
Contains a list of instantiated levels.
Definition: Logger.qm.dox.h:258
const TRACE
Logger level for trace messages.
Definition: Logger.qm.dox.h:246
static LoggerLevel getLevelTrace()
Returns a TRACE Level.
bool isEqual(LoggerLevel other)
Compares two logger levels.
static LoggerLevel getLevelWarn()
Returns a WARN Level.
const DEBUG
Logger level for debugging messages.
Definition: Logger.qm.dox.h:244
const OFF
The highest logger level.
Definition: Logger.qm.dox.h:234
static *LoggerLevel getNextLowerLevel(int level)
Returns closest lower logger level.
static LoggerLevel getLevelAll()
Returns an ALL Level.
static LoggerLevel getLevelOff()
Returns an OFF Level.
static LoggerLevel getLevel(int level, *LoggerLevel default_level)
Converts the input argument to a level.
int getValue()
Gets level code value.
const LEVEL_TO_LEVEL_STR
Int to string hash.
Definition: Logger.qm.dox.h:273
int levelCode
Integer level value.
Definition: Logger.qm.dox.h:252
static LoggerLevel getLevel(string level_str, *LoggerLevel default_level)
Converts the input argument to a level.
constructor(int code, string str)
Creates a new object.
static LoggerLevel getLevelFatal()
Returns a FATAL Level.
static LoggerLevel getLevelError()
Returns an ERROR Level.
static LoggerLevel getLevelInfo()
Returns an INFO Level.
const INFO
Logger level for informational messages.
Definition: Logger.qm.dox.h:242
bool isGreaterOrEqual(LoggerLevel other)
Compares logger levels.
const WARN
Logger level for warnings.
Definition: Logger.qm.dox.h:240
static LoggerLevel getLevelDebug()
Returns a DEBUG Level.
const ALL
The lowest logger level.
Definition: Logger.qm.dox.h:248
static *LoggerLevel getNextHigherLevel(int level)
Returns closest higher logger level.
Implements pattern parsing and substitution.
Definition: Logger.qm.dox.h:938
string origPattern
pattern
Definition: Logger.qm.dox.h:946
setPattern(string value)
Sets the new pattern.
string getPattern()
Returns the current pattern.
list< auto > parsedPattern
parsed pattern; list elements may be strings or hashes
Definition: Logger.qm.dox.h:952
constructor(string pattern)
Creates the object.
string format(auto data)
Formats the event record with the current pattern.
abstract *string resolveField(auto data, string key, *string option)
Returns a formatted string for an input pattern.
const ESCAPE_CHAR
format escape character
Definition: Logger.qm.dox.h:942
Implements the root class for loggers; does not allow a parent logger to be set.
Definition: Logger.qm.dox.h:2623
setParent(*Logger value)
Overrides value setter as the root logger cannot have a parent; this method always throws an exceptio...
constructor(string level)
constructor(int level)
setLevel(*LoggerLevel value)
Overrides the level setter to prevent setting the root logger's level to NOTHING (an exception is thr...
constructor(LoggerLevel level=LoggerLevel::getLevelAll())
Class handling a LoggerInterface object as a member and providing atomic logging through it.
Definition: Logger.qm.dox.h:2036
constructor()
Creates the object with no logger.
warn(string message,...)
Logs a message object with the WARN level.
log(int level, string message)
Logs a message using the provided logging level if a logger is set.
log(string level, string message)
Logs a message using the provided logging level if a logger is set.
debug(string message,...)
Logs a message object with the DEBUG level.
log(LoggerLevel level, string message)
Logs a message using the provided logging level if a logger is set.
logArgs(LoggerLevel level, string message, *softlist< auto > args)
Logs a message using the provided logging level and a single argument for any format string arguments...
fatal(string message,...)
Logs a message object with the FATAL level.
traceVar(string var_name, auto value)
Logs the variable name and value using TRACE level.
bool isDebugEnabled()
Checks whether this Logger is enabled for the DEBUG Level.
bool isEnabledFor(int level)
Checks whether this Logger is enabled for a given Level passed as parameter.
debugVar(string var_name, auto value)
Logs the variable name and value using DEBUG level.
logArgs(string level, string message, *softlist< auto > args)
Logs a message using the provided logging level and a single argument for any format string arguments...
bool isErrorEnabled()
Checks whether this Logger is enabled for the ERROR Level.
bool isEnabledFor(LoggerLevel level)
Checks whether this Logger is enabled for a given Level passed as parameter.
logArgs(int level, string message, *softlist< auto > args)
Logs a message using the provided logging level and a single argument for any format string arguments...
trace(string message,...)
Logs a message object with the TRACE level.
error(string message,...)
Logs a message object with the ERROR level.
setLogger(*LoggerInterface logger)
Accepts a LoggerInterface object for logging (or clears it)
transient *LoggerInterface logger
The logger interface.
Definition: Logger.qm.dox.h:2041
constructor(LoggerInterface logger)
Creates the object with a logger.
bool isFatalEnabled()
Checks whether this Logger is enabled for the FATAL Level.
bool isInfoEnabled()
Checks whether this Logger is enabled for the INFO Level.
bool isEnabledFor(string level)
Checks whether this Logger is enabled for a given Level passed as parameter.
bool isTraceEnabled()
Checks whether this Logger is enabled for the TRACE Level.
info(string message,...)
Logs a message object with the INFO level.
logEvent(LoggerEvent event)
Logs an already prepared logging event object.
assertLog(bool assertion, string message,...)
Performs logging of assertions.
bool isWarnEnabled()
Checks whether this Logger is enabled for the WARN Level.
Appender for logging to the console.
Definition: Logger.qm.dox.h:2666
processEventImpl(int type, auto params)
Processes the event to the physical target.
The Logger namespace contains all the definitions in the Logger module.
Definition: Logger.qm.dox.h:224