1
0
Fork 0

Forgot to initialize logger

This commit is contained in:
Casey 2022-11-01 13:04:31 +03:00
parent d861b2fe45
commit 1ec78d5f53
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
1 changed files with 11 additions and 1 deletions

View File

@ -1,7 +1,8 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from asyncio import run from asyncio import run
from configparser import ConfigParser, ExtendedInterpolation 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 import execute_integrations, load_integrations_from
from mastoposter.integrations import FilteredIntegration from mastoposter.integrations import FilteredIntegration
from mastoposter.sources import websocket_source from mastoposter.sources import websocket_source
@ -18,6 +19,14 @@ VERIFY_CREDS_TEMPLATE = "https://{instance}/api/v1/accounts/verify_credentials"
logger = getLogger() 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( async def listen(
source: Callable[..., AsyncGenerator[Status, None]], source: Callable[..., AsyncGenerator[Status, None]],
drains: List[FilteredIntegration], drains: List[FilteredIntegration],
@ -55,6 +64,7 @@ async def listen(
def main(config_path: str): def main(config_path: str):
init_logger()
conf = ConfigParser(interpolation=ExtendedInterpolation()) conf = ConfigParser(interpolation=ExtendedInterpolation())
conf.read(config_path) conf.read(config_path)