|
Class: MiniLogger
Object
|
+--MiniLogger
|
+--UnixSyslogInterface
- Package:
- stx:libbasic
- Category:
- System-Debugging-Support
- Version:
- rev:
1.155
date: 2024/04/29 13:25:46
- user: cg
- file: MiniLogger.st directory: libbasic
- module: stx stc-classLibrary: libbasic
A very simple logger for Smalltalk/X. This one is always present.
It mimics the protocol of the loggers found in stx:goodies/loggia,
which can be activated by setting the global 'Logger' to an instance of
one of them.
All
'Transcript show: 'Processor [info]: xxx'
should be rewritten over time to use the Logger.
'Object infoPrint' and 'Object debugPrint' have been changed to
forward their messages to the global 'Logger' if not nil.
Usage:
Logger info: 'Hello world'.
Logger debug: 'Hello world'.
Logger warning: 'Hello world'.
Logger error: 'Hello world'.
to disable logging:
MiniLogger logOnTranscript:false.
MiniLogger logOnStderr:false.
for selective logging:
Logger loggingThreshold: Logger severityALL.
Logger loggingThreshold: Logger severityINFO.
Logger loggingThreshold: Logger severityNONE.
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE
The following keywords are expanded in the message:
'LINE' linenumber in the sending method
'RECEIVER' printstring of receiver in sending context
'CLASS' class of receiver in sending context
'MCLASS' class of sendig method
'SELECTOR' selector of sending method
'WHO' who-string of sending method
'WHERE' who-string plus linenumber of sending method
i.e.
Logger info:'%(WHERE) - some message here'
For more examples, see #examples.
[instance variables:]
[class variables:]
copyrightCOPYRIGHT (c) 2012-2014 by Jan Vrany & eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
accessing-log format
-
logColor
-
is coloring of logs enabled/disabled
Usage example(s):
Logger logColor:true
Logger warn:'wwww'.
Logger error:'wwww'.
Logger info:'wwww'.
Logger logColor:false
Logger warn:'wwww'.
Logger error:'wwww'.
Logger info:'wwww'.
|
-
logColor: aBoolean
-
enable/disable coloring of logs
Usage example(s):
Logger logColor:true
Logger warn:'wwww'.
Logger error:'wwww'.
Logger info:'wwww'.
Logger logColor:false
Logger warn:'wwww'.
Logger error:'wwww'.
Logger info:'wwww'.
|
-
logFile
-
if this is non-nil, the log goes into that file (possibly in addition to other destinations)
-
logFile: aFilename
-
if non-nil, the log goes into that file (possibly in addition to other destinations)
-
logFormat
-
will be used for the log message as:
%1 [%2] (%3): %4
with
%1: facility (area such as 'STX' or 'appname')
%2: severity (error, info, etc.)
%3: timestamp (in timestamp format)
%4: caller/originator (receiver's class name)
%5: message
%6: location where log was generated ('[class>>sel@lineNr]'
%7: process id
%8: process name
Usage example(s):
MiniLogger logFormat:'%1 [%2]: %5 %6'.
'hello' errorPrintCR.
MiniLogger logFormat:'%1 [%2]: %5'.
'hello' errorPrintCR.
MiniLogger logFormat:'%3 %1 [%2]: %5'.
'hello' errorPrintCR.
MiniLogger logFormat:nil.
'hello' errorPrintCR.
|
-
logFormat: aFormatString
-
will be used for the log message as:
%1 [%2] (%3):%5 {%6}'
with
%1: facility (area such as 'STX' or 'appname')
%2: severity (error, info, etc.)
%3: timestamp (in timestamp format)
%4: caller/originator (receiver's class name)
%5: message
%6: location where log was generated ('[class>>sel@lineNr]
%7: process id
%8: process name
Pass a nil argument to return to the default format.
Usage example(s):
MiniLogger logFormat:'%1 [%2]: %5 %6'.
'hello' errorPrintCR.
MiniLogger logFormat:'%1 [%2]: %5'.
'hello' errorPrintCR.
MiniLogger logFormat:'%3 %1 [%2]: %5'.
'hello' errorPrintCR.
MiniLogger logFormat:nil.
'hello' errorPrintCR.
|
-
logFormatTranscript
-
will be used for transcript messages as:
with
%1: facility (area such as 'STX' or 'appname')
%2: severity (error, info, etc.)
%3: timestamp (in timestamp format)
%4: caller/originator (receiver's class name)
%5: message
%6: location where log was generated ('[class>>sel@lineNr]'
%7: process id
%8: process name
-
logFormatTranscript: aFormatString
-
will be used for the log message as:
%1: facility (area such as 'STX' or 'appname')
%2: severity (error, info, etc.)
%3: timestamp (in timestamp format)
%4: caller/originator (receiver's class name)
%5: message
%6: location where log was generated ('[class>>sel@lineNr]
%7: process id
%8: process name
Pass a nil argument to return to the default format.
Usage example(s):
MiniLogger logFormatTranscript:'[%2]: %5 %6'.
'hello' errorPrintCR.
MiniLogger logFormatTranscript:nil.
'hello' errorPrintCR.
MiniLogger logFormat:'%3 %1 [%2]: %5'.
'hello' errorPrintCR.
MiniLogger logFormat:nil.
'hello' errorPrintCR.
|
-
logOnStderr
-
true if the log is sent to stderr (possibly in addition to other destinations)
-
logOnStderr: aBoolean
-
enable/disable logging on stderr (possibly in addition to other destinations)
Usage example(s):
MiniLogger logOnStderr:false
MiniLogger logOnTranscript:false
MiniLogger logOnStderr:true
MiniLogger logOnTranscript:true
|
-
logOnTranscript
-
true if logging on the Transcript is enabled (possibly in addition to other destinations)
-
logOnTranscript: aBoolean
-
enable/disable logging on the Transcript (possibly in addition to other destinations)
Usage example(s):
MiniLogger logOnStderr:false
MiniLogger logOnTranscript:false
MiniLogger logOnStderr:true
MiniLogger logOnTranscript:true
|
-
timestampFormat
-
will be used for the log message
Usage example(s):
Timestamp now printStringFormat:(self timestampFormat)
self timestampFormat:'%h:%m:%s.%i'
|
-
timestampFormat: aTimestampFormatString
-
will be used for the log messages
Usage example(s):
Timestamp now printStringFormat:(self timestampFormat)
self timestampFormat:'%h:%m:%s.%i'
self timestampFormat:'%s.%i'
|
accessing-severities
-
severities
-
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE
-
severityDEBUG
-
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE
Usage example(s):
Logger loggingThreshold
Logger loggingThreshold:(Logger severityDEBUG).
Logger loggingThreshold:'debug'.
Logger loggingThreshold:'info'.
|
-
severityENTER
-
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE
-
severityERROR
-
setting this as threshold will print errors
-
severityFATAL
-
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE
-
severityINFO
-
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE
-
severityLEAVE
-
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE
-
severityTRACE
-
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE
-
severityTRACE0
-
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE
-
severityTRACE1
-
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE
-
severityTRACE2
-
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE
-
severityTRACE3
-
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE
-
severityWARN
-
setting this as threshold will print warnings and errors
accessing-severities-special
-
severityALL
-
setting this as thareshold will print all
-
severityNONE
-
setting this as threshold will suppress all logging
configuration
-
debugIfLogGenerated
-
if true, a break is generated whenever a log is generated.
Usage example(s):
self loggingThreshold:INFO.
self debugIfLogGenerated:true.
self info:'blabla'.
self debugIfLogGenerated:false.
self info:'blabla'.
|
-
debugIfLogGenerated: aBoolean
-
if true, a break is generated whenever a log is generated.
Usage example(s):
self loggingThreshold:INFO.
self debugIfLogGenerated:true.
self info:'blabla'.
self debugIfLogGenerated:false.
self info:'blabla'.
|
-
logLevel
-
same as loggingThreshold; nicer name
Usage example(s):
Logger logLevel: Logger severityALL.
Logger logLevel: Logger severityINFO. -- info, warnings and errors
Logger logLevel: #TRACE.
Logger logLevel:'DEBUG'
Logger logLevel:'DEBUG'
Logger logLevel:'DEBUG'
|
-
logLevel: severityOrName
-
same as loggingThreshold; nicer name
Usage example(s):
Logger logLevel: Logger severityALL.
Logger logLevel: Logger severityINFO. -- info, warnings and errors
Logger logLevel: #TRACE.
Logger logLevel:'DEBUG'
Logger logLevel:'DEBUG'
Logger logLevel:'DEBUG'
|
-
loggingThreshold
-
Return the logging threshold.
No messages with severity lower than threshold will be logged.
The default is
InfoPrinting ifTrue:[INFO] ifFalse:[WARN]
meaning that by default, no trace and debug logs are generated.
Usage example(s):
self loggingThreshold:INFO.
self trace:'blabla'.
self loggingThreshold:TRACE.
self trace:'blabla'.
self loggingThreshold:INFO.
self info:'xxx'.
|
-
loggingThreshold: severityOrNameOrNil
-
Sets the default logging threshold.
This is used if no per-class, per-package or per-facility
threshold is set.
All severities higher or equal to the given one will be logged.
Use `Logger severityNONE` to suppress logging completely
or `Logger severityALL` to log all messages.
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE
Usage example(s):
Logger loggingThreshold: Logger severityALL.
Logger loggingThreshold: Logger severityINFO. -- info, warnings and errors
Logger loggingThreshold: Logger severityTRACE. -- trace, debug, info, warnings and errors
Logger loggingThreshold: Logger severityDEBUG. -- debug, info, warnings and errors
Logger loggingThreshold: Logger severityWARN. -- only warnings and errors
Logger loggingThreshold: Logger severityERROR. -- only errors
Logger loggingThreshold: Logger severityNONE.
Logger loggingThreshold
Logger loggingThreshold: 'error'.
Logger loggingThreshold: 'info'.
Logger info:'test'
|
-
loggingThreshold: severityOrNameOrNil forClass: aClass
-
allows individual per-class setting of the threshold (useful during debugging).
With a nil limit, the default is reinstalled for that class.
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE
Usage example(s):
Logger severityThresholdOf: Object
Logger severityThresholdOf: Expecco::Browser
Logger loggingThreshold:(Logger severityDEBUG) forClass:TerminalSession.
Logger loggingThreshold:(Logger severityDEBUG) forClass:(Expecco::Browser).
Logger loggingThreshold:(Logger severityDEBUG) forPackage:'stx:libbasic'.
Logger loggingThreshold:(Logger severityDEBUG) forPackage:'exept:workflow'.
Logger loggingThreshold:nil forClass:(Expecco::Browser).
Logger loggingThreshold:nil forPackage:'stx:libbasic'.
|
-
loggingThreshold: severityOrNameOrNil forFacility: aFacilityName
-
allows individual per-facility setting of the threshold (useful during debugging).
With a nil limit, the default is reinstalled for that facility.
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE
Usage example(s):
Logger severityThresholdOf: Object
Logger severityThresholdOf: Expecco::Browser
Logger loggingThreshold:(Logger severityDEBUG) forClass:(Expecco::Browser).
Logger loggingThreshold:(Logger severityDEBUG) forPackage:'stx:libbasic'.
Logger loggingThreshold:(Logger severityDEBUG) forPackage:'exept:workflow'.
Logger loggingThreshold:nil forClass:(Expecco::Browser).
Logger loggingThreshold:nil forPackage:'stx:libbasic'.
|
-
loggingThreshold: severityOrNameOrNil forPackage: aPackageName
-
allows individual per-package setting of the threshold (useful during debugging).
With a nil limit, the default is reinstalled for that class.
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE
Usage example(s):
Logger severityThresholdOf: Object
Logger severityThresholdOf: Expecco::Browser
Logger loggingThreshold:(Logger severityDEBUG) forClass:(Expecco::Browser).
Logger loggingThreshold:(Logger severityDEBUG) forPackage:'stx:libbasic'.
Logger loggingThreshold:(Logger severityDEBUG) forPackage:'exept:workflow'.
Logger loggingThreshold:nil forClass:(Expecco::Browser).
Logger loggingThreshold:nil forPackage:'stx:libbasic'.
|
-
loggingThresholdForClass: aClass
-
returns a per-class setting;
nil if there is none
-
loggingThresholdForFacility: aFacilityName
-
returns a per-facility setting;
nil if there is none
-
loggingThresholdForPackage: aPackageName
-
returns a per-package setting;
nil if there is none
-
setLoggingThresholdToDebug
-
sets the default threshold
-
setLoggingThresholdToError
-
sets the default threshold
-
setLoggingThresholdToInfo
-
sets the default threshold
-
setLoggingThresholdToWarning
-
sets the default threshold
initialization
-
initialize
-
do NOT ask the OS here, as this might not yet been initialized.
logging - basic
-
basicLog: message severity: severity facility: facility originator: originator attachment: attachment
-
Principal logging method on file or stderr (i.e. NOT on Transcript).
This mimics VM's __stxLog__()
-
log: message severity: severityOrSymbol facility: facilityArg originator: originator attachment: attachment
-
Pricipal logging method.
Depending on the settings, logs on stderr/ Transcript / logFile.
This mimics VM's __stxLog__().
attachment is ignored here, but the protocol is to be compatible with loggers
which do support attachments (see goodies/Loggia).
Originator used to be the receiver of the method which generates the logmessage;
however, it is better to make it the class of the method which contains the log-call.
In the meantime, we kind of support both.
Usage example(s):
self log: 'using symbols as severity is deprecated, use Logger severityXXX to get severity object' severity: WARN facility: 'STX' originator: self.
|
Usage example(s):
self log: 'caller is ', caller printString severity: INFO facility: 'STX' originator: self.
|
Usage example(s):
Logger info:'some info'
Logger warning:'some warning'
Logger error:'some error'
Logger debug:'some debug'
Logger trace:'some trace'
Logger info:'some info with
multiple
lines
'
Logger log:'test message' severity:self severityINFO facility: 'TEST'
Logger log:'test message' severity:#info facility: 'TEST'
Logger log:'test message' severity:#bla facility: 'TEST'
Logger log:'test message' severity:123 facility: 'TEST'
Logger log:'test message' severity: DEBUG facility: 'TEST'
Logger log:'test message' severity: INFO facility: 'TEST'
Logger log:'test message' asUnicode16String severity: INFO facility: 'TEST'
Logger log:'test message äöüß' severity: INFO facility: 'TEST'
Logger log:'test message' severity: WARNING facility: 'TEST'
Logger log:'test message' severity: ERROR facility: 'TEST'
'test message' infoPrintCR
'test message' errorPrintCR
|
logging - buffered
-
disableFastTrace
-
Disable the fastTrace feature
-
dumpFastTraceOn: aStream
-
dump the fast trace and clear it for new recordings;
the output columns are:
processID timestamp message
Usage example(s):
MiniLogger enableFastTrace:1000.
MiniLogger fastTrace:'hello1'.
MiniLogger fastTrace:'hello2'.
MiniLogger fastTrace:'hello3'.
MiniLogger dumpFastTraceOn:Transcript.
MiniLogger fastTrace:'hello4'.
MiniLogger fastTrace:'hello5'.
MiniLogger dumpFastTraceOn:Transcript.
MiniLogger disableFastTrace.
|
-
enableFastTrace: bufferSize
-
Enable the fastTrace feature, remembering bufferSize last messages.
Usage example(s):
MiniLogger enableFastTrace:1000.
MiniLogger fastTrace:'hello1'.
MiniLogger fastTrace:'hello2'.
MiniLogger fastTrace:'hello3'.
MiniLogger getFastTrace.
|
-
fastTrace: msg
-
fastTrace puts a message into a traceBuffer;
this will not be printed, but instead keeps the last N log messages
in a cyclic round robin buffer.
To enable this feature, call enableFastTrace.
-
fastTraceContext
-
fastTrace puts a message into a traceBuffer;
this will not be printed, but instead keeps the last N log messages
in a cyclic round robin buffer.
To enable this feature, call enableFastTrace.
-
flushFastTrace
-
-
getFastTrace
-
|trace|
MiniLogger enableFastTrace:100.
MiniLogger fastTrace:'hello1'.
MiniLogger fastTrace:'hello2'.
MiniLogger fastTrace:'hello3'.
trace := MiniLogger getFastTrace.
MiniLogger disableFastTrace.
trace
logging - utils
-
debug: message
-
generate a 'debug'-log
Usage example(s):
-
debug: format with: arg1
-
generate a 'debug'-log
-
debug: format with: arg1 with: arg2
-
generate a 'debug'-log
-
debug: format with: arg1 with: arg2 with: arg3
-
generate a 'debug'-log
-
debug: format with: arg1 with: arg2 with: arg3 with: arg4
-
generate a 'debug'-log
-
debug: format with: arg1 with: arg2 with: arg3 with: arg4 with: arg5
-
generate a 'debug'-log
-
debug: format withArguments: arg1
-
generate a 'debug'-log
-
enter
-
generate an 'entering method...'-log,
showing the sender method's selector
-
enter: message
-
generate an 'entering method...'-log
-
enter: format with: arg1
-
generate an 'entering method...'-log
-
enter: format with: arg1 with: arg2
-
generate an 'entering method...'-log
-
enter: format with: arg1 with: arg2 with: arg3
-
generate an 'entering method...'-log
-
enter: format withArguments: arg1
-
generate an 'entering method...'-log
-
error: message
-
generate an 'error'-log
Usage example(s):
Logger error:'some error message'
Logger error:'hello %(WHERE)'
|
-
error: format with: arg1
-
generate an 'error'-log
Usage example(s):
Logger error:'some %1 message' with:'foo'
|
-
error: format with: arg1 with: arg2
-
generate an 'error'-log
Usage example(s):
Logger error:'some %1 %2' with:'foo' with:'bar'
|
-
error: format with: arg1 with: arg2 with: arg3
-
generate an 'error'-log
-
error: format with: arg1 with: arg2 with: arg3 with: arg4
-
generate an 'error'-log
-
error: format withArguments: arg1
-
generate an 'error'-log
-
fatal: message
-
generate a 'fatal'-log
-
fatal: format with: arg1
-
generate a 'fatal'-log
-
fatal: format with: arg1 with: arg2
-
generate a 'fatal'-log
-
fatal: format with: arg1 with: arg2 with: arg3
-
generate a 'fatal'-log
-
fatal: format withArguments: arg1
-
generate a 'fatal'-log
-
info: message
-
generate an 'info'-log
Usage example(s):
Logger info:'some info message'
|
-
info: format with: arg1
-
generate an 'info'-log
Usage example(s):
Logger info:'some %1 message' with:'foo'
|
-
info: format with: arg1 with: arg2
-
generate an 'info'-log
Usage example(s):
Logger info:'some %1 message (%2)' with:'foo' with:'bar'
|
-
info: format with: arg1 with: arg2 with: arg3
-
generate an 'info'-log
-
info: format with: arg1 with: arg2 with: arg3 with: arg4
-
generate an 'info'-log
-
info: format withArguments: arg1
-
generate an 'info'-log
-
leave
-
generate a 'leaving method...'-log
showing the sender method's selector
-
leave: message
-
generate a 'leaving method...'-log
-
leave: format with: arg1
-
generate a 'leaving method...'-log
-
leave: format with: arg1 with: arg2
-
generate a 'leaving method...'-log
-
leave: format with: arg1 with: arg2 with: arg3
-
generate a 'leaving method...'-log
-
leave: format withArguments: arg1
-
generate a 'leaving method...'-log
-
log: message
-
generate a debug level log message
-
log: message facility: facility
-
generate a debug level log message for facility
-
log: message severity: severity
-
generate a debug level log message with severity
-
log: message severity: severity attachment: attachment
-
generate a debug level log message with severity and attached data
-
log: message severity: severity facility: facility
-
-
log: message severity: severity facility: facility originator: originator
-
-
log: message severity: severity originator: originatorOrNil
-
originator := originatorContext receiver.
-
log: message with: arg
-
-
log: format with: arg1 severity: severity
-
generate a debug level log message with severity and arg in message
-
log: message with: arg1 with: arg2
-
-
log: format with: arg1 with: arg2 severity: severity
-
generate a debug level log message with severity and arg in message
-
log: message with: arg1 with: arg2 with: arg3
-
-
log: message withArguments: args
-
-
trace
-
generate a trace log; this is special, in that it
prints the context of the sender
-
trace0: message
-
generate a 'debug trace'-log
-
trace0: format with: arg1
-
generate a 'debug trace'-log with one %-arg
-
trace0: format with: arg1 with: arg2
-
generate a 'debug trace'-log with two %-args
-
trace0: format with: arg1 with: arg2 with: arg3
-
generate a 'debug trace'-log with three %-args
-
trace1: message
-
generate a trace1-level log
-
trace1: format with: arg1
-
generate a trace1-level log with 1 %-arg
-
trace1: format with: arg1 with: arg2
-
generate a trace1-level log with 2 %-args
-
trace1: format with: arg1 with: arg2 with: arg3
-
generate a level1 trace-log with two %-args
-
trace2: message
-
generate a trace2-level log
-
trace2: format with: arg1
-
a quick rejector to avoid overhead in deployed apps
-
trace2: format with: arg1 with: arg2
-
a quick rejector to avoid overhead in deployed apps
-
trace2: format with: arg1 with: arg2 with: arg3
-
a quick rejector to avoid overhead in deployed apps
-
trace3: message
-
generate a trace3-level log
-
trace3: format with: arg1
-
generate a trace3-level log with one %-arg
-
trace3: format with: arg1 with: arg2
-
generate a trace3-level log with 2 %-args
-
trace3: format with: arg1 with: arg2 with: arg3
-
generate a trace3-level log with 3 %-args
-
trace: message
-
generate a trace log
-
trace: format with: arg1
-
generate a trace log with a %-arg
-
trace: format with: arg1 with: arg2
-
generate a trace log with two %-args
-
trace: format with: arg1 with: arg2 with: arg3
-
generate a trace log with 3 %-args
-
trace: format withArguments: arg1
-
generate a trace log with %-args
-
warn: message
-
generate a warning
-
warn: message with: arg1
-
generate a warning with one %-arg
-
warn: message with: arg1 with: arg2
-
generate a warning with two %-args
-
warn: message with: arg1 with: arg2 with: arg3
-
generate a warning with three %-args
-
warn: message with: arg1 with: arg2 with: arg3 with: arg4
-
generate a warning with four %-args
-
warn: format withArguments: arg1
-
generate a warning with %-args
-
warning: message
-
generate a warning
-
warning: format with: arg1
-
generate a warning with one %-arg
-
warning: format with: arg1 with: arg2
-
generate a warning with two %-args
-
warning: format with: arg1 with: arg2 with: arg3
-
generate a warning with three %-args
-
warning: format with: arg1 with: arg2 with: arg3 with: arg4
-
generate a warning with four %-args
-
warning: format withArguments: arg1
-
generate a warning with %-args
private
-
ansiColorEscapeForSeverity: numericSeverity
-
ansii color escapes are:
black fg: ESC[30m / bg: ESC[40m
dark red ESC[31m / bg: ESC[41m
dark green ESC[32m / bg: ESC[42m
dark yellow ESC[33m / bg: ESC[43m
dark blue
dark magenta
dark cyan
dark white eg. light grey). ESC[37m / bg: ESC[47m
bright black eg. darkGray fg: ESC[90m / bg: ESC[100m
bright red ESC[91m / bg: ESC[101m
bright green
bright yellow
bright blue
bright magenta
bright cyan
white ESC[97m / bg: ESC[107m
-
colorForSeverity: numericSeverity
-
Logger info:'hello'
-
expand: message
-
-
expand: message addingInfoFrom: aContext to: aDictionary
-
Logger warning:'some problem with %(RECEIVER)'
Logger warning:'some problem with %(RECEIVER) in %(LINE)'
Logger warning:'some problem with %(CLASS) in %(LINE)'
Logger warning:'some problem with %(MCLASS) in %(LINE)'
Logger warning:'some problem with %(SELECTOR) in [%(LINE)]'
Logger warning:'some problem with %(WHERE)'
-
expand: message with: arg1
-
-
expand: message with: arg1 with: arg2
-
-
expand: message with: arg1 with: arg2 with: arg3
-
-
expand: message with: arg1 with: arg2 with: arg3 with: arg4
-
-
expand: message with: arg1 with: arg2 with: arg3 with: arg4 with: arg5
-
-
expand: message withArguments: args
-
-
facilityOf: originator
-
^ originator class
Usage example(s):
Logger facilityOf: Object
Logger facilityOf: Expecco::Browser
|
-
getLogWriterInfo
-
walk up the call stack to find where the log was created.
This will first skip over my own helper method contexts,
then over all methods marked with a <skipInLog> annotation.
Return this info as a string of the form:
'[class>>method [lineNr]'
-
severityFromLoggingThreshold: severityOrNameOrNil
-
converts a numeric or symbolic thresholdlevel to a severity instance.
Usage example(s):
Logger severityFromLoggingThreshold: Logger severityALL.
Logger severityFromLoggingThreshold: 'all'.
Logger severityFromLoggingThreshold: Logger severityINFO. -- info, warnings and errors
Logger severityFromLoggingThreshold: 'info'.
Logger severityFromLoggingThreshold: Logger severityTRACE. -- trace, debug, info, warnings and errors
Logger severityFromLoggingThreshold: Logger severityDEBUG. -- debug, info, warnings and errors
Logger severityFromLoggingThreshold: 'debug'.
Logger severityFromLoggingThreshold: 50.
Logger severityFromLoggingThreshold: 51.
|
-
severityThresholdOf: originator
-
allow each class to define an individual threshold for Logging
Usage example(s):
Logger severityThresholdOf: Object
Logger severityThresholdOf: Expecco::Browser
Logger loggingThreshold:(Logger severityDEBUG) forClass:(Expecco::Browser).
Logger loggingThreshold:(Logger severityDEBUG) forPackage:'stx:libbasic'.
Logger loggingThreshold:nil forClass:(Expecco::Browser).
Logger loggingThreshold:nil forPackage:'stx:libbasic'.
|
-
severityThresholdOf: originator facility: facility
-
allow each class to define an individual threshold for Logging
Usage example(s):
Logger severityThresholdOf: Object
Logger severityThresholdOf: Expecco::Browser
Logger loggingThreshold:(Logger severityDEBUG) forClass:(Expecco::Browser).
Logger loggingThreshold:(Logger severityDEBUG) forPackage:'stx:libbasic'.
Logger loggingThreshold:nil forClass:(Expecco::Browser).
Logger loggingThreshold:nil forPackage:'stx:libbasic'.
|
queries
-
canLog
-
answer true, if logging is to be performed.
Subclasse may redefine this.
-
isNotLoggingInfo
-
a quick rejector to avoid overhead in deployed apps
Severity
Simple logging (make sure logging threshold is lower or equal then
Logger severityDEBUG, see #loggingThreshold:)
Logger loggingThreshold
Logger loggingThreshold:(Logger severityDEBUG)
Logger debug: 'Hello world!'
|
Logger info: 'Hello world!'
Logger warning: 'Hello world!'
Logger error: 'Hello world!'
Logger fatal: 'Hello world!'
|
You may use #<severity>:with:with: utility to format log message:
|hostname port|
hostname := 'www.google.com'.
port := 80.
Logger error: 'Cannot connect to %1:%2' with: hostname with: port
|
and even automatically include a lineNumber:
Logger info: '[%(CLASS)>>%(SELECTOR):%(LINE)] Hello world!'
|
|