Logging consists of two parts. web::log issues a logging message, while web::loglevel and web::logdest determine where to send a message. Websh uses a two-step filtering. First, Websh determines whether it should handle a message, or not, using the levels configured with web::loglevel. Then, Websh determines which message is to be sent where, using the the additional filters and destinations configured with web::logdest. There is no logging per default. Setting levels with web::loglevel is mandatory.
A filter consists of a tag and a level, separated by a ".". The tag is free text. Typically, it is the name of the application, say "foo". Example: "ws3.debug". Levels are, in order:
web::logdest
subcommand
?options
? args
Subcommands are: add, delete, names, and levels.
options
?
level
plugin
?plugin-specific options
?-maxchar n
truncates the message to a
maximum of n
characters.
strftime()
plus: $p
(process id), $t
(thread id), $l
(log level), $n
(numerical log level), $f
(log facility), $m
(the message), and $$
(dollar sign).
"%x %X [\$p] \$f.\$l: \$m\n"
web::logdest add -maxchar 25 -format "%x %X \$l \$m\n" *.-debug command logTest
name
?-requests
to delete all destinations except the one defined from
within web::initializer code is only
used internally.)
names
levels
web::loglevel
subcommand argsSubcommands are: add, delete, names, and levels. Levels defined using web::loglevel act as a filter for log messages sent by Websh. Only messages that pass at least one level defined using this command are passed to the log destinations configured using web::logdest
level
name
?-requests
to delete all levels except the one defined from within
web::initializer code is only used
internally.)
names
levels
web::log
level
msg
Issues a log message. It is possible, should the user so desire, to have the web::log run subst on its arguments. This behaviour is turned off by default, and can be turned on by doing:
web::config logsubst 1
.
web::logdest
add destination
.-level
file ?options
? filename
Option is: -unbuffered
Log messages are sent to the file filename, which is opened in append mode at the time of this call and stays open until this destination is deleted. This is either at the end of the request (mod_websh) or when the interpreter is deleted.
The file opened using the permissions configured with web::config filepermissions. Default: 0644.
web::logdest
add *.-debug syslog ?level
?See the man page for syslog for levels on your system. Typical: 10. Available under Unix only.
web::logdest
add *.-debug command cmdName
The log message is sent to a Tcl command taking the message as an argument. E.g.
% proc logCommand {msg} { puts "---- here comes the message ----" puts -nonewline $msg puts "----- that was the message -----" } % % web::loglevel add *.-debug loglevel0 % web::logdest add *.-debug command logCommand logdest0 % web::log debug "a log message" ---- here comes the message ---- 10/28/05 13:44:26 [20596] user.debug: a log message ----- that was the message ----- %
web::logdest
add *.-debug channel ?options
? channel
Option is: -unbuffered
Writes the message to the Tcl channel channel.
web::logdest
add *.-debug apache Sends the message to the Apache ErrorLog file. Available within mod_websh only.
Example 11. web::log, web::loglevel, and web::logdest
% web::loglevel add *.-debug loglevel0 % web::logdest add *.-debug channel stdout logdest0 % web::log info {Websh is cool} 03/01/00 00:00:00 [111] user.info: Websh is cool % web::logdest delete % web::logdest add -format "--> \$m\n" *.-debug channel stdout logdest0 % web::log info {Websh is cool} --> Websh is cool % web::logdest delete % web::logdest add -maxchar 5 *.-debug channel stdout % web::log info {Websh is cool} 03/01/00 00:00:00 [111] user.info: Websh %