Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The example usage in the docs for SensibleSink doesn't seem to work #10

Open
pfmoore opened this issue Mar 15, 2021 · 0 comments
Open

Comments

@pfmoore
Copy link

pfmoore commented Mar 15, 2021

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"):
    pass

The 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant