WhizzML Reference Manual
4.11 Logging
There’s no interactive input in WhizzML, but you can output logs using the procedures enumerated below. All of them take any number of arguments, coerce them to strings and ouput the result of concatenating those strings, prepended by a the log level label, when the current log level is equal or greater to the requested one.
(log-debug obj1 …) \(\rightarrow \) false
(log-info obj1 …) \(\rightarrow \) false
(log-warn obj1 …) \(\rightarrow \) false
(log-error obj1 …) \(\rightarrow \) false
For instance, the statement
(let (x 3) (log-info "The x value is " x))
will log the message
INFO: The x value is 3
when you run your script locally. When WhizzML scripts are run on the server side, logs are collected in a map of the execution metadata, as lists of strings keyed by log level.
As mentioned, logs are only output if the requested log level is not below the current minimum log level. By default, the minimum log level is set to “info”. You can query and alter it using these two standard procedures:
(log-level ) \(\rightarrow \) integer
(set-log-level int) \(\rightarrow \) integer
There is also a special form that will automatically log the running time for any group of expressions:
(with-time-log body) \(\rightarrow \) object
This form will evaluate its body normally, but will also compute the time the evaluation took, and write a log with that information. Since it evaluates to its body’s value, the with-time-log expression can be used in any place its body would be used. For instance:
(+ (with-time-log (+ 1 2 3)) 8) ;; => 14
Evaluating the above expression will also give you a log similar to:
INFO: Elapsed time: 1
Finally, there’s a special log function to report progress in script executions, and an associated accessor:
(log-progress num) \(\rightarrow \) number
(logged-progress ) \(\rightarrow \) number
The log-progress primitive will update the progress reported by your WhizzML execution (when run in BigML’s servers) to the given value, after coercing it to the unit interval [0, 1]. It evaluates to the actual value stored as the current progress, which can also be retrieved at any later moment using logged-progress:
(log-progress 0.12) ;; => 0.12
(logged-progress) ;; => 0.12
(log-progress 0.9) ;; => 0.9
(log-progress 0.7) ;; => 0.7
(logged-progress) ;; => 0.7
(log-progress 23) ;; => 1.0
(logged-progress) ;; => 1.0