logging switched to loguru

This commit is contained in:
localhost_frssoft 2022-09-07 02:55:12 +03:00
parent 4d02fde9aa
commit 8e3253fd50
8 changed files with 14 additions and 21 deletions

View file

@ -13,5 +13,5 @@ max_fail_limit = 4 # Игнорировать предложения польз
hour_poll_posting = 16 # Час в который будет создан пост с голосовалкой (и завершение сбора)
fmn_next_watching_hour = 21 # Час начала киносеанса
logger_default_level = 10 # Уровень логгирования 10 - DEBUG, 20 - INFO, 30 - WARN
logger_default_level = 'DEBUG' # Уровень логгирования TRACE, DEBUG, INFO, SUCCESS, WARNING, ERROR, CRITICAL

View file

@ -1,12 +1,14 @@
from src import listener_context, listener_mention, imdb_datasets_worker
from config import logger_default_level
import logging
from loguru import logger
import time
import sys
def main():
logging.basicConfig(level=logger_default_level)
logger.remove()
logger.add(sink=sys.stderr, level=logger_default_level)
listener_mention.run_scan_notif() # Слушаем упоминания в фоне
time.sleep(1)

View file

@ -1,3 +1,4 @@
loguru
requests
python-dateutil

View file

@ -2,9 +2,7 @@ from config import instance
import time
import json
import requests
import logging
logger = logging.getLogger('fedi_api')
from loguru import logger
instance_point = f"https://{instance}/api/v1"

View file

@ -1,10 +1,8 @@
import sqlite3
import logging
from loguru import logger
from config import limit_movies_per_user
logger = logging.getLogger('fmn_db')
conn = sqlite3.connect("fmn.sqlite")
c = conn.cursor()

View file

@ -2,10 +2,9 @@ from src.fedi_api import get_status, post_status, upload_attachment
from src.fmn_states_db import add_state, get_state, clear_all_states
from src.fmn_database import get_movies_for_poll, write_votes, read_votes, mark_as_watched_movie, get_already_watched, rewrite_db, reset_poll
from collections import Counter
import logging
from loguru import logger
import time
logger = logging.getLogger('fmn_poll')
text_create_poll = '''Друзья, голосование за следующий Fediverse Movie Night объявляю открытым!

View file

@ -1,9 +1,7 @@
import sqlite3
import logging
from loguru import logger
logger = logging.getLogger('fmn_states_database')
conn = sqlite3.connect("fmn_states.sqlite", check_same_thread=False)
c = conn.cursor()
@ -23,7 +21,7 @@ def add_state(key, value):
def get_state(key):
'''Получение стейта по ключу'''
logger.debug(f'Запрошен стейт {key}')
logger.trace(f'Запрошен стейт {key}')
value = c.execute("SELECT value FROM states WHERE key = (?)", (key,)).fetchone()
if value:
return value[0]

View file

@ -5,16 +5,13 @@ from src.imdb_datasets_worker import get_title_by_id
from src.fmn_database import add_movie_to_poll, get_already_watched, get_suggested_movies_count
from src.fmn_states_db import get_state, add_state
from src.fmn_poll import create_poll_movies, get_winner_movie
import re
import time
from datetime import datetime
from dateutil.parser import parse as dateutilparse
from dateutil.relativedelta import relativedelta, TU
from collections import Counter
import re
import logging
logger = logging.getLogger('thread_listener')
from loguru import logger
def parse_links(text=str):
@ -149,7 +146,7 @@ def scan_context_thread():
add_result = add_movie_to_poll(acct, name, name_ru, year)
if add_result == 0:
message_writer.append(f"✅ Принято: {movie_string}")
logger.info(f'Предложение от {acct} принято: {name} {name_ru} {year}')
logger.success(f'Предложение от {acct} принято: {name} {name_ru} {year}')
success = True
elif add_result == 1:
message_writer.append("❌ Этот фильм уже был предложен")