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

Formatters do not work #5

Open
mbrancato opened this issue Jul 14, 2021 · 0 comments
Open

Formatters do not work #5

mbrancato opened this issue Jul 14, 2021 · 0 comments

Comments

@mbrancato
Copy link

The formatter support appears to not support messages and likely other attributes. Here is it not supporting the default formatter and using Python 3.9.5.

import asyncio
import logging
import aiologger


async def testaiolog():
    # The default formatter is '%(message)s'
    f = logging.Formatter()
    logger = aiologger.Logger.with_default_handlers(name="my-logger", formatter=f)
    await logger.info("foo")


asyncio.run(testaiolog())

Result is to stderr:

{"record": {"line_number": 10, "level": "INFO", "file_path": "aiologgertest.py", "function": "testaiolog", "msg": "foo"}, "logged_at": "2021-07-14T14:12:28.313405", "logger_exception": {"type": "<class 'AttributeError'>", "exc": "'LogRecord' object has no attribute 'getMessage'", "traceback": ["File \"/Users/mike/.pyenv/versions/global-3.9.5/lib/python3.9/site-packages/aiologger/handlers/streams.py\", line 80, in emit", "    msg = self.formatter.format(record) + self.terminator", "  File \"/Users/mike/.pyenv/versions/3.9.5/lib/python3.9/logging/__init__.py\", line 663, in format", "    record.message = record.getMessage()"]}}
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