-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
I took the example code from here and put some boilerplate code around it:
from lithoxyl import Logger
app_log = Logger("myapp")
from lithoxyl import (SensibleFilter,
SensibleFormatter,
StreamEmitter,
SensibleSink)
# Create a filter that controls output verbosity
fltr = SensibleFilter(success='critical',
failure='info',
exception='debug')
# Create a simple formatter with just two bits of info:
# The time since startup/import and end event message.
# These are just two of the built-in "fields",
# and the syntax is new-style string formatting syntax.
fmtr = SensibleFormatter('+{import_delta_s} - {end_message}')
# Create an emitter to write to stderr. 'stdout' and open file objects
# also behave predictably.
emtr = StreamEmitter('stderr')
# Tie them all together. Note that filters accepts an iterable
sink = SensibleSink(filters=[fltr], formatter=fmtr, emitter=emtr)
# Add the sink to app_log, a vanilla Logger created above
app_log.add_sink(sink)
with app_log.info("Main code"):
passThe resulting code, when run, produces no output. It doesn't matter if I use app_log.critical, still no output.
It's quite possible I'm doing something wrong here - I could find no "complete" examples of how to use SensibleSink - but at a minimum I think the documentation should include a fully working example.
This is using Python 3.9 on Windows 10, with the version of lithoxy from PyPI (20.0.0) in case it matters. I also tried with Python 3.8 and 3.7, just in case, and got the same result.
Metadata
Metadata
Assignees
Labels
No labels