home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
d
/
dbassist2
/
!SysLog
/
!Help
< prev
next >
Wrap
Text File
|
1997-04-23
|
23KB
|
575 lines
============================================================================
SysLog Documentation
----------------------------------------------------------------------------
Version: 0.17
Author: Jon Ribbens <jon@doggysoft.co.uk>
(c) DoggySoft Ltd., 1995, 1996, 1997
This program is Freeware and may be freely distributed so long as it is
not charged for, and none of the files are changed or removed. It may be
included with a commercial program which is charged for. There is no
warranty, express or implied. DoggySoft Ltd. is not liable for any loss
or damages caused by the use or misuse of this program.
Things done:
* facility to insert arbitrary line
* considered format of datestamp
* implemented backoff system for errors writing to logs (partly a bugfix)
* fixed bug which left files open on errors (e.g. disk full)
* added Indent/UnIndent/NoIndent
* do 'temporary logs' thingy for Termite session logs
* implement log truncation at specified maximum size
* read <SysLog$Dir> once and once only at startup
* do automatic tidy-up of 'temporary logs'
* fixed bug which corrupted the very last line in the options file
* get allocation for SWI chunk and module name and OS commands
* user options to disable session logs
* added "*" line in options file to specify default values
* reserve disk space option
* make entry point use two-layer task, so RMEnsuring works
* add *SysLog ON|OFF and *SysLog <log> <new priority>
* LogData routine to log a block of hex data (e.g. IP packets)
* add debugf routine for assembler people
* add C front-end for C people
* added SysLog_ReadErrorMessage
* added %<reg>p and %<reg>a to LogFormatted
* fixed order of %<reg>a (it was backwards)
* made log buffer size dependent on logging level
* made log buffer get de-allocated after ten minutes
* added SysLog_LogComplete
* made buffer size be recalculated when log level is changed
* made setting log level also apply to session logs of that log
* fixed tidying up of stray session logs (sometimes missed some)
* fixed a few problems with sessions
0.15
* termination of strings is now by zero-byte or line-feed
0.16
* add log_forget and call it in CloseSessionLog
0.17
* allow CR as a string terminator
* automatically create 'Old' directory on startup
* added 'IRQ mode'
To do:
* add expression evaluation to LogFormatted
* add optional checking of pointer validity
* add 'features flags'
============================================================================
Rationale
----------------------------------------------------------------------------
Termite is currently lacking in logging facilities. In fact, most
communications software for the Arc is rather poor at logging. This module
is designed to make it easy for comprehensive logging to be added to any
RISC OS program.
The logging level can be altered by the user for individual log files, and
buffering is used to speed logging, so it is safe for programs to log large
quantities of data, provided that they use sensible priorities for each type
of message. The logs are also automatically kept to user-specified maximum
lengths, so there is no need to worry about filling up the user's hard disk.
Separate log files are used for each application, on the basis that such
segregation of information makes it much easier for the user to find what
they're looking for.
A back-off system is used for dealing with errors when writing to logs. Each
error is logged in the "SysLog" log, and the offending log is marked as
"dead". SysLog will then not attempt to write to that log again for one
second. If we again get an error writing to the log, we multiply the
"back-off" time by 1.5, and again mark the log as dead. The back-off time is
not allowed to grow longer than ten minutes.
============================================================================
Session logs
----------------------------------------------------------------------------
Usually, log entries are stored strictly chronologically. Sometimes, though,
it may be more useful to store them grouped by 'session'. For example,
NewsBite can have several incoming NNTP connections at once. It is nice to
group the log messages that are coming from each separate connection
together. This can be done using SysLog_OpenSessionLog.
SysLog_OpenSessionLog creates a specially-named temporary log file. The log
entries for the session are stored in this log file. When the temporary log
file is closed using SysLog_CloseSessionLog, this data is appended in one
chunk to the end of the main log.
SysLog checks for stray temporary log files when it initialises and
finalises, and appends them to the relevant logs. This copes with the
situation where an application crashes or otherwise exits without calling
SysLog_CloseSessionLog.
============================================================================
Priorities
----------------------------------------------------------------------------
Message priorities can be in the range 0 to 255, with 0 being the highest
priority and 255 being the lowest. Unless otherwise specified by the user,
only messages with priorities of less than 125 are stored in the log files.
You should therefore think about what things the user is likely to want to
have logged by default, and ensure that these things are logged at
a priority of 124 or less.
The priority of errors often depends on how significant the consequences of
the error are, not what the cause of it is. e.g. sometimes "out of memory"
will be an extremely important unrecoverable error (because the program
can't start up), and sometimes it will be unimportant (because the program
can use disk instead, or maybe try again later).
============================================================================
Log names
----------------------------------------------------------------------------
Log names are used as the leafnames to store the logs as, so they must
comply with the rules for RISC OS leafnames. They must also not be longer
than ten characters.
It is intended that each application have its own log, so an obvious choice
for the log name is the application name (without the '!'). Very large
applications could have more than one log file - in which case the naming
scheme is unspecified. Try and choose sensible log names.
If your application is going to be distributed, you should write to
support@doggysoft.co.uk, to request that your log name be formally
allocated. This will hopefully avoid having more than one program using the
same log file.
The following log names are reserved for internal use:
any name beginning with a '-' character
any name beginning with "SysLog"
"Old"
============================================================================
OS commands
----------------------------------------------------------------------------
*SysLog <log name> <priority> <message>
------
Adds a time-stamped message to the log file, if and only if the specified
log file is set up to log messages of this priority. The priority must be in
the range 0-255.
*SysLog <log name> <new priority>
------
Temporarily (but with immediate effect) changes the logging priority of the
specified log. The priority must be in the range 0-256.
*SysLog ON|OFF
------
*SysLog OFF will temporary disable SysLog - all log messages received after
this command is issued will be ignored. *SysLog ON resumes normal operation.
*SysLog_Flush ON|OFF
------------
*SysLog_Flush with no paramaters flushes all currently open log files to
disk. If it used with the parameter 'ON' then it causes all log files to be
flushed immediately after each message is written to them. *SysLog_Flush OFF
disables this behaviour. (This is intended for use when the a program is
being debugged, and keeps crashing the computer. With SysLog_Flush ON,
you're guaranteed that all the log information your program produces before
it crashes will actually be available after a re-boot. It also makes logging
*very slow*.)
============================================================================
SWIs
-----------------------------------------------------------