eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'MiniLogger':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: MiniLogger


Inheritance:

   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

Description:


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:]

copyright

COPYRIGHT (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.

Class protocol:

accessing-log format
o  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'.

o  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'.

o  logFile
if this is non-nil, the log goes into that file (possibly in addition to other destinations)

o  logFile: aFilename
if non-nil, the log goes into that file (possibly in addition to other destinations)

o  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.

o  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.

o  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

o  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.

o  logOnStderr
true if the log is sent to stderr (possibly in addition to other destinations)

o  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

o  logOnTranscript
true if logging on the Transcript is enabled (possibly in addition to other destinations)

o  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

o  timestampFormat
will be used for the log message

Usage example(s):

     Timestamp now printStringFormat:(self timestampFormat)
     self timestampFormat:'%h:%m:%s.%i'

o  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
o  severities
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE

o  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'.

o  severityENTER
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE

o  severityERROR
setting this as threshold will print errors

o  severityFATAL
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE

o  severityINFO
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE

o  severityLEAVE
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE

o  severityTRACE
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE

o  severityTRACE0
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE

o  severityTRACE1
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE

o  severityTRACE2
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE

o  severityTRACE3
ALL > FATAL > ERROR > WARN > INFO > DEBUG > TRACE0 > TRACE3 > NONE

o  severityWARN
setting this as threshold will print warnings and errors

accessing-severities-special
o  severityALL
setting this as thareshold will print all

o  severityNONE
setting this as threshold will suppress all logging

configuration
o  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'.

o  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'.

o  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' 

o  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' 

o  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'.

o  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'

o  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'.

o  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'.

o  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'.

o  loggingThresholdForClass: aClass
returns a per-class setting;
nil if there is none

o  loggingThresholdForFacility: aFacilityName
returns a per-facility setting;
nil if there is none

o  loggingThresholdForPackage: aPackageName
returns a per-package setting;
nil if there is none

o  setLoggingThresholdToDebug
sets the default threshold

o  setLoggingThresholdToError
sets the default threshold

o  setLoggingThresholdToInfo
sets the default threshold

o  setLoggingThresholdToWarning
sets the default threshold

initialization
o  initialize
do NOT ask the OS here, as this might not yet been initialized.

logging - basic
o  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__()

o  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
o  disableFastTrace
Disable the fastTrace feature

o  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.

o  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.

o  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.

o  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.

o  flushFastTrace

o  getFastTrace
|trace|

MiniLogger enableFastTrace:100.
MiniLogger fastTrace:'hello1'.
MiniLogger fastTrace:'hello2'.
MiniLogger fastTrace:'hello3'.
trace := MiniLogger getFastTrace.
MiniLogger disableFastTrace.
trace

logging - utils
o  debug: message
generate a 'debug'-log

Usage example(s):

     self debug:'hello'

o  debug: format with: arg1
generate a 'debug'-log

o  debug: format with: arg1 with: arg2
generate a 'debug'-log

o  debug: format with: arg1 with: arg2 with: arg3
generate a 'debug'-log

o  debug: format with: arg1 with: arg2 with: arg3 with: arg4
generate a 'debug'-log

o  debug: format with: arg1 with: arg2 with: arg3 with: arg4 with: arg5
generate a 'debug'-log

o  debug: format withArguments: arg1
generate a 'debug'-log

o  enter
generate an 'entering method...'-log,
showing the sender method's selector

o  enter: message
generate an 'entering method...'-log

o  enter: format with: arg1
generate an 'entering method...'-log

o  enter: format with: arg1 with: arg2
generate an 'entering method...'-log

o  enter: format with: arg1 with: arg2 with: arg3
generate an 'entering method...'-log

o  enter: format withArguments: arg1
generate an 'entering method...'-log

o  error: message
generate an 'error'-log

Usage example(s):

     Logger error:'some error message'
     Logger error:'hello %(WHERE)'

o  error: format with: arg1
generate an 'error'-log

Usage example(s):

     Logger error:'some %1 message' with:'foo'

o  error: format with: arg1 with: arg2
generate an 'error'-log

Usage example(s):

     Logger error:'some %1 %2' with:'foo' with:'bar'

o  error: format with: arg1 with: arg2 with: arg3
generate an 'error'-log

o  error: format with: arg1 with: arg2 with: arg3 with: arg4
generate an 'error'-log

o  error: format withArguments: arg1
generate an 'error'-log

o  fatal: message
generate a 'fatal'-log

o  fatal: format with: arg1
generate a 'fatal'-log

o  fatal: format with: arg1 with: arg2
generate a 'fatal'-log

o  fatal: format with: arg1 with: arg2 with: arg3
generate a 'fatal'-log

o  fatal: format withArguments: arg1
generate a 'fatal'-log

o  info: message
generate an 'info'-log

Usage example(s):

     Logger info:'some info message'

o  info: format with: arg1
generate an 'info'-log

Usage example(s):

     Logger info:'some %1 message' with:'foo'

o  info: format with: arg1 with: arg2
generate an 'info'-log

Usage example(s):

     Logger info:'some %1 message (%2)' with:'foo' with:'bar'

o  info: format with: arg1 with: arg2 with: arg3
generate an 'info'-log

o  info: format with: arg1 with: arg2 with: arg3 with: arg4
generate an 'info'-log

o  info: format withArguments: arg1
generate an 'info'-log

o  leave
generate a 'leaving method...'-log
showing the sender method's selector

o  leave: message
generate a 'leaving method...'-log

o  leave: format with: arg1
generate a 'leaving method...'-log

o  leave: format with: arg1 with: arg2
generate a 'leaving method...'-log

o  leave: format with: arg1 with: arg2 with: arg3
generate a 'leaving method...'-log

o  leave: format withArguments: arg1
generate a 'leaving method...'-log

o  log: message
generate a debug level log message

o  log: message facility: facility
generate a debug level log message for facility

o  log: message severity: severity
generate a debug level log message with severity

o  log: message severity: severity attachment: attachment
generate a debug level log message with severity and attached data

o  log: message severity: severity facility: facility

o  log: message severity: severity facility: facility originator: originator

o  log: message severity: severity originator: originatorOrNil
originator := originatorContext receiver.

o  log: message with: arg

o  log: format with: arg1 severity: severity
generate a debug level log message with severity and arg in message

o  log: message with: arg1 with: arg2

o  log: format with: arg1 with: arg2 severity: severity
generate a debug level log message with severity and arg in message

o  log: message with: arg1 with: arg2 with: arg3

o  log: message withArguments: args

o  trace
generate a trace log; this is special, in that it
prints the context of the sender

o  trace0: message
generate a 'debug trace'-log

o  trace0: format with: arg1
generate a 'debug trace'-log with one %-arg

o  trace0: format with: arg1 with: arg2
generate a 'debug trace'-log with two %-args

o  trace0: format with: arg1 with: arg2 with: arg3
generate a 'debug trace'-log with three %-args

o  trace1: message
generate a trace1-level log

o  trace1: format with: arg1
generate a trace1-level log with 1 %-arg

o  trace1: format with: arg1 with: arg2
generate a trace1-level log with 2 %-args

o  trace1: format with: arg1 with: arg2 with: arg3
generate a level1 trace-log with two %-args

o  trace2: message
generate a trace2-level log

o  trace2: format with: arg1
a quick rejector to avoid overhead in deployed apps

o  trace2: format with: arg1 with: arg2
a quick rejector to avoid overhead in deployed apps

o  trace2: format with: arg1 with: arg2 with: arg3
a quick rejector to avoid overhead in deployed apps

o  trace3: message
generate a trace3-level log

o  trace3: format with: arg1
generate a trace3-level log with one %-arg

o  trace3: format with: arg1 with: arg2
generate a trace3-level log with 2 %-args

o  trace3: format with: arg1 with: arg2 with: arg3
generate a trace3-level log with 3 %-args

o  trace: message
generate a trace log

o  trace: format with: arg1
generate a trace log with a %-arg

o  trace: format with: arg1 with: arg2
generate a trace log with two %-args

o  trace: format with: arg1 with: arg2 with: arg3
generate a trace log with 3 %-args

o  trace: format withArguments: arg1
generate a trace log with %-args

o  warn: message
generate a warning

o  warn: message with: arg1
generate a warning with one %-arg

o  warn: message with: arg1 with: arg2
generate a warning with two %-args

o  warn: message with: arg1 with: arg2 with: arg3
generate a warning with three %-args

o  warn: message with: arg1 with: arg2 with: arg3 with: arg4
generate a warning with four %-args

o  warn: format withArguments: arg1
generate a warning with %-args

o  warning: message
generate a warning

o  warning: format with: arg1
generate a warning with one %-arg

o  warning: format with: arg1 with: arg2
generate a warning with two %-args

o  warning: format with: arg1 with: arg2 with: arg3
generate a warning with three %-args

o  warning: format with: arg1 with: arg2 with: arg3 with: arg4
generate a warning with four %-args

o  warning: format withArguments: arg1
generate a warning with %-args

private
o  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

o  colorForSeverity: numericSeverity
Logger info:'hello'

o  expand: message

o  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)'

o  expand: message with: arg1

o  expand: message with: arg1 with: arg2

o  expand: message with: arg1 with: arg2 with: arg3

o  expand: message with: arg1 with: arg2 with: arg3 with: arg4

o  expand: message with: arg1 with: arg2 with: arg3 with: arg4 with: arg5

o  expand: message withArguments: args

o  facilityOf: originator
^ originator class

Usage example(s):

     Logger facilityOf: Object
     Logger facilityOf: Expecco::Browser

o  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]'

o  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.    

o  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'.

o  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
o  canLog
answer true, if logging is to be performed.
Subclasse may redefine this.

o  isNotLoggingInfo
a quick rejector to avoid overhead in deployed apps


Private classes:

    Severity

Examples:


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!'


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 04:36:08 GMT