aiologger

raw JSON →
0.7.0 verified Fri May 01 auth: no python

Asynchronous logging library for Python and asyncio. Version 0.7.0. Supports Python >=3.7. Provides an async-compatible logger that integrates with the standard logging module. Release cadence is low; last release was in 2021.

pip install aiologger
error RuntimeError: Task <Task pending ...> got Future <Future pending ...> attached to a different loop
cause Creating a Logger before the event loop is running, or mixing loops across threads/contexts.
fix
Ensure all aiologger calls happen within the same event loop, typically the main thread's loop. Create the logger inside async context.
error TypeError: object dict can't be used in 'await' expression
cause Trying to use `logger.info` as a synchronous call without `await`.
fix
Add await: await logger.info(...)
gotcha Logger is a coroutine-based object; you must await all logging methods (info, error, etc.) or use asyncio.run. Not awaiting will produce warnings or silently skip logs.
fix Always use `await` when calling logger methods, or use `await logger.info(...)`.
gotcha Logger's handlers are not static; you must call `shutdown()` to flush and close handlers properly. Failure to do so may lose final log entries.
fix Always call `await logger.shutdown()` at the end of your async block.
deprecated The `aiologger.AsyncLogger` class is misdocumented; the correct logger is `aiologger.Logger`. Some older examples reference `AsyncLogger` which does not exist.
fix Use `from aiologger import Logger` instead.

Basic async logging with default handlers. Always call shutdown to flush and close handlers.

import asyncio
from aiologger import Logger

async def main():
    logger = Logger.with_default_handlers(name='my-app')
    await logger.info('Hello, world!')
    await logger.shutdown()

asyncio.run(main())