I'm including a couple of minor actual logging entries here for exhibition purposes (including the one detail I most often wish I had access to - "what is the actual options object right now?"), but for the most part, this slice is about implementing the logger, and not about using it.
We add a Logger class (and a Logging module that provides convenience methods for using it) - it exposes both configuration controls and actual logging methods like info, warn, and debug, which are able to accept an optional data object alongside the message.
The logger writes its logs out in a separate set of colors, and prefixed with a [ INFO] style tag (matching the label, of course). Default log-level is 'warn', but for each -v passed it will go up one step (currently there's only 'info' and then 'debug', but 'ultra' will probably eventually be warranted).
The logging verbosity can be configured through the cli only, and is completely separate from the logging configuration that controls presentation style (logging: quiet won't turn off this type of logging for example). We might eventually want to adjust the naming there, but that'll be a breaking change, so I won't worry about it yet.
I definitely recommend reading this by commit, as it is broken down neatly in that direction.
I'm including a couple of minor actual logging entries here for exhibition purposes (including the one detail I most often wish I had access to - "what is the actual options object right now?"), but for the most part, this slice is about implementing the logger, and not about using it.
We add a Logger class (and a Logging module that provides convenience methods for using it) - it exposes both configuration controls and actual logging methods like
info
,warn
, anddebug
, which are able to accept an optional data object alongside the message.The logger writes its logs out in a separate set of colors, and prefixed with a
[ INFO]
style tag (matching the label, of course). Default log-level is 'warn', but for each-v
passed it will go up one step (currently there's only 'info' and then 'debug', but 'ultra' will probably eventually be warranted).The logging verbosity can be configured through the cli only, and is completely separate from the
logging
configuration that controls presentation style (logging: quiet
won't turn off this type of logging for example). We might eventually want to adjust the naming there, but that'll be a breaking change, so I won't worry about it yet.I definitely recommend reading this by commit, as it is broken down neatly in that direction.
Examples