forked from Cryz/battle_royale_sim
better log name
This commit is contained in:
@@ -43,7 +43,7 @@ async def show_logs(update, context):
|
||||
try:
|
||||
game_log= _os.path.expanduser(f'{_botsyms.BOT_PATH}/battle_royale.log')
|
||||
with open(game_log, 'r') as _log_file:
|
||||
lines= _log_file.readlines()[-10:]
|
||||
lines= _log_file.readlines()[-30:]
|
||||
log_content= '\n'.join(lines)
|
||||
await update.message.reply_text(f"Contenuto del log:\n{log_content}")
|
||||
except Exception as e:
|
||||
|
||||
@@ -1,7 +1,20 @@
|
||||
import logging as _logging
|
||||
from datetime import datetime as _dt
|
||||
|
||||
logger = _logging.getLogger(__name__)
|
||||
_logging.basicConfig(filename= 'battle_royale.log', encoding= 'utf-8', format='%(asctime)s - %(levelname)s - %(message)s', level= _logging.INFO)
|
||||
logger= _logging.getLogger(__name__)
|
||||
|
||||
def get_log_name():
|
||||
now= _dt.now()
|
||||
year= now.year
|
||||
month= now.month
|
||||
if month < 10: month= f'0{month}'
|
||||
day= now.day
|
||||
if day < 10: day= f'0{day}'
|
||||
#fname= f'battle_royale-{now.year}{month}{day}-{now.time()}.log'
|
||||
fname= f'battle_royale-{now.year}{month}{day}.log'
|
||||
return fname
|
||||
|
||||
_logging.basicConfig(filename= get_log_name(), encoding= 'utf-8', format='%(asctime)s - %(levelname)s - %(message)s', level= _logging.INFO)
|
||||
|
||||
def log_debug(txt):
|
||||
logger.debug(txt)
|
||||
|
||||
Reference in New Issue
Block a user