All handlers
Cixo Develop a editat această pagină 1 săptămână în urmă

All handlers

Of course logs could be write not only to stderr. Generally logger class sends content to all handlers which had been added to the logger by method use_handler(). Handlers is library in the logger is Set not list, that mean one handler instance could be added only one. All handlers are childs of the handler class. If You want, for example, write logs to database, just create own simple handler.

Avairable handlers:

  • stdout_handler - Write messages to STDOUT
  • stderr_handler - Write messages to STDERR
  • file_handler - Write messages to selecred file

stdout_handler, stderr_handler

It is super simple, it does not take any parameter.

logger.stdout_handler()
logger.stderr_handler()

file_handler

It take file used to write logs into when had been creating.

import pathlib

logger.file_handler(pathlib.Path("file.log"))

To create own handler just take a look at file_handler.py and handler.py