sanic-org / sanic-ext

Extended Sanic functionality
https://sanic.dev/en/plugins/sanic-ext/getting-started.html
MIT License
50 stars 36 forks source link

Supporting custom logger in the background #179

Closed mymusise closed 1 year ago

mymusise commented 1 year ago

Hi, the background logger is an excellent extension helping me log all my messages from a background process, with multiple processes. But, it's not support to log any other logger backgrounding except "sanic.access", "sanic.error", "sanic.root".

This PR is an attempt to support logging other custom loggers in the background.

to use:

from sanic import Sanic

app = Sanic("MyApp")
app.config.LOGGING = True
app.config.LOGGERS = [
    "my_logger"
]

The default value of app.config.LOGGERS = ["sanic.access", "sanic.error", "sanic.root"], which is the same with (root_logger, access_logger, error_logger)