better loggings but i need to fix a duplicate log line error
This commit is contained in:
@@ -39,11 +39,11 @@ async def show_logs(update, context):
|
|||||||
return _log.log_warning(f'open_logs: user {chat_id} not allowed')
|
return _log.log_warning(f'open_logs: user {chat_id} not allowed')
|
||||||
|
|
||||||
await update.message.reply_text('Sto provando ad aprire i log...')
|
await update.message.reply_text('Sto provando ad aprire i log...')
|
||||||
_log.log_info(f'open_logs: {chat_id} trying opening logs...')
|
_log.log_debug(f'open_logs: {chat_id} trying opening logs...')
|
||||||
try:
|
try:
|
||||||
game_log= _os.path.expanduser(f'{_botsyms.BOT_PATH}/{_log.get_log_name()}')
|
game_log= _os.path.expanduser(f'{_log.get_log_name()}')
|
||||||
with open(game_log, 'r') as _log_file:
|
with open(game_log, 'r') as _log_file:
|
||||||
lines= _log_file.readlines()[-20:]
|
lines= _log_file.readlines()[-30:]
|
||||||
log_content= '\n'.join(lines)
|
log_content= '\n'.join(lines)
|
||||||
await update.message.reply_text(f"Contenuto del log:\n{log_content}")
|
await update.message.reply_text(f"Contenuto del log:\n{log_content}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -1,12 +1,19 @@
|
|||||||
|
import os as _os
|
||||||
from local_settings import TOKEN as _token
|
from local_settings import TOKEN as _token
|
||||||
from local_settings import BOT_PATH as _bot_path
|
from local_settings import BOT_PATH as _bot_path
|
||||||
|
from local_settings import LOG_PATH as _log_path
|
||||||
from local_settings import BOT_EXEC_CMD as _bot_exec_cmd
|
from local_settings import BOT_EXEC_CMD as _bot_exec_cmd
|
||||||
from local_settings import SUPER_USERS as _superusers
|
from local_settings import SUPER_USERS as _superusers
|
||||||
|
|
||||||
TOKEN= _token
|
TOKEN= _token
|
||||||
BOT_PATH= _bot_path
|
try: BOT_PATH= _os.path.expanduser(_bot_path)
|
||||||
BOT_EXEC_CMD= _bot_exec_cmd
|
except: BOT_PATH= ''
|
||||||
SUPER_USERS= _superusers
|
try: LOG_PATH= _os.path.expanduser(_log_path)
|
||||||
|
except: LOG_PATH= ''
|
||||||
|
try: BOT_EXEC_CMD= _bot_exec_cmd
|
||||||
|
except: BOT_EXEC_CMD= None
|
||||||
|
try: SUPER_USERS= _superusers
|
||||||
|
except: SUPER_USERS= []
|
||||||
|
|
||||||
START_MSG= """Benvenuto nel crudele mondo di Battle Royal Simulator,
|
START_MSG= """Benvenuto nel crudele mondo di Battle Royal Simulator,
|
||||||
La tua avventura e quella dei tuoi compagni inizia qui.
|
La tua avventura e quella dei tuoi compagni inizia qui.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import os as _os
|
import os as _os
|
||||||
import logging as _logging
|
import logging as _logging
|
||||||
from datetime import datetime as _dt
|
from datetime import datetime as _dt
|
||||||
|
from bot_libs import syms as _bot_syms
|
||||||
|
|
||||||
logger= _logging.getLogger(__name__)
|
logger= _logging.getLogger(__name__)
|
||||||
file_handler= None
|
file_handler= None
|
||||||
@@ -13,7 +14,8 @@ def get_log_name():
|
|||||||
day= now.day
|
day= now.day
|
||||||
if day < 10: day= f'0{day}'
|
if day < 10: day= f'0{day}'
|
||||||
fname= f'battle_royale-{now.year}{month}{day}.log'
|
fname= f'battle_royale-{now.year}{month}{day}.log'
|
||||||
return fname
|
|
||||||
|
return _os.path.join(_bot_syms.LOG_PATH, fname)
|
||||||
|
|
||||||
def _create_file_handler():
|
def _create_file_handler():
|
||||||
current_log_file = get_log_name()
|
current_log_file = get_log_name()
|
||||||
|
|||||||
Reference in New Issue
Block a user