robin2015
11/13/2019 - 9:13 AM

python loguru 用 logger.catch

# coding=utf-8

# loguru 扩展
from loguru import logger



def init_logger(logfilename):
    rotation_val = '100 MB'
    retention_val = '15 days'
    logger.add("logs/{}_debug.log".format(logfilename), rotation=rotation_val, retention=retention_val, level="DEBUG")
    logger.add("logs/{}_info.log".format(logfilename), rotation=rotation_val, retention=retention_val, level="INFO")
    logger.add("logs/{}_warning.log".format(logfilename), rotation=rotation_val, retention=retention_val,
               level="WARNING")
    logger.add("logs/{}_error.log".format(logfilename), rotation=rotation_val, retention=retention_val, level="ERROR")
from ycyj_kline.tools.log_ext import init_logger


def main():
    init_logger("ycyj_hangqing_app")
from flask import Flask
from loguru import logger
# import requests
# import sys
import os
import logging
import json
import urllib.request
# from datetime import datetime
from flask import request
from flask import make_response
import time
# from tornado.wsgi import WSGIContainer
# from tornado.httpserver import HTTPServer
# from tornado.ioloop import IOLoop

app = Flask(__name__)



@app.route('/')
@logger.catch
@runtime
def hello_world():
    # time.sleep(1)
    return 'Hello World!'