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

Format placeholders #263

Open
JokerQyou opened this issue Jun 9, 2018 · 2 comments
Open

Format placeholders #263

JokerQyou opened this issue Jun 9, 2018 · 2 comments

Comments

@JokerQyou
Copy link

I read through the documentation site but did not find a single line of code mentioning about string format. So I assumed the basic concepts are the same. But when I go ahead and try it, things does not work as expected:

Python 3.6.5 (default, Mar 30 2018, 06:42:10)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging, sys, logbook
>>> logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)
>>> logging.debug('Hi %s', 'world')
DEBUG:root:Hi world
>>> logbook.StreamHandler(sys.stdout).push_application()
>>> logbook.debug('Hi %s', 'world')
[2018-06-09 13:01:12.360139] DEBUG: Generic: Hi %s
>>> logbook.__version__
'1.4.0'
>>> logbook.debug('Hi {}', 'world')
[2018-06-09 13:02:14.765765] DEBUG: Generic: Hi world
>>>

It seems like logbook does not support string format placeholders %s, %d, etc., while the stdlib logging does. It's this an intended behavior? If so, would it make sense to document this difference so people coming from logging could adjust their expectation?

@vmalloc
Copy link
Collaborator

vmalloc commented Jun 10, 2018

@JokerQyou Logbook uses new-style formatting:

logger.debug("Message is {}", "message")

The code you attached is using logging redirect, which is mostly an interoperability feature to make sure built-in logging logs will make their way into logbook. If you use Logbook, your own code should emit logs using logbook loggers and not logging ones...

@wsw70
Copy link

wsw70 commented Sep 15, 2018

@vmalloc I think the question was also about the available formatting attributes (?) If so I opened a similar issue (#276)

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

3 participants