The builtin python logger is IO blocking. This means that using the builting
logging
module will interfere with your asynchronouns application performance. aiologger
aims to be the standard Asynchronous non blocking logging for python and asyncio.
pip install aiologger
pip install -r requirements-dev.txt
py.test
The most basic use case is to log the output into stdout
and stderr
.
Using Logger.with_default_handlers
you're able to effortlessly create a new
Logger
instance with handlers for handling debug
and info
as stdout
and
warning
, critical
, exception
and error
as stderr
.
import asyncio
from aiologger import Logger
async def main():
logger = await Logger.with_default_handlers(name='my-logger')
await logger.debug("Hello stdout !")
await logger.info("Hello stdout !")
await logger.warning("Hello stderr !")
await logger.error("Hello stderr !")
await logger.critical("Hello stderr !")
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()