diff --git a/app/__init__.py b/app/__init__.py index b027ef7..f4b0d68 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -70,6 +70,9 @@ def create_app(config_class=None): app.logger.removeHandler(default_handler) + logs_dir = os.path.join(app_dir, 'logs') + logs_file = os.path.join(logs_dir, 'pdc.log') + # Log to stdout if app.debug or app.testing or app.config['LOG_TO_STDOUT']: stream_handler = logging.StreamHandler() @@ -78,9 +81,9 @@ def create_app(config_class=None): # or log to file # TODO: get filename from config else: - if not os.path.exists('logs'): - os.mkdir('logs') - file_handler = RotatingFileHandler('logs/pdc.log')#, maxBytes=10240, backupCount=10) + if not os.path.exists(logs_dir): + os.mkdir(logs_dir) + file_handler = RotatingFileHandler(logs_file, maxBytes=10240, backupCount=10) file_handler.setFormatter(logging.Formatter( '%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]')) file_handler.setLevel(logging.INFO) -- libgit2 0.21.2