It is useful to have a log of input to Glish and the output Glish
generates. There are several ways which this logging information can
be processed. Probably the simplest way is to have logging information
go to a file. Setting system.output.log to a text string, which
represents a valid directory path to a file. If the path is valid, all
input and all output will be logged to that file. The following
commands:
system.output.log := "one.log"
a := array(1:16,4,4)
print a
system.output.log := F
print a
would result in a file called one.log in the current directory with
the contents:
a := array(1:16,4,4)
print a
#[[1:4,]
# 1 5 9 13
# 2 6 10 14
# 3 7 11 15
# 4 8 12 16]
system.output.log := F
The output generated by Glish is preceeded by a ``#''. If the user
wishes to only log the commands, setting system.output.ilog will
log only the commands, e.g. leaving out the lines commented by ``#''
above. Similarly, setting system.output.olog will only the output
and not the input.
For more complicated applications, each of these record fields, i.e. log, ilog, and olog, can be set to a function which takes a single parameter. The function will then be called repeatedly with the line to be logged; the function then logs the line. Likewise, these fields can be assigned to an agent. In this case, each line to be logged is sent as an event where the event name is append and the event value is the line to be logged.