From 1ec78d5f53bdaa2fb07d3e2cc3cacb98d713495b Mon Sep 17 00:00:00 2001 From: hkc Date: Tue, 1 Nov 2022 13:04:31 +0300 Subject: [PATCH] Forgot to initialize logger --- mastoposter/__main__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mastoposter/__main__.py b/mastoposter/__main__.py index 083588d..4073ab0 100644 --- a/mastoposter/__main__.py +++ b/mastoposter/__main__.py @@ -1,7 +1,8 @@ #!/usr/bin/env python3 from asyncio import run from configparser import ConfigParser, ExtendedInterpolation -from logging import getLogger +from logging import DEBUG, Formatter, StreamHandler, getLogger +from sys import stdout from mastoposter import execute_integrations, load_integrations_from from mastoposter.integrations import FilteredIntegration from mastoposter.sources import websocket_source @@ -18,6 +19,14 @@ VERIFY_CREDS_TEMPLATE = "https://{instance}/api/v1/accounts/verify_credentials" logger = getLogger() +def init_logger(): + stdout_handler = StreamHandler(stdout) + stdout_handler.setLevel(DEBUG) + formatter = Formatter("[%(asctime)s][%(levelname)5s:%(name)s] %(message)s") + stdout_handler.setFormatter(formatter) + logger.addHandler(stdout_handler) + + async def listen( source: Callable[..., AsyncGenerator[Status, None]], drains: List[FilteredIntegration], @@ -55,6 +64,7 @@ async def listen( def main(config_path: str): + init_logger() conf = ConfigParser(interpolation=ExtendedInterpolation()) conf.read(config_path)