Commit ac058f3d6b49c0a72cc3f0026809c11527e3704c

Authored by hitier
1 parent db7f51f7

Absolute paths for logs_dir and logs_file

Showing 1 changed file with 6 additions and 3 deletions   Show diff stats
app/__init__.py
... ... @@ -70,6 +70,9 @@ def create_app(config_class=None):
70 70  
71 71 app.logger.removeHandler(default_handler)
72 72  
  73 + logs_dir = os.path.join(app_dir, 'logs')
  74 + logs_file = os.path.join(logs_dir, 'pdc.log')
  75 +
73 76 # Log to stdout
74 77 if app.debug or app.testing or app.config['LOG_TO_STDOUT']:
75 78 stream_handler = logging.StreamHandler()
... ... @@ -78,9 +81,9 @@ def create_app(config_class=None):
78 81 # or log to file
79 82 # TODO: get filename from config
80 83 else:
81   - if not os.path.exists('logs'):
82   - os.mkdir('logs')
83   - file_handler = RotatingFileHandler('logs/pdc.log')#, maxBytes=10240, backupCount=10)
  84 + if not os.path.exists(logs_dir):
  85 + os.mkdir(logs_dir)
  86 + file_handler = RotatingFileHandler(logs_file, maxBytes=10240, backupCount=10)
84 87 file_handler.setFormatter(logging.Formatter(
85 88 '%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'))
86 89 file_handler.setLevel(logging.INFO)
... ...