Loggers
Cixo Develop editou esta página 1 semana atrás

Loggers

That library is sync and async ready. Generally have two simular classes, async_logger and sync_logger. All use same functions, but async_logger functions is of course async. For example:

# Sync logger
sync_logger.info("Info message")

# Async logger
await async_logger.info("Info message")

Levels of messages

That library have four levels of message:

  • info - Base level for normal messages.
  • warning - Next level for warnings.
  • error - Not critical error could be logged here.
  • critical - Last level for critical errors.

Use loggers to write messages

All levels have own functions, which could be used to write messages. When async_logger is used, then all of them must be used with await. If more parameters had been added to string, then it would be used to call format function on that string. It is useable for example to log IP address. Read more here.

logger.info("Info message")
logger.warning("Message with args {0}", 10)
logger.error("Error")
logger.critical("BUG!")

Creating loggers

Loggers could be create simple by call them