Hi Thorsten

I'm not sure if I understand you correctly.
You can use (log) in different ways, e.g.:
(log "just a message")
(log 'debug "variable x is" x)
(log 'warn "folder size is reaching >1GB")
(log 'error "a fatal error occured")

If (on *LogOn), all messages get printed.
If (setq *LogOn 'warn), only warn and error messages (the 2 at bottom)
will be printed.
If (setq *LogOn 'error), only the last message will be printed.

So you can put (log 'debug ...) all over the place in the code, but
deactivate them during production by setting (setq *LogOn 'error) at start
of your program.
You can also reactivate debug just in parts of code, by declaring the
variables locally, e.g.:

(setq *LogOn 'warn)
(setq *LogW "+/var/log/pilapp.warning.log")
(setq *LogE "+/var/log/pilapp.error.log")
# normal programm, only print warnings and errors
(log 'debug "blabla") # ignored, because (= *LogOn 'warn)
..
(let *LogOn T
  (log 'debug "currently testing this code) # not ignored
  (somestuff)
  (somemorestuff) )
..
(log 'debug "morebla") # ignored again

So far this system only handles messages which you explicitly send
yourself with (log Type any ...). Error ouput from pil isn't getting
handled, as I don't know how I could do that. Pil error messages can be
redirected to a file with (err), but I don't see a way to get it
redirected to a function...

Does this answer your question?
Else join the IRC if you can ( #picolisp on freenode.net), I'm currently
online.

Cheers,
Andreas


> Thorsten Jolitz <tjol...@gmail.com>
> writes:
>
> after testing a bit more I have one question:
>
> It seems the levels 'warning and 'error unconditionally print their
> messages when *LogOn is set to them, but from my understanding these
> levels would eventually be turned-on in production code and thus
> should only print something when something goes wrong in the program
> execution.
>
> Would it be possible to only log messages from catched error with level
> 'warning and try to log some system information when there is a real
> uncatched error with log-level 'error? So that level 'warning would
> become the default level for production code and nothing is printed as
> long as the program runs smoothly?
>
> --
> cheers,
> Thorsten
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>



-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to