eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'MiniLogger':

Home

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

Class: MiniLogger


Inheritance:

   Object
   |
   +--MiniLogger

Package:
stx:libbasic
Category:
System-Debugging-Support
Version:
rev: 1.50 date: 2018/04/26 10:13:54
user: cg
file: MiniLogger.st directory: libbasic
module: stx stc-classLibrary: libbasic
Author:
Jan Vrany <jan.vrany@fit.cvut.cz>

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.

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


Related information:

    Loggia
    logging
    framework
    [stx]

Class protocol:

accessing-log format
o  logFormat
will be used for the log message as:
%1 [%2] (%3): %4
with %1: facility (area)
with %2: secerity (area)
with %3: timestamp
with %4: caller/originator
with %5: message
usage example(s):
     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): %4
with %1: facility (area)
with %2: secerity (area)
with %3: timestamp
with %4: caller/originator
with %5: message.
Pass anil argument to return to the default format.

usage example(s):
     MiniLogger logFormat:'%1 [%2]: %5'.
     'hello' errorPrintCR.
     MiniLogger logFormat:'%3 %1 [%2]: %5'.
     'hello' errorPrintCR.
     MiniLogger logFormat:nil.
     'hello' errorPrintCR.

o  logOnStderr

o  logOnStderr: aBoolean
enable/disable logging on stderr
usage example(s):
     MiniLogger logOnStderr:false
     MiniLogger logOnTranscript:false

     MiniLogger logOnStderr:true
     MiniLogger logOnTranscript:true

o  logOnTranscript

o  logOnTranscript: aBoolean
enable/disable logging on the Transcript
usage example(s):
     MiniLogger logOnStderr:false
     MiniLogger logOnTranscript:false

     MiniLogger logOnStderr:true
     MiniLogger logOnTranscript:true

o  timestampFormat
will be used for the log message

o  timestampFormat: aTimestampFormatString
will be used for the log message

accessing-severities
o  severities

o  severityDEBUG

o  severityENTER

o  severityERROR

o  severityFATAL

o  severityINFO

o  severityLEAVE

o  severityTRACE

o  severityTRACE0

o  severityTRACE1

o  severityTRACE2

o  severityTRACE3

o  severityWARN

accessing-severities-special
o  severityALL

o  severityNONE

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

o  loggingThreshold: severity
Sets logging threshold.
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
usage example(s):
    Logger loggingThreshold: Logger severityALL.
    Logger loggingThreshold: Logger severityINFO.
    Logger loggingThreshold: Logger severityDEBUG.
    
    Logger loggingThreshold: Logger severityNONE.

o  loggingThreshold: aLimitOrNil forClass: aClass
allows individual per-class setting of the threshold (useful during debugging).
With a nil limit, the default is reinstalled for that class.
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: aLimitOrNil forPackage: aPackageName
allows individual per-package setting of the threshold (useful during debugging).
With a nil limit, the default is reinstalled for that class.
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'.

initialization
o  initialize
(comment from inherited method)
called only once - initialize signals

logging
o  log: message

o  log: message facility: facility

o  log: message severity: severity

o  log: message severity: severity attachment: attachment

o  log: message severity: severity facility: facility

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

o  log: message severity: severity facility: facility originator: originator attachment: attachment
Pricipal logging method. This mimics VM __stxLog__()
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 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'

o  log: message severity: severity originator: originator

logging - utils
o  debug: message
a quick rejector to avoid overhead in deployed apps

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

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

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

o  enter: message
a quick rejector to avoid overhead in deployed apps

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

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

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

o  error: message
a quick rejector to avoid overhead in deployed apps

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

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

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

o  fatal: message
a quick rejector to avoid overhead in deployed apps

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

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

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

o  info: message
a quick rejector to avoid overhead in deployed apps

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

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

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

o  leave: message
a quick rejector to avoid overhead in deployed apps

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

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

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

o  trace0: message
a quick rejector to avoid overhead in deployed apps

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

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

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

o  trace1: message
a quick rejector to avoid overhead in deployed apps

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

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

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

o  trace2: message
a quick rejector to avoid overhead in deployed apps

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
a quick rejector to avoid overhead in deployed apps

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

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

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

o  trace: message
a quick rejector to avoid overhead in deployed apps

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

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

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

o  warning: message
a quick rejector to avoid overhead in deployed apps

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

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

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

private
o  expand: message

o  expand: message addingInfoFrom: aContext to: aDictionary

o  expand: message with: arg1

o  expand: message with: arg1 with: arg2

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

o  facilityOf: originator
^ originator class
usage example(s):
     Logger facilityOf: Object
     Logger facilityOf: Expecco::Browser

o  log: message severity: severity facility: facilityArg originator: originator attachment: attachment on: aStream
Principal logging method. This mimics VM __stxLog__()
usage example(s):
     'hello' infoPrintCR.

     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

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


Private classes:

    Severity

Examples:


Simple logging (make sure logging threshold is lower or equal then Logger severityDEBUG, see #loggingThreshold:)
    Logger debug: '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 port %2' with: hostname with: port
and even automatically include a lineNumber:
    Logger info: '[%(CLASS)>>%(SELECTOR):%(LINE)] Hello world!'


ST/X 7.1.0.0; WebServer 1.663 at exept.de:8081; Sun, 22 Jul 2018 16:48:57 GMT