PapcoDoc/documents/PapcoLoggers
From PapcoWiki
Contents |
Using PaPCo loggers
Papco loggers are objects that receive messages logging the evolution of a system. The interface is introduced to control separately:
- who receives the message (e.g. a software developer or end user),
- the verbosity level, and
- what is done to handle the message (e.g. write it to a log file with a time tag.)
Logger clients
Here's an example program that uses a logger:
pro myProcess
logger= papco_get_logger('end_user')
logger->info( 'starting loop' )
for i=0,10 do begin
logger->fine('i='+strtrim(i,2))
;; code
endfor
logger->info('done with loop')
end
papco_set_loglevel, 'end_user', 'info' myProcess ;; shows just the 'info' messages
Note that at the time that the program is coded, the software isn’t concerned with what happens to the messages, it just logs the steps it took to complete the process. Later when the end user needs a better understanding of what’s going on in the process, he can increase the verbosity of the end_user logger:
papco_set_loglevel, 'end_user', 'finest' myProcess ;; shows all messages
PaPCo Loggers
When PaPCo starts up, it creates two loggers, "developer" and "end_user." You can send messages to either one as shown above. You can create new loggers, too, like so:
papco_add_logger, 'cluster_cdf_developer', obj_new( 'papco_logger', 'all' )
(Then before committing the module for distribution, you'd set the log level to 'none')
Log Level Definitions, taken from the java Logging API.
- OFF is a special level that can be used to turn off logging. This level is initialized to Integer.MAX_VALUE.
- SEVERE is a message level indicating a serious failure.
- In general SEVERE messages should describe events that are of considerable importance and which will prevent normal program execution. They should be reasonably intelligible to end users and to system administrators.
- This level is initialized to 1000.
- WARNING is a message level indicating a potential problem.
- In general WARNING messages should describe events that will be of interest to end users or system managers, or which indicate potential problems.
- This level is initialized to 900.
- INFO is a message level for informational messages.
- Typically INFO messages will be written to the console or its equivalent.
- So the INFO level should only be used for reasonably significant messages that will make sense to end users and system admins.
- This level is initialized to 800.
- CONFIG is a message level for static configuration messages.
- CONFIG messages are intended to provide a variety of static configuration information, to assist in debugging problems that may be associated with particular configurations.
- For example, CONFIG message might include the CPU type, the graphics depth, the GUI look-and-feel, etc.
- This level is initialized to 700.
- FINE is a message level providing tracing information.
- All of FINE, FINER, and FINEST are intended for relatively detailed tracing.
- The exact meaning of the three levels will vary between subsystems, but in general, FINEST should be used for the most voluminous detailed output, FINER for somewhat less detailed output, and FINE for the lowest volume (and most important) messages.
- In general the FINE level should be used for information that will be broadly interesting to developers who do not have a specialized interest in the specific subsystem.
- FINE messages might include things like minor (recoverable) failures.
- Issues indicating potential performance problems are also worth logging as FINE.
- This level is initialized to 500.
- FINER indicates a fairly detailed tracing message.
- By default logging calls for entering, returning, or throwing an exception are traced at this level.
- This level is initialized to 400.
- FINEST indicates a highly detailed tracing message.
- This level is initialized to 300.
- ALL indicates that all messages should be logged.
- This level is initialized to Integer.MIN_VALUE.

