Improve logger for windows
This commit is contained in:
parent
98181fe21c
commit
6d1a3ccdcc
|
@ -33,11 +33,10 @@ from flask_login import LoginManager
|
|||
from flask_babel import Babel
|
||||
from flask_principal import Principal
|
||||
|
||||
from . import logger, cache_buster, cli, config_sql, ub, db, services
|
||||
from . import config_sql, logger, cache_buster, cli, ub, db
|
||||
from .reverseproxy import ReverseProxied
|
||||
from .server import WebServer
|
||||
|
||||
|
||||
mimetypes.init()
|
||||
mimetypes.add_type('application/xhtml+xml', '.xhtml')
|
||||
mimetypes.add_type('application/epub+zip', '.epub')
|
||||
|
@ -62,7 +61,6 @@ lm = LoginManager()
|
|||
lm.login_view = 'web.login'
|
||||
lm.anonymous_user = ub.Anonymous
|
||||
|
||||
|
||||
ub.init_db(cli.settingspath)
|
||||
# pylint: disable=no-member
|
||||
config = config_sql.load_configuration(ub.session)
|
||||
|
@ -75,6 +73,7 @@ _BABEL_TRANSLATIONS = set()
|
|||
|
||||
log = logger.create()
|
||||
|
||||
from . import services
|
||||
|
||||
def create_app():
|
||||
app.wsgi_app = ReverseProxied(app.wsgi_app)
|
||||
|
|
|
@ -67,6 +67,8 @@ def get_level_name(level):
|
|||
|
||||
|
||||
def is_valid_logfile(file_path):
|
||||
if file_path == LOG_TO_STDERR or file_path == LOG_TO_STDOUT:
|
||||
return True
|
||||
if not file_path:
|
||||
return True
|
||||
if os.path.isdir(file_path):
|
||||
|
@ -105,7 +107,9 @@ def setup(log_file, log_level=None):
|
|||
# avoid spamming the log with debug messages from libraries
|
||||
r.setLevel(log_level)
|
||||
|
||||
log_file = _absolute_log_file(log_file, DEFAULT_LOG_FILE)
|
||||
# Otherwise name get's destroyed on windows
|
||||
if log_file != LOG_TO_STDERR and log_file != LOG_TO_STDOUT:
|
||||
log_file = _absolute_log_file(log_file, DEFAULT_LOG_FILE)
|
||||
|
||||
previous_handler = r.handlers[0] if r.handlers else None
|
||||
if previous_handler:
|
||||
|
@ -119,7 +123,7 @@ def setup(log_file, log_level=None):
|
|||
file_handler = StreamHandler(sys.stdout)
|
||||
file_handler.baseFilename = log_file
|
||||
else:
|
||||
file_handler = StreamHandler()
|
||||
file_handler = StreamHandler(sys.stderr)
|
||||
file_handler.baseFilename = log_file
|
||||
else:
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue
Block a user