From 32278bed155e272cd743e9bf83a4c1d8a0ee4d82 Mon Sep 17 00:00:00 2001 From: Egg Date: Fri, 30 Jun 2023 13:22:34 +0200 Subject: [PATCH] fix logging --- active_bots/mailbot.py | 2 +- active_bots/mastodonbot.py | 2 +- active_bots/telegrambot.py | 5 +---- active_bots/twitterbot.py | 2 +- backend.py | 4 ++-- db.py | 2 +- sendmail.py | 2 +- user.py | 2 +- 8 files changed, 9 insertions(+), 12 deletions(-) diff --git a/active_bots/mailbot.py b/active_bots/mailbot.py index b42bfef..334d25e 100644 --- a/active_bots/mailbot.py +++ b/active_bots/mailbot.py @@ -10,7 +10,7 @@ from bot import Bot from config import config from db import db -logger = logging.getLogger(__name__) +logger = logging.getLogger("main") class Mailbot(Bot): diff --git a/active_bots/mastodonbot.py b/active_bots/mastodonbot.py index d715906..34c9a48 100755 --- a/active_bots/mastodonbot.py +++ b/active_bots/mastodonbot.py @@ -7,7 +7,7 @@ import re from report import Report -logger = logging.getLogger(__name__) +logger = logging.getLogger("main") class MastodonBot(Bot): diff --git a/active_bots/telegrambot.py b/active_bots/telegrambot.py index 3bd3ac2..6e1573a 100644 --- a/active_bots/telegrambot.py +++ b/active_bots/telegrambot.py @@ -2,10 +2,8 @@ from bot import Bot import logging from report import Report from twx.botapi import TelegramBot as Telegram -from time import sleep - -logger = logging.getLogger(__name__) +logger = logging.getLogger("main") class TelegramBot(Bot): @@ -89,7 +87,6 @@ class TelegramBot(Bot): try: for subscriber_id in user.get_telegram_subscribers(): tb.send_message(subscriber_id, text).wait() - sleep(0.5) except Exception: logger.error('Error telegramming: ' + user.get_city() + ': ' + str(report.id), exc_info=True) diff --git a/active_bots/twitterbot.py b/active_bots/twitterbot.py index 4c53115..4d1e283 100755 --- a/active_bots/twitterbot.py +++ b/active_bots/twitterbot.py @@ -9,7 +9,7 @@ import report from bot import Bot -logger = logging.getLogger(__name__) +logger = logging.getLogger("main") class TwitterBot(Bot): diff --git a/backend.py b/backend.py index 6e36788..95a9d41 100755 --- a/backend.py +++ b/backend.py @@ -16,7 +16,7 @@ def shutdown(): if __name__ == '__main__': - logger = logging.getLogger() + logger = logging.getLogger("main") fh = logging.FileHandler('/var/log/ticketfrei/backend.log') fh.setLevel(logging.DEBUG) formatter = logging.Formatter('%(asctime)s %(levelname)8s: %(message)s') @@ -34,7 +34,7 @@ if __name__ == '__main__': while True: for user in db.active_users: for bot in bots: - sleep(5) + sleep(1) reports = bot.crawl(user) for status in reports: if not user.is_appropriate(status): diff --git a/db.py b/db.py index bbbc64f..853f16b 100644 --- a/db.py +++ b/db.py @@ -7,7 +7,7 @@ import sqlite3 from time import sleep, time -logger = logging.getLogger(__name__) +logger = logging.getLogger("main") class DB(object): diff --git a/sendmail.py b/sendmail.py index 3c6e9a6..b612a11 100755 --- a/sendmail.py +++ b/sendmail.py @@ -8,7 +8,7 @@ import smtplib from socket import getfqdn -logger = logging.getLogger(__name__) +logger = logging.getLogger("main") def sendmail(to, subject, city=None, body=''): diff --git a/user.py b/user.py index 74949ac..2cff416 100644 --- a/user.py +++ b/user.py @@ -7,7 +7,7 @@ from pylibscrypt import scrypt_mcf, scrypt_mcf_check from os import urandom import logging -logger = logging.getLogger(__name__) +logger = logging.getLogger("main") class User(object): def __init__(self, uid):