Qore Logger Module Reference 0.4
Loading...
Searching...
No Matches
Logger.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* Logger.qm Copyright 2018 - 2022 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
220namespace Logger {
222
227
228public:
230 const OFF = MAXINT;
232 const FATAL = 50000;
234 const ERROR = 40000;
236 const WARN = 30000;
238 const INFO = 20000;
240 const DEBUG = 10000;
242 const TRACE = 5000;
244 const ALL = MININT;
245
246private:
249
251 string levelStr;
252
254 static hash<string, LoggerLevel> levelMap;
255
258 'ALL': ALL,
259 'TRACE': TRACE,
260 'DEBUG': DEBUG,
261 'INFO': INFO,
262 'WARN': WARN,
263 'ERROR': ERROR,
264 'FATAL': FATAL,
265 'OFF': OFF,
266 };
267
269 const LEVEL_TO_LEVEL_STR = map {$1.value: $1.key}, LEVELSTR_TO_LEVEL.pairIterator();
270
271public:
272
274
278 constructor(int code, string str);
279
280
282 int getValue();
283
285 string getStr();
286
288
293
295
298 bool isEqual(LoggerLevel other);
299
302
305
308
311
314
317
320
323
325
333 static LoggerLevel getLevel(int level, *LoggerLevel default_level);
334
336
342 static *LoggerLevel getNextLowerLevel(int level);
343
345
351 static *LoggerLevel getNextHigherLevel(int level);
352
354
361 static LoggerLevel getLevel(string level_str, *LoggerLevel default_level);
362};
363
365
385
386public:
387private:
388 code callable;
389 *list<auto> args;
390
391public:
393
396 constructor(code func);
397
399
403 auto call();
404};
405
407
415
416public:
417private:
419 static date startTime = now_us();
420
422 string fqcn;
423
425 transient *Logger logger;
426
429
432
435
437 *list<auto> messageArgs;
438
441
444
447
449 *hash<CallStackInfo> locationInfo;
450
452 *hash<ExceptionInfo> throwableInfo;
453
456
458 static Sequence sequence(1);
459
460public:
461
463
475 constructor(Logger logger, LoggerLevel level, string message, *list<auto> args,
476 *hash<CallStackInfo> location_info, int thread_id = gettid(), date time_stamp = now_us(),
477 *hash<ExceptionInfo> throwable) {
478 fqcn = get_class_name(logger);
479 self.logger = logger;
481 self.level = level;
482 messageFmt = message;
483 messageArgs = args;
484 locationInfo = location_info;
485 threadId = thread_id;
486 timeStamp = time_stamp;
487 if (throwable);
488
489 }
490
492
503 constructor(string fqcn, softstring category, LoggerLevel level, string message, *list<auto> args,
504 *hash<CallStackInfo> location_info, int thread_id = gettid(), date time_stamp = now_us(),
505 *hash<ExceptionInfo> throwable) {
506 self.fqcn = fqcn;
507 categoryName = category;
508 self.level = level;
509 messageFmt = message;
510 messageArgs = args;
511 locationInfo = location_info;
512 threadId = thread_id;
513 timeStamp = time_stamp;
514 if (throwable);
515
516 }
517
520
522 *hash<CallStackInfo> getLocationInfo();
523
526
529
532
535
537
544 string getMessage();
545
547 static date getStartTime();
548
550 static setStartTime(date time);
551
554
556
563
565 *hash<ExceptionInfo> getThrowableInfo();
566
569};
570
572
577
578public:
579private:
580 Queue queue();
581
582public:
583
585
591 bool push(LoggerAppender appender, int type, auto params);
592
594
605 process(timeout ms = 0);
606
608 int size();
609
611
622protected:
623 *hash<auto> getEvent(timeout ms);
624public:
625
626};
627
629
637
638public:
639private:
641 ThreadPool threadPool;
643 Counter runningCounter(0);
647 hash<auto> pendingEvents;
653 Sequence lastId(0);
655 Mutex lock();
656
657public:
658
660
665private:
666 worker(string id, LoggerAppender appender, list<auto> events);
667public:
668
669
671
675 constructor(ThreadPool tp, int max_threads = -1);
676
677
678 destructor();
679
680
682 ThreadPool getThreadPool();
683
685
697 process(timeout ms = 0);
698
700 int size();
701};
702
704
717
718public:
720 const EVENT_OPEN = 1;
722 const EVENT_LOG = 2;
724 const EVENT_CLOSE = 3;
725
726protected:
728 RWLock lock();
729
730public:
731
732private:
734 bool active = False;
735
737 list<LoggerFilter> filters;
738
740 string name;
741
744
745public:
746
748
752
753
754 destructor();
755
756
758 string getName();
759
761
770
773
775
779
782
784 bool isOpen();
785
787
793 addFilter(LoggerFilter filter, bool top = False);
794
796
800
803
805
808 list<LoggerFilter> getFilters();
809
811
817protected:
818 abstract auto serializeImpl(LoggerEvent event);
819public:
820
822
830protected:
831 bool pushEvent(int type, auto params);
832public:
833
834
836
847 bool post(LoggerEvent event);
848
850
856 processEvent(int type, auto params);
857
859
867 abstract processEventImpl(int type, auto params);
869protected:
870 *object ensureAtomicOperations(int type);
871public:
872
873};
874
876
880
881public:
882 constructor(*string name);
883
884
885protected:
887public:
888
889
890 processEventImpl(int type, auto params);
891};
892
894
960
961public:
963 const ESCAPE_CHAR = "%";
964
965private:
968
969public:
970
971protected:
973 list<auto> parsedPattern; // subclass may provide value e.g. for unit tests
974
975public:
976
978
982 constructor(string pattern);
983
984
986
990 setPattern(string value);
991
993 string getPattern();
994
996
1000 string format(auto data);
1001
1003
1010protected:
1011 abstract *string resolveField(auto data, string key, *string option);
1012public:
1013};
1014
1016
1020
1021public:
1023 abstract string format(LoggerEvent event);};
1024
1026
1118
1119public:
1121 const DEFAULT_PATTERN = "%r [%t] %p %c - %m%n";
1123 const DEFAULT_DATE_FORMAT = "YYYY-MM-DD HH:mm:SS.u";
1125 const HostName = gethostname();
1126
1128
1131 constructor(string pattern = DEFAULT_PATTERN);
1132
1133
1135 static string getLineDelimiter();
1136
1138
1141 string format(LoggerEvent event);
1142
1144
1149protected:
1150 *string resolveField(auto event, string key, *string option);
1151public:
1152
1153};
1154
1156
1163
1164public:
1165private:
1168
1169public:
1170
1172
1177
1178
1180
1184
1187
1189
1192protected:
1194public:
1195
1196};
1197
1199
1204
1205public:
1206private:
1208 StreamWriter writer;
1210 bool closed = False;
1213
1214public:
1215
1217
1222 constructor(*string name, LoggerLayout layout, StreamWriter writer);
1223
1224
1226 StreamWriter getStreamWriter();
1227
1230
1232 processEventImpl(int type, auto params);
1233};
1234
1236
1240
1241public:
1243 const EVENT_REOPEN = 1001;
1244
1245protected:
1246 File file;
1247 string fileName;
1248
1249public:
1250
1252
1258 constructor(*string name, LoggerLayout layout, string filename, *string encoding)
1259 ;
1260
1261
1263 File getFile();
1264
1266 string getFileName();
1267
1269
1273 processEventImpl(int type, auto params);
1274
1275 openFile();
1276
1277
1278 closeFile();
1279
1280
1281 reopen();
1282
1283
1285protected:
1286 *object ensureAtomicOperations(int type);
1287public:
1288
1289};
1290
1292
1297
1298public:
1300
1305
1306
1308
1312 processEventImpl(int type, auto params);
1313};
1314
1316
1321
1322public:
1324
1329
1330
1332
1336 processEventImpl(int type, auto params);
1337};
1338
1341
1342public:
1344 const EVENT_ROTATE = 10001;
1347
1348 rotate();
1349
1351 abstract int getCount();
1353protected:
1354 *object ensureAtomicOperations(int type);
1355public:
1356
1357};
1358
1360
1366
1367public:
1369 const DEFAULT_ARCHIVE_PATTERN = "%p%f.%i";
1370
1371private:
1372 int count;
1373
1374public:
1375
1377
1447 constructor(*string name, LoggerLayout layout, string filename, int count = DEFAULT_ROTATION_COUNT,
1448 string archive = DEFAULT_ARCHIVE_PATTERN, *string encoding)
1449 ;
1450
1451
1453
1460protected:
1461 *string resolveField(auto data, string key, *string option);
1462public:
1463
1464
1466
1470 processEventImpl(int type, auto params);
1471
1473
1476 string getArchiveFileName(int idx);
1477
1480};
1481
1483
1489
1490public:
1492 const DEFAULT_DATE_FORMAT = "YYYYMMDDHHmmSS";
1493
1494private:
1495 hash<auto> patternData;
1496
1497public:
1498
1500
1548 constructor(*string name, LoggerLayout layout, string pattern, int count = DEFAULT_ROTATION_COUNT,
1549 *string encoding);
1550
1551
1553
1560protected:
1561 *string resolveField(auto data, string key, *string option);
1562public:
1563
1564
1566
1570 processEventImpl(int type, auto params);
1571
1574
1577};
1578
1580
1587
1588public:
1590 const EVENT_ARCHIVE = 20;
1592 const DEFAULT_DATE_FORMAT = "YYYYMMDDHHmmSS";
1594 const DEFAULT_ARCHIVE_PATTERN = "%p%f.%d";
1595
1597
1664 *string encoding);
1665
1666
1668
1675protected:
1676 *string resolveField(auto data, string key, *string option);
1677public:
1678
1679
1681
1685 processEventImpl(int type, auto params);
1686
1688
1694 string archive();
1695
1697
1702
1704protected:
1705 *object ensureAtomicOperations(int type);
1706public:
1707
1708};
1709
1711
1718
1719public:
1721 const ACCEPT = 1;
1722
1724 const NEUTRAL = 0;
1725
1727 const DENY = -1;
1728
1730
1737 int eval(LoggerEvent event);
1738};
1739
1741
1748
1749public:
1750private:
1755
1756public:
1757
1759
1764
1765
1767
1771 constructor(int min_value, int max_value = LoggerLevel::OFF);
1772
1773
1775
1779 constructor(string min_value, string max_value = 'OFF');
1780
1781
1783
1787
1789
1792 setMinLevel(int value);
1793
1795
1798 setMinLevel(string value);
1799
1802
1804
1808
1810
1813 setMaxLevel(int value);
1814
1816
1819 setMaxLevel(string value);
1820
1823
1825 int eval(LoggerEvent event);
1826};
1827
1829
1834
1835public:
1836private:
1838 string regexStr;
1841
1842public:
1843
1845
1849 constructor(string regex_str = '', bool regex_result = True);
1850
1851
1853
1857 setRegex(string regex_str, bool regex_result = True);
1858
1860 string getRegex();
1861
1864
1866 int eval(LoggerEvent event);
1867};
1868
1870
1876class Logger {
1877
1878public:
1879private:
1881 transient RWLock lock();
1882
1884 static RWLock hierarchyLock();
1885
1887 bool additivity = True;
1888
1891
1893 string name;
1894
1897
1899 list<LoggerAppender> appenders;
1900
1901public:
1902
1904
1907 constructor(string name = '');
1908
1909
1911
1915 constructor(string name, LoggerLevel level);
1916
1917
1919
1923
1924
1925 destructor();
1926
1927
1929 string getName();
1930
1933
1935
1940
1942
1946 *LoggerLevel getLevel(bool effective = True);
1947
1949
1953
1955
1958 setLevel(string level);
1959
1961
1964 setLevel(int level);
1965
1967
1971
1973
1977
1979
1982 setAdditivity(bool enable);
1983
1986
1988
1992
1994protected:
1995 hash<CallStackInfo> getLocation();
1996public:
1997
1998
2000
2005
2007
2011
2014
2016
2020 list<LoggerAppender> getAppenders();
2021
2022private:
2023 logIntern(LoggerLevel level, string message, *list<auto> args, *hash<CallStackInfo> location,
2024public:
2025
2026
2027 private:internal logIntern(LoggerLevel level, string message, *list<auto> args, *hash<CallStackInfo> location,
2028 *hash<ExceptionInfo> throwable, date time_stamp) {
2029 if (isEnabledFor(level));
2030
2031 {
2032 AutoReadLock awl(lock);
2033 if (parent && getAdditivity()) {
2034 // Forward the event upstream if additivity is turned on
2035 parent.logIntern(level, message, args, location, throwable, time_stamp);
2036 }
2037 }
2038 }
2039
2041
2045 log(LoggerLevel level, string message);
2046
2048
2052 log(int level, string message);
2053
2055
2059 log(string level, string message);
2060
2062
2067 logArgs(LoggerLevel level, string message, *softlist<auto> args);
2068
2070
2075 logArgs(int level, string message, *softlist<auto> args);
2076
2078
2083 logArgs(string level, string message, *softlist<auto> args);
2084
2086
2089 logEvent(LoggerEvent event);
2090
2092
2096 trace(string message);
2097
2099
2103 debug(string message);
2104
2106
2110 info(string message);
2111
2113
2117 warn(string message);
2118
2120
2124 error(string message);
2125
2127
2131 fatal(string message);
2132
2134
2143 assertLog(bool assertion, string message);
2144
2146
2152 traceVar(string var_name, auto value);
2153
2155
2161 debugVar(string var_name, auto value);
2162
2164
2167 bool isEnabledFor(LoggerLevel level);
2168
2170
2173 bool isEnabledFor(int level);
2174
2176
2179 bool isEnabledFor(string level);
2180
2182 bool isTraceEnabled();
2183
2185 bool isDebugEnabled();
2186
2188 bool isInfoEnabled();
2189
2191 bool isWarnEnabled();
2192
2194 bool isErrorEnabled();
2195
2197 bool isFatalEnabled();
2198};
2199
2201class LoggerRoot : public Logger {
2202
2203public:
2204 // Creates the object
2209
2210
2211 // Creates the object
2215 constructor(int level);
2216
2217
2218 // Creates the object
2222 constructor(string level);
2223
2224
2226
2233
2235
2239};
2240
2242
2245
2246public:
2247 constructor() ;
2248
2249
2250 processEventImpl(int type, auto params);
2251
2252};
2253};
Abstract class for file appenders with rotation support.
Definition: Logger.qm.dox.h:1340
const EVENT_ROTATE
rotate event
Definition: Logger.qm.dox.h:1344
const DEFAULT_ROTATION_COUNT
default value for rotation chain
Definition: Logger.qm.dox.h:1346
*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:1586
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:1592
string archive()
Posts an archive event.
const EVENT_ARCHIVE
archive event
Definition: Logger.qm.dox.h:1590
const DEFAULT_ARCHIVE_PATTERN
default archive pattern
Definition: Logger.qm.dox.h:1594
*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:1239
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:1243
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:1488
int getCount()
Returns number of files in ring.
const DEFAULT_DATE_FORMAT
default date format
Definition: Logger.qm.dox.h:1492
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:1365
string getArchiveFileName(int idx)
Returns the archive filename.
const DEFAULT_ARCHIVE_PATTERN
default archive pattern
Definition: Logger.qm.dox.h:1369
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:716
*LoggerAppenderQueue queue
async queue
Definition: Logger.qm.dox.h:743
RWLock lock()
The lock to ensure proper serialization with concurrent access.
const EVENT_LOG
logging event
Definition: Logger.qm.dox.h:722
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:737
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:734
*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:740
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:720
const EVENT_CLOSE
close event
Definition: Logger.qm.dox.h:724
list< LoggerFilter > getFilters()
Returns the filter chain as a list.
Implements appender which does nothing.
Definition: Logger.qm.dox.h:879
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:576
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:636
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:647
Mutex lock()
to protect process()
ThreadPool threadPool
worker thread pool
Definition: Logger.qm.dox.h:641
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:649
int maxThreads
max.number of worker threads
Definition: Logger.qm.dox.h:645
Implements appender writing to a stderr file.
Definition: Logger.qm.dox.h:1320
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:1296
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:1203
bool closed
closed flag
Definition: Logger.qm.dox.h:1210
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:1212
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:1208
Implements an appender with a layout.
Definition: Logger.qm.dox.h:1162
constructor(*string name, LoggerLayout layout)
Creates the object.
LoggerLayout layout
assigned layout
Definition: Logger.qm.dox.h:1167
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:414
*string renderedMessage
The application supplied message rendered through the rendering mechanism.
Definition: Logger.qm.dox.h:440
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:431
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.
Definition: Logger.qm.dox.h:503
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:452
date timeStamp
event time stamp
Definition: Logger.qm.dox.h:446
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:419
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.
Definition: Logger.qm.dox.h:475
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:428
string messageFmt
The application supplied message of logging event (not rendered)
Definition: Logger.qm.dox.h:434
int threadId
related thread id
Definition: Logger.qm.dox.h:443
*hash< CallStackInfo > locationInfo
location information where the logging was performed.
Definition: Logger.qm.dox.h:449
*hash< CallStackInfo > getLocationInfo()
Returns the location information for this logging event.
int getThreadId()
Returns the thread id which is related to event.
int uniqueId
unique id
Definition: Logger.qm.dox.h:455
transient *Logger logger
Logger reference.
Definition: Logger.qm.dox.h:425
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:437
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:422
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:384
constructor(code func)
Creates object.
auto call()
Call function with arguments provided.
Implements a general event filtering class.
Definition: Logger.qm.dox.h:1717
const NEUTRAL
No decision could be made, further filtering should occur.
Definition: Logger.qm.dox.h:1724
const DENY
The event should not be processed.
Definition: Logger.qm.dox.h:1727
const ACCEPT
The event will be processed.
Definition: Logger.qm.dox.h:1721
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:1747
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:1754
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:1752
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:1833
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:1838
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:1840
string getName()
Returns the logger name.
list< LoggerAppender > getAppenders()
Returns the appender list.
addAppender(LoggerAppender appender)
Adds an appender to the appender list.
*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.
static RWLock hierarchyLock()
The lock to protect access to parent/child hierarchy.
bool getAdditivity()
Returns the additivity flag.
string name
The name of this Logger instance.
Definition: Logger.qm.dox.h:1893
constructor(string name='')
Creates the object.
transient RWLock lock()
The lock to protect object manipulation.
list< LoggerAppender > appenders
A collection of appenders linked to this logger.
Definition: Logger.qm.dox.h:1899
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:1890
setLevel(*LoggerLevel level)
Sets the logging level.
setLevel(string level)
Sets the logging level.
*Logger parent
The parent logger. Unassigned if this is the root logger.
Definition: Logger.qm.dox.h:1896
removeAllAppenders()
Clears the appender list by removing all appenders.
callAppenders(LoggerEvent event)
Forwards the given logging event to all linked appenders.
*LoggerLevel decLevel()
Decrement logger level.
setAdditivity(bool enable)
Sets the additivity flag; when additivity is active, events are passed to parent loggers.
constructor(LoggerLevel level)
Creates the object with an empty name and the given initial level.
removeAppender(LoggerAppender appender)
Removes the appender from the list.
Abstract class that defines the interface for logger layouts.
Definition: Logger.qm.dox.h:1019
abstract string format(LoggerEvent event)
Format event record.
Implements the formatting of LoggerEvent objects with a pattern.
Definition: Logger.qm.dox.h:1117
const HostName
This hostname.
Definition: Logger.qm.dox.h:1125
const DEFAULT_PATTERN
default layout pattern
Definition: Logger.qm.dox.h:1121
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:1123
constructor(string pattern=DEFAULT_PATTERN)
Creates the object.
Defines the minimum set of levels recognized by the system.
Definition: Logger.qm.dox.h:226
const LEVELSTR_TO_LEVEL
String to int hash.
Definition: Logger.qm.dox.h:257
string getStr()
Gets level string.
string levelStr
String representation of the level.
Definition: Logger.qm.dox.h:251
const FATAL
Logger level for fatal errors.
Definition: Logger.qm.dox.h:232
const ERROR
Logger level for (non-fatal) errors.
Definition: Logger.qm.dox.h:234
static hash< string, LoggerLevel > levelMap
Contains a list of instantiated levels.
Definition: Logger.qm.dox.h:254
const TRACE
Logger level for trace messages.
Definition: Logger.qm.dox.h:242
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:240
const OFF
The highest logger level.
Definition: Logger.qm.dox.h:230
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:269
int levelCode
Integer level value.
Definition: Logger.qm.dox.h:248
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:238
bool isGreaterOrEqual(LoggerLevel other)
Compares logger levels.
const WARN
Logger level for warnings.
Definition: Logger.qm.dox.h:236
static LoggerLevel getLevelDebug()
Returns a DEBUG Level.
const ALL
The lowest logger level.
Definition: Logger.qm.dox.h:244
static *LoggerLevel getNextHigherLevel(int level)
Returns closest higher logger level.
Implements pattern parsing and substitution.
Definition: Logger.qm.dox.h:959
string origPattern
pattern
Definition: Logger.qm.dox.h:967
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:973
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:963
Implements the root class for loggers; does not allow a parent logger to be set.
Definition: Logger.qm.dox.h:2201
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())
Appender for logging to the console.
Definition: Logger.qm.dox.h:2244
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:220