Home > Net >  [aiofiles & asyncio dont write logs in file.txt
[aiofiles & asyncio dont write logs in file.txt

Time:07-09

The question is as to why it does not write certain logs to the file, errors are not shown. Bot for tg on aiogram.

logs.py:

import aiofiles
import asyncio

async def writelog(user_id: int, log: str):
    return 
    async with aiofiles.open('assets/recently.txt', mode='w') as f:
        await f.write(f'{user_id}:{log}\n')

async def readlogs():
    return ''
    async with aiofiles.open('assets/recently.txt', mode='r') as f:
        text = await f.read()
    return text

The code for writing a log to a file from script:

await writelog(message.from_user.id, 'turn off notifications           
  • Related