Package joy ::
Module loggit
|
|
Module loggit
source code
loggit.py implements a general purpose logging interface and some convenience
functions for emitting both debug and progress messages.
The interface consists of the LogWriter class and several utility functions,
most notable of which is progress().
Functions:
dbgId, debugMsg -- used for generating useful debug messages
progress -- emit a text message "immediately" as a progress indication for
the user. Progress messages can also be emitted using speech synthesis
and may be automatically logged to one or more LogWriter-s.
iterlog -- iterator for log entries
Data Format:
loggit logs are GNU-zipped (using the gzip module) streams of 'safe' YAML
documents. YAML is a human and machine readable text format, much more
friendly than XML; see http://www.yaml.org . Each document contains a single
YAML mapping object, with at least a TIME integer and a TOPIC string. By
virtue of the YAML standard, mapping keys are sorted in ASCII lexicographic
order, so that if all other log entry mapping keys start with lowercase
letters the first two keys will be TIME and TOPIC, e.g.
--- {TIME: 286447, TOPIC: getter, func_name: get, value: 7}
|
LogWriter
Concrete class LogWriter provides an interface for logging data.
|
|
dbgId(obj)
Generate a unique, human readable name for an object |
source code
|
|
|
|
|
|
|
|
|
T0 = time()
|
|
PROGRESS_LOG = set()
|
|
__NEED_NL = False
|
Print a "debug" message. Debug messages are indicated by a
leading 'DBG' and the dbgId() of the object sending the message. This is
used to make it easier to identify the actual object that generated a
given message.
|
Print a progress message to standard output. The message will have a
pre-pended timestamp showing seconds elapsed from the moment the joy
module was imported.
Messages that start with the string "(say) " will be read out loud on
systems that support it. See the speak module for details.
Progress messages flush standard output, so they display immediately.
A copy of progress messages is write()n to every logger in PROGRESS_LOG
if sameLine is True, message is prefixed by a "
" instead of ending with
a "
" -- showing it on the same line in the terminal
|
Iterate over a logfile returning entry values
Entries have keys TIME and TOPIC for timestamp and topic
OUTPUT: t,topic,val
t -- timestamp
val -- dictionary with log entry values
|