π LoggingΒΆ
Raito ships a colored, adaptive log formatter so your terminal output is readable out of the box.
Enable itΒΆ
init_logging() installs the formatter on the root logger:
raito = Raito(dispatcher, "handlers", production=False)
raito.init_logging()
The level follows production: DEBUG in development, INFO in
production. Pass logger names to silence noisy third-party loggers:
raito.init_logging("aiogram.event", "aiogram.dispatcher")
Each name is dropped via a MuteLoggersFilter.
What you getΒΆ
Level-colored tags β
D / I / W / E / Con a colored background.Adaptive timestamps β
ColoredFormattershows more (date, logger name) on wide terminals and less on narrow ones, so lines donβt wrap.Warnings are captured into logging (
logging.captureWarnings(True)), soDeprecationWarningand friends appear in your logs too.
Logging from your codeΒΆ
The rt namespace exposes the root logger and a debug shortcut:
from raito import rt
rt.debug("Loaded %d items", count) # rt.log.debug
rt.log.info("Hello, %s", name)
rt.log.warning("Careful")
rt.log.error("Something failed")
Raitoβs own subsystems log under named loggers (raito.core,
raito.routers, raito.roles, raito.scenes, β¦), so you can tune or mute
any part independently.