fix logging

This commit is contained in:
Egg 2023-06-30 13:22:34 +02:00
parent 97e0566759
commit 32278bed15
8 changed files with 9 additions and 12 deletions

View file

@ -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):

View file

@ -7,7 +7,7 @@ import re
from report import Report
logger = logging.getLogger(__name__)
logger = logging.getLogger("main")
class MastodonBot(Bot):

View file

@ -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)

View file

@ -9,7 +9,7 @@ import report
from bot import Bot
logger = logging.getLogger(__name__)
logger = logging.getLogger("main")
class TwitterBot(Bot):

View file

@ -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):

2
db.py
View file

@ -7,7 +7,7 @@ import sqlite3
from time import sleep, time
logger = logging.getLogger(__name__)
logger = logging.getLogger("main")
class DB(object):

View file

@ -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=''):

View file

@ -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):