log
Package: WA2L/edrc 1.5.57
Section: Library Commands (3)
Updated: 10 April 2009
Index
Return to Main Contents
NAME
log - write a message to a logfile
SYNOPSIS
edrc/lib/log level "message text"
log
-h
AVAILABILITY
WA2L/edrc
DESCRIPTION
This command is used in scripts to write a standardized message to a
log file.
The message is appended to
a logfile
and has the format:
-
YYYYY-MM-DD HH:MM:SS [ <Session> ] <Scriptname>-<LEVEL>:
<message text>
Example:
-
2008-12-14 14:00:05 [SAT_6031] my_script-ERROR: dir '/dat/report/myreport' does not exist.
The
<Scriptname>
is derived from the
$EDRC_SCRIPTNAME
environment variable, the
<LEVEL>
is the upper case of the
level
string given as the first option of the command. The
<Session>
is derived from the
$EDRC_SESSION
environment variable if set, else the process id of the calling script
is logged. The message text is written as received from the other
options of the command.
OPTIONS
- level
-
Message level. The string given here is printed in upper case. There
is no restriction in the
level
strings, a convention used in commands within WA2L/edrc is:
-
- INFO
-
Information messages.
- ERROR
-
An error occurred, that questions the correct output or function of
the command. An error has to be corrected to ensure that the command
can complete successfully.
- WARNING
-
A non critical malfunction of the command occurred. Often a
WARNING
can be ignored, but in some occasions a warning can also lead to a
minor reduction in output quality. A warning has to be analyzed and
rated by the user.
- FATAL
-
A fatal error is a condition that has to be analyzed and that needs
user intervention and correction to ensure proper functionality.
- message text
-
message to be printed.
ENVIRONMENT
- $EDRC_SCRIPTNAME
-
scriptname that is printed in the
<Scriptname>
part of the output.
- $EDRC_LOGFILE
-
logfile where the log entries are appended to.
- $TZ
-
time zone.
EXIT STATUS
- 0
-
no error.
- 4
-
usage listed.
EXAMPLES
The following examples are script cut-outs of Bourne-, Korn- or
Bash shell scripts:
- 1) common usage
-
EDRC_SCRIPTNAME=`basename $0`; export EDRC_SCRIPTNAME
EDRC_LOGFILE=/var/log/`basename $0`.log; export EDRC_LOGFILE
log INFO "command started"
- 2) set a session usage
-
EDRC_SCRIPTNAME=`basename $0`; export EDRC_SCRIPTNAME
EDRC_LOGFILE=/var/log/`basename $0`.log; export EDRC_LOGFILE
EDRC_SESSION=SAT_6031; export EDRC_SESSION
log INFO "command started"
SEE ALSO
edrcintro(1),
msg(3),
sh(1),
ksh(1)
NOTES
-
BUGS
-
AUTHOR
log was developed by Christian Walther. Send suggestions
and bug reports to wa2l@users.sourceforge.net .
COPYRIGHT
Copyright © 2009
Christian Walther
This is free software; see
edrc/doc/COPYING
for copying conditions. There is ABSOLUTELY NO WARRANTY; not
even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This document was created by man2html
using the manual pages.
Time: 17:19:03 GMT, April 17, 2025