Qore Logger Module Reference 0.6
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
229namespace Logger {
231
236
237public:
239 const OFF = MAXINT;
241 const FATAL = 50000;
243 const ERROR = 40000;
245 const WARN = 30000;
247 const INFO = 20000;
249 const DEBUG = 10000;
251 const TRACE = 5000;
253 const ALL = MININT;
254
255private:
258
260 string levelStr;
261
263 static hash<string, LoggerLevel> levelMap;
264
267 'ALL': ALL,
268 'TRACE': TRACE,
269 'DEBUG': DEBUG,
270 'INFO': INFO,
271 'WARN': WARN,
272 'ERROR': ERROR,
273 'FATAL': FATAL,
274 'OFF': OFF,
275 };
276
278 const LEVEL_TO_LEVEL_STR = map {$1.value: $1.key}, LEVELSTR_TO_LEVEL.pairIterator();
279
280public:
281
283
287 constructor(int code, string str);
288
289
291 int getValue();
292
294 string getStr();
295
297
302
304
307 bool isEqual(LoggerLevel other);
308
311
314
317
320
323
326
329
332
334
342 static LoggerLevel getLevel(int level, *LoggerLevel default_level);
343
345
351 static *LoggerLevel getNextLowerLevel(int level);
352
354
360 static *LoggerLevel getNextHigherLevel(int level);
361
363
370 static LoggerLevel getLevel(string level_str, *LoggerLevel default_level);
371};
372
374
394
395public:
396private:
397 code callable;
398 *list<auto> args;
399
400public:
402
405 constructor(code func);
406
408
412 auto call();
413};
414
416
424
425public:
426private:
428 static date startTime = now_us();
429
431 string fqcn;
432
435
438
441
444
446 *list<auto> messageArgs;
447
450
453
456
458 *hash<CallStackInfo> locationInfo;
459
461 *hash<ExceptionInfo> throwableInfo;
462
465
467 static Sequence sequence(1);
468
469public:
470
472
484 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);
485
486
488
499 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);
500
501
504
506 *hash<CallStackInfo> getLocationInfo();
507
510
513
516
519
521
528 string getMessage();
529
531 static date getStartTime();
532
534 static setStartTime(date time);
535
538
540
547
549 *hash<ExceptionInfo> getThrowableInfo();
550
553};
554
556
561
562public:
563private:
564 Queue queue();
565
566public:
567
569
575 bool push(LoggerAppender appender, int type, auto params);
576
578
589 process(timeout ms = 0);
590
592 int size();
593
595
606protected:
607 *hash<auto> getEvent(timeout ms);
608public:
609
610};
611
613
621
622public:
623private:
625 ThreadPool threadPool;
627 Counter runningCounter(0);
631 hash<auto> pendingEvents;
637 Sequence lastId(0);
639 Mutex lock();
640
641public:
642
644
649private:
650 worker(string id, LoggerAppender appender, list<auto> events);
651public:
652
653
655
659 constructor(ThreadPool tp, int max_threads = -1);
660
661
662 destructor();
663
664
666 ThreadPool getThreadPool();
667
669
681 process(timeout ms = 0);
682
684 int size();
685};
686
688
701
702public:
704 const EVENT_OPEN = 1;
706 const EVENT_LOG = 2;
708 const EVENT_CLOSE = 3;
709
710protected:
712 RWLock lock();
713
714public:
715
716private:
718 bool active = False;
719
721 list<LoggerFilter> filters;
722
724 string name;
725
728
729public:
730
732
736
737
738 destructor();
739
740
742 string getName();
743
745
754
757
759
763
766
768 bool isOpen();
769
771
777 addFilter(LoggerFilter filter, bool top = False);
778
780
784
787
789
792 list<LoggerFilter> getFilters();
793
795
801protected:
802 abstract auto serializeImpl(LoggerEvent event);
803public:
804
806
814protected:
815 bool pushEvent(int type, auto params);
816public:
817
818
820
831 bool post(LoggerEvent event);
832
834
840 processEvent(int type, auto params);
841
843
851 abstract processEventImpl(int type, auto params);
853protected:
854 *object ensureAtomicOperations(int type);
855public:
856
857};
858
860
864
865public:
866 constructor(*string name);
867
868
869protected:
871public:
872
873
874 processEventImpl(int type, auto params);
875};
876
878
944
945public:
947 const ESCAPE_CHAR = "%";
948
949private:
952
953public:
954
955protected:
957 list<auto> parsedPattern; // subclass may provide value e.g. for unit tests
958
959public:
960
962
966 constructor(string pattern);
967
968
970
974 setPattern(string value);
975
977 string getPattern();
978
980
984 string format(auto data);
985
987
994protected:
995 abstract *string resolveField(auto data, string key, *string option);
996public:
997};
998
1000
1004
1005public:
1007 abstract string format(LoggerEvent event);};
1008
1010
1102
1103public:
1105 const DEFAULT_PATTERN = "%r [%t] %p %c - %m%n";
1107 const DEFAULT_DATE_FORMAT = "YYYY-MM-DD HH:mm:SS.u";
1109 const HostName = gethostname();
1110
1112
1115 constructor(string pattern = DEFAULT_PATTERN);
1116
1117
1119 static string getLineDelimiter();
1120
1122
1125 string format(LoggerEvent event);
1126
1128
1133protected:
1134 *string resolveField(auto event, string key, *string option);
1135public:
1136
1137};
1138
1140
1147
1148public:
1149private:
1152
1153public:
1154
1156
1161
1162
1164
1168
1171
1173
1176protected:
1178public:
1179
1180};
1181
1183
1188
1189public:
1190private:
1192 StreamWriter writer;
1194 bool closed = False;
1197
1198public:
1199
1201
1206 constructor(*string name, LoggerLayout layout, StreamWriter writer);
1207
1208
1210 StreamWriter getStreamWriter();
1211
1214
1216 processEventImpl(int type, auto params);
1217};
1218
1220
1224
1225public:
1227 const EVENT_REOPEN = 1001;
1228
1230 const DEFAULT_OPEN_FLAGS = O_CREAT | O_APPEND | O_WRONLY;
1231
1232protected:
1233 File file;
1234 string fileName;
1235 *string encoding;
1236
1237public:
1238
1240
1246 constructor(*string name, LoggerLayout layout, string filename, *string encoding) ;
1247
1248
1250 File getFile();
1251
1253 string getFileName();
1254
1256
1260 processEventImpl(int type, auto params);
1261
1262 openFile();
1263
1264
1265 closeFile();
1266
1267
1268 static closeFileStatic(File file);
1269
1270 reopen();
1271
1272};
1273
1275
1280
1281public:
1283
1288
1289
1291
1295 processEventImpl(int type, auto params);
1296};
1297
1299
1304
1305public:
1307
1312
1313
1315
1319 processEventImpl(int type, auto params);
1320};
1321
1324
1325public:
1327 const EVENT_ROTATE = 10001;
1330
1331 constructor(*string name, LoggerLayout layout, *string encoding) : LoggerAppenderFile(name, layout, '', encoding) {}
1332
1333
1335 abstract int getCount();};
1336
1338
1344
1345public:
1347 const DEFAULT_ARCHIVE_PATTERN = "%p%f.%i";
1348
1349private:
1350 int count;
1351
1352public:
1353
1355
1425 constructor(*string name, LoggerLayout layout, string filename, int count = DEFAULT_ROTATION_COUNT, string archive = DEFAULT_ARCHIVE_PATTERN, *string encoding)
1426 ;
1427
1428
1430
1437protected:
1438 *string resolveField(auto data, string key, *string option);
1439public:
1440
1441
1443
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};
1679
1681
1688
1689public:
1691 const ACCEPT = 1;
1692
1694 const NEUTRAL = 0;
1695
1697 const DENY = -1;
1698
1700
1707 int eval(LoggerEvent event);
1708};
1709
1711
1718
1719public:
1720private:
1725
1726public:
1727
1729
1734
1735
1737
1741 constructor(int min_value, int max_value = LoggerLevel::OFF);
1742
1743
1745
1749 constructor(string min_value, string max_value = 'OFF');
1750
1751
1753
1757
1759
1762 setMinLevel(int value);
1763
1765
1768 setMinLevel(string value);
1769
1772
1774
1778
1780
1783 setMaxLevel(int value);
1784
1786
1789 setMaxLevel(string value);
1790
1793
1795 int eval(LoggerEvent event);
1796};
1797
1799
1804
1805public:
1806private:
1808 string regexStr;
1811
1812public:
1813
1815
1819 constructor(string regex_str = '', bool regex_result = True);
1820
1821
1823
1827 setRegex(string regex_str, bool regex_result = True);
1828
1830 string getRegex();
1831
1834
1836 int eval(LoggerEvent event);
1837};
1838
1841
1842public:
1844
1850 abstract log(LoggerLevel level, string message);
1851
1853
1859 abstract log(int level, string message);
1860
1862
1868 abstract log(string level, string message);
1869
1871
1878 abstract logArgs(LoggerLevel level, string message, *softlist<auto> args);
1879
1881
1888 abstract logArgs(int level, string message, *softlist<auto> args);
1889
1891
1898 abstract logArgs(string level, string message, *softlist<auto> args);
1899
1901
1904 abstract logEvent(LoggerEvent event);
1905
1907
1913 abstract trace(string message, ...);
1914
1916
1922 abstract debug(string message, ...);
1923
1925
1931 abstract info(string message, ...);
1932
1934
1940 abstract warn(string message, ...);
1941
1943
1949 abstract error(string message, ...);
1950
1952
1958 abstract fatal(string message, ...);
1959
1961
1972 abstract assertLog(bool assertion, string message, ...);
1973
1975
1981 abstract traceVar(string var_name, auto value);
1982
1984
1990 abstract debugVar(string var_name, auto value);
1991
1993
1996 abstract bool isEnabledFor(LoggerLevel level);
1997
1999
2002 abstract bool isEnabledFor(int level);
2003
2005
2008 abstract bool isEnabledFor(string level);
2009
2011 abstract bool isTraceEnabled();
2012
2014 abstract bool isDebugEnabled();
2015
2017 abstract bool isInfoEnabled();
2018
2020 abstract bool isWarnEnabled();
2021
2023 abstract bool isErrorEnabled();
2024
2026 abstract bool isFatalEnabled();
2027};
2028
2031
2032public:
2033protected:
2036
2037public:
2038
2041
2042
2045
2046
2049
2050
2052
2058 log(LoggerLevel level, string message);
2059
2060
2062
2068 log(int level, string message);
2069
2070
2072
2078 log(string level, string message);
2079
2080
2082
2090 logArgs(LoggerLevel level, string message, *softlist<auto> args);
2091
2092
2094
2102 logArgs(int level, string message, *softlist<auto> args);
2103
2104
2106
2114 logArgs(string level, string message, *softlist<auto> args);
2115
2116
2118
2122
2123
2125
2131 trace(string message, ...);
2132
2133
2135
2141 debug(string message, ...);
2142
2143
2145
2151 info(string message, ...);
2152
2153
2155
2161 warn(string message, ...);
2162
2163
2165
2171 error(string message, ...);
2172
2173
2175
2181 fatal(string message, ...);
2182
2183
2185
2196 assertLog(bool assertion, string message, ...);
2197
2198
2200
2206 traceVar(string var_name, auto value);
2207
2208
2210
2216 debugVar(string var_name, auto value);
2217
2218
2220
2224
2225
2227
2230 bool isEnabledFor(int level);
2231
2232
2234
2237 bool isEnabledFor(string level);
2238
2239
2242
2243
2246
2247
2250
2251
2254
2255
2258
2259
2262
2263};
2264
2266
2272class Logger : public LoggerInterface {
2273
2274public:
2275private:
2277 transient RWLock lock();
2278
2280 static RWLock hierarchyLock();
2281
2283
2285 bool additivity = True;
2286
2289
2291 string name;
2292
2295
2297 transient list<LoggerAppender> appenders;
2298
2299public:
2300
2302
2305 constructor(string name = '');
2306
2307
2309
2313 constructor(string name, LoggerLevel level);
2314
2315
2317
2321
2322
2323 destructor();
2324
2325
2327 string getName();
2328
2331
2333
2338
2340
2344 *LoggerLevel getLevel(bool effective = True);
2345
2347
2351
2353
2356 setLevel(string level);
2357
2359
2362 setLevel(int level);
2363
2365
2369
2371
2375
2377
2380 setAdditivity(bool enable);
2381
2384
2386
2390
2392protected:
2393 hash<CallStackInfo> getLocation();
2394public:
2395
2396
2398
2403
2405
2409
2412
2414
2418 list<LoggerAppender> getAppenders();
2419
2420private:
2421 logIntern(LoggerLevel level, string message, *list<auto> args, *hash<CallStackInfo> location, bool check_throwable, date time_stamp = now_us());
2422public:
2423
2424
2425private:
2426 logIntern(LoggerLevel level, string message, *list<auto> args, *hash<CallStackInfo> location, *hash<ExceptionInfo> throwable, date time_stamp);
2427public:
2428
2429
2431
2437 log(LoggerLevel level, string message);
2438
2440
2446 log(int level, string message);
2447
2449
2455 log(string level, string message);
2456
2458
2465 logArgs(LoggerLevel level, string message, *softlist<auto> args);
2466
2468
2475 logArgs(int level, string message, *softlist<auto> args);
2476
2478
2485 logArgs(string level, string message, *softlist<auto> args);
2486
2488
2492
2494
2500 trace(string message, ...);
2501
2503
2509 debug(string message, ...);
2510
2512
2518 info(string message, ...);
2519
2521
2527 warn(string message, ...);
2528
2530
2536 error(string message, ...);
2537
2539
2545 fatal(string message, ...);
2546
2548
2559 assertLog(bool assertion, string message, ...);
2560
2562
2568 traceVar(string var_name, auto value);
2569
2571
2577 debugVar(string var_name, auto value);
2578
2580
2584
2586
2589 bool isEnabledFor(int level);
2590
2592
2595 bool isEnabledFor(string level);
2596
2599
2602
2605
2608
2611
2614};
2615
2617class LoggerRoot : public Logger {
2618
2619public:
2620 // Creates the object
2625
2626
2627 // Creates the object
2631 constructor(int level);
2632
2633
2634 // Creates the object
2638 constructor(string level);
2639
2640
2642
2649
2651
2655};
2656
2658
2661
2662public:
2663 constructor() ;
2664
2665
2666 processEventImpl(int type, auto params);
2667
2668};
2669};
Abstract class for file appenders with rotation support.
Definition: Logger.qm.dox.h:1323
const EVENT_ROTATE
rotate event
Definition: Logger.qm.dox.h:1327
const DEFAULT_ROTATION_COUNT
default value for rotation chain
Definition: Logger.qm.dox.h:1329
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.
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:1223
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:1227
string getFileName()
Returns the current filename.
const DEFAULT_OPEN_FLAGS
Default open flags.
Definition: Logger.qm.dox.h:1230
File getFile()
Returns the file object for the appender.
constructor(*string name, LoggerLayout layout, string filename, *string encoding)
Creates the object.
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:1343
string getArchiveFileName(int idx)
Returns the archive filename.
const DEFAULT_ARCHIVE_PATTERN
default archive pattern
Definition: Logger.qm.dox.h:1347
processEventImpl(int type, auto params)
Implements filename rotation; handles the open and rotate events directly.
*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:700
*LoggerAppenderQueue queue
async queue
Definition: Logger.qm.dox.h:727
RWLock lock()
The lock to ensure proper serialization with concurrent access.
const EVENT_LOG
logging event
Definition: Logger.qm.dox.h:706
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:721
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:718
*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:724
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:704
const EVENT_CLOSE
close event
Definition: Logger.qm.dox.h:708
list< LoggerFilter > getFilters()
Returns the filter chain as a list.
Implements appender which does nothing.
Definition: Logger.qm.dox.h:863
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:560
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:620
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:631
Mutex lock()
to protect process()
ThreadPool threadPool
worker thread pool
Definition: Logger.qm.dox.h:625
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:633
int maxThreads
max.number of worker threads
Definition: Logger.qm.dox.h:629
Implements appender writing to a stderr file.
Definition: Logger.qm.dox.h:1303
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:1279
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:1187
bool closed
closed flag
Definition: Logger.qm.dox.h:1194
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:1196
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:1192
Implements an appender with a layout.
Definition: Logger.qm.dox.h:1146
constructor(*string name, LoggerLayout layout)
Creates the object.
LoggerLayout layout
assigned layout
Definition: Logger.qm.dox.h:1151
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:423
*string renderedMessage
The application supplied message rendered through the rendering mechanism.
Definition: Logger.qm.dox.h:449
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:440
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:461
date timeStamp
event time stamp
Definition: Logger.qm.dox.h:455
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:428
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:437
string messageFmt
The application supplied message of logging event (not rendered)
Definition: Logger.qm.dox.h:443
int threadId
related thread id
Definition: Logger.qm.dox.h:452
*hash< CallStackInfo > locationInfo
location information where the logging was performed.
Definition: Logger.qm.dox.h:458
*hash< CallStackInfo > getLocationInfo()
Returns the location information for this logging event.
*Logger logger
Logger reference.
Definition: Logger.qm.dox.h:434
int getThreadId()
Returns the thread id which is related to event.
int uniqueId
unique id
Definition: Logger.qm.dox.h:464
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:446
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:431
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:393
constructor(code func)
Creates object.
auto call()
Call function with arguments provided.
Implements a general event filtering class.
Definition: Logger.qm.dox.h:1687
const NEUTRAL
No decision could be made, further filtering should occur.
Definition: Logger.qm.dox.h:1694
const DENY
The event should not be processed.
Definition: Logger.qm.dox.h:1697
const ACCEPT
The event will be processed.
Definition: Logger.qm.dox.h:1691
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:1717
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:1724
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:1722
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:1803
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:1808
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:1810
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:2291
transient list< LoggerAppender > appenders
A collection of appenders linked to this logger.
Definition: Logger.qm.dox.h:2297
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:2288
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:2294
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:1840
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:1003
abstract string format(LoggerEvent event)
Format event record.
Implements the formatting of LoggerEvent objects with a pattern.
Definition: Logger.qm.dox.h:1101
const HostName
This hostname.
Definition: Logger.qm.dox.h:1109
const DEFAULT_PATTERN
default layout pattern
Definition: Logger.qm.dox.h:1105
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:1107
constructor(string pattern=DEFAULT_PATTERN)
Creates the object.
Defines the minimum set of levels recognized by the system.
Definition: Logger.qm.dox.h:235
const LEVELSTR_TO_LEVEL
String to int hash.
Definition: Logger.qm.dox.h:266
string getStr()
Gets level string.
string levelStr
String representation of the level.
Definition: Logger.qm.dox.h:260
const FATAL
Logger level for fatal errors.
Definition: Logger.qm.dox.h:241
const ERROR
Logger level for (non-fatal) errors.
Definition: Logger.qm.dox.h:243
static hash< string, LoggerLevel > levelMap
Contains a list of instantiated levels.
Definition: Logger.qm.dox.h:263
const TRACE
Logger level for trace messages.
Definition: Logger.qm.dox.h:251
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:249
const OFF
The highest logger level.
Definition: Logger.qm.dox.h:239
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:278
int levelCode
Integer level value.
Definition: Logger.qm.dox.h:257
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:247
bool isGreaterOrEqual(LoggerLevel other)
Compares logger levels.
const WARN
Logger level for warnings.
Definition: Logger.qm.dox.h:245
static LoggerLevel getLevelDebug()
Returns a DEBUG Level.
const ALL
The lowest logger level.
Definition: Logger.qm.dox.h:253
static *LoggerLevel getNextHigherLevel(int level)
Returns closest higher logger level.
Implements pattern parsing and substitution.
Definition: Logger.qm.dox.h:943
string origPattern
pattern
Definition: Logger.qm.dox.h:951
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:957
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:947
Implements the root class for loggers; does not allow a parent logger to be set.
Definition: Logger.qm.dox.h:2617
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:2030
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:2035
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:2660
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:229