2022-06-19 13:22:05 +01:00
|
|
|
from flask import current_app as app
|
|
|
|
|
2022-06-11 11:29:15 +01:00
|
|
|
from datetime import datetime
|
2022-06-19 13:22:05 +01:00
|
|
|
from pathlib import Path
|
2022-06-11 11:29:15 +01:00
|
|
|
|
|
|
|
def read(filename:str):
|
2022-06-19 13:22:05 +01:00
|
|
|
data = Path(app.config.get('DATA'))
|
2022-06-11 11:29:15 +01:00
|
|
|
with open(f'./{data}/logs/{filename}') as file:
|
|
|
|
return file.readlines()
|
|
|
|
|
|
|
|
def write(filename:str, message:str):
|
2022-06-19 13:22:05 +01:00
|
|
|
data = Path(app.config.get('DATA'))
|
2022-06-11 11:29:15 +01:00
|
|
|
with open(f'./{data}/logs/{filename}', 'a+') as file:
|
|
|
|
file.write(f'{datetime.now().strftime("%Y-%m-%d-%X")}: {message}\n')
|