I have a flask server which responsible on several tasks. Each task represented by a route:
@app.route('/task_1')
def handle_task_one():
Since I don't control the clients I would really like to know in real-time which tasks Are getting called. Therefore I would like to create a logs monitor page.
I'm using simple logging:
formatter = logging.Formatter(fmt='%(asctime)s %(levelname)-8s %(message)s',datefmt='%Y-%m-%d %H:%M:%S')
handler = RotatingFileHandler('logs/server.log',
maxBytes=1000000, backupCount=1)
handler.setLevel(logging.INFO)
handler.setFormatter(formatter)
app.logger.setLevel(logging.INFO)
app.logger.addHandler(handler)
And log when every task is called.
I would like to know what is the best practice for this use-case(building a log page) My naive idea was to read the n first lines from the log file and return rendered page with this lines.
Aucun commentaire:
Enregistrer un commentaire