40ants / lisp-project-of-the-day

Here I'll post notes about Quicklisp projects. Also I publish them on Twitter account svetlyak40wt.
http://40ants.com/lisp-project-of-the-day/
BSD 2-Clause "Simplified" License
51 stars 6 forks source link

log4cl-extras #22

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

log4cl-extras

https://40ants.com/lisp-project-of-the-day/2020/07/0136-log4cl-extras.html

vindarel commented 3 years ago

Nice!

a macro to capture unhandled errors along with their tracebacks.

this looks like what Sentry does, for which we have a CL client: https://github.com/mmontone/cl-sentry-client (with the benefit of having a web dashboard and email notifications)

svetlyak40wt commented 3 years ago

Yes, it is similar to sentry, but for Ultralisp I send all logs to Datadog and in case of some error it is possible to find also debug messages, logged before the error (thanks to the "request_id" trick). This way you will get more information about what happened.

Another useful trick, I like, but didn't implement yet is "Crossfinger Logging". Crossfinger logger buffer all log messages and output them only if the error was also logged. Here is the peseudo-code:

(with-crossed-fingers
   (with-log-unhandled
       (log:debug "Just working")
       (log:info "Everything is fine")
       (log:info "Nothing to worry about")

       (when (< (random 100)
                         10)
           (error "Some shit happened and I need to write to log all messages you see above!"))))

This helps to reduce log size. It will not be cluttered with numerous INFO and DEBUG messages unless something bad happens in this block. Info and debug messages will be written only on error and discarded otherwise.

That is the feature I'd like to add to log4cl-extras myself or to accept as a contribution ;-)