Add some basic logging capibilities
This commit is contained in:
parent
9289ec4006
commit
bde55d5870
1 changed files with 15 additions and 2 deletions
17
main.py
17
main.py
|
@ -2,6 +2,8 @@ import importlib
|
|||
from multiprocessing import Lock
|
||||
from multiprocessing.connection import wait
|
||||
import time
|
||||
import logging
|
||||
import sys
|
||||
|
||||
import toml
|
||||
import click
|
||||
|
@ -10,13 +12,22 @@ from chats.ChatProcess import LIFECYCLE_MESSAGES
|
|||
from server import WebsocketServerProcess
|
||||
from events import Event, Delete
|
||||
|
||||
logging.basicConfig(stream=sys.stdout)
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.argument('config_toml', type=click.File('r'), default='config.toml')
|
||||
def main(config_toml):
|
||||
@click.option('--silent', 'loglevel', flag_value=logging.NOTSET)
|
||||
@click.option('--quiet', 'loglevel', flag_value=logging.ERROR)
|
||||
@click.option('--log-level-info--this-is-default-dont-use-this', 'loglevel',
|
||||
flag_value=logging.INFO, default=True, hidden=True)
|
||||
@click.option('--debug', 'loglevel', flag_value=logging.DEBUG)
|
||||
def main(config_toml, loglevel):
|
||||
config = toml.load(config_toml)
|
||||
|
||||
stdin_lock = Lock()
|
||||
logger = logging.getLogger()
|
||||
|
||||
logger.setLevel(loglevel)
|
||||
|
||||
# Dynamically import chats
|
||||
chat_processes = {}
|
||||
|
@ -68,6 +79,7 @@ def main(config_toml):
|
|||
|
||||
for ready_pipe in ready_pipes:
|
||||
event = ready_pipe.recv()
|
||||
logger.info(f'Event recieved: {event}')
|
||||
|
||||
if isinstance(event, Event):
|
||||
for plugin in plugins.values():
|
||||
|
@ -91,5 +103,6 @@ def main(config_toml):
|
|||
if process.exitcode is None:
|
||||
process.terminate()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Add table
Reference in a new issue