-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
PositionalArgumentsFormatter raises TypeError when postional argument is not a formatting tuple #258
Comments
Hi, |
Well, I'm a bit conflicted on this one. Sure What exactly is motivation to allow for bugs here? Just because it's logging? |
I do agree that is masking an error and potentially losing logs in production but, while migrating from Perhaps a optional flag similar to the logging.raiseExceptions could be used. |
But… isn’t that a feature that you’re finding those bugs now? You’re basically asking me to tape over an engine warning light. |
Wait a minute, i'm completely lost! log.info("hello, %s!", "world", key="value!", more_than_strings=[1, 2, 3]) although I do get exactly the same error, when I'm trying to use logger this way: logger = structlog.get_logger(__name__)
logger.error("Update ticker", ticker.name) logger.error("Update ticker", ticker.name)
File ".../site-packages/structlog/_native.py", line 136, in meth
return self._proxy_to_logger(name, event % args, **kw)
~~~~~~^~~~~~
TypeError: not all arguments converted during string formatting What is going on here? |
There's a |
When a structlog BouldLogger user incorrectly uses a postional argument that is not a formatting tuple, the PositionalArgumentsFormatter raises a TypeError.
The documentation states that this "must contain a tuple that is used for formatting".
What I want to point out is that this behavior is different than the stdlib when that method is misused. When the stdlib method is misused it catches the exception and prints a stacktrace, but it does not result in an uncaught exception.
e.g.
Results in:
PositionalArgumentsFormatter does result in an uncaught exception
e.g.
Results in:
Which is an uncaught error.
Ideally logging even when misused in this manner wouldn't cause Runtime errors.
The text was updated successfully, but these errors were encountered: