Google cloud logging compatible structured logging.
This project uses pino (used to be bunyan but that is unmaintained) for it's logging make sure you added that to your dependencies by running:
yarn add --exact pino
See the below example for usage examples:
(ns example
;; First make sure you add this require
(:require [com.avisi-apps.gaps.log :as log]))
;; You need to log maps, make sure to always add a `:message`
(log/info {:message "My human readable message"
:extra-information {:tenant-id "foo"}
:answer 42})
;; You can log errors
(log/error error {:message "Something horrible happend"
:debug-information {:input 13}})
;; Make sure to only log something as an error when necessary you can also use warn
(log/warn {:message "Something has happend which does not need our attention immediately"
:error error ;; You can still give it the error and it will extract information from it
})
;; You can also log debug message (are by default only enabled in shadow-cljs dev mode)
;; Will be removed on release builds
(log/debug {:message "debug logging"})
If you want to make the output of logging more readable you can use pino-pretty
. You can enable this by adding it as
a preload in your shadow-cljs.edn
{:devtools {:preloads [com.avisi-apps.gaps.log.preload]}}
Make sure to save the pino-pretty module as a dev dependency:
yarn add --dev --exact pino-pretty