Merge pull request #9 from gutenbergtools/logfile

fix logfile settings
gbnewby-patch-1
eshellman 2019-05-01 13:32:45 -04:00 committed by GitHub
commit 38e4d9a72f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 20 deletions

View File

@ -40,8 +40,11 @@ msdrive_client_id: '6902b111-a9d6-461f-bd8a-83dafee3da66'
msdrive_client_secret: 'add secret in .autocat3 or /etc/autocat3.conf files'
log.screen: False
log.error_file: CherryPyApp.install_dir + '/log/error.log'
log.access_file: CherryPyApp.install_dir + '/log/access.log'
log.error_file: ''
log.access_file: ''
logger.error_file: '/var/lib/autocat/log/error.log'
logger.access_file: '/var/lib/autocat/log/access.log'
log.rot_max_bytes: 104857600
log.rot_backup_count: 2
tools.log_headers.on: False

View File

@ -98,29 +98,29 @@ def main():
pass
# Rotating Logs
#
# read the log file locations from config file.
error_file = cherrypy.config.get('log.error_file', 'error.log')
access_file = cherrypy.config.get('log.error_file', 'access.log')
# turn off cp built-in logging
cherrypy.log.error_file = ""
cherrypy.log.access_file = ""
# CherryPy will already open log files if present in config
error_file = access_file = ''
# read the logger file locations from config file.
if not cherrypy.log.error_file:
error_file = cherrypy.config.get('logger.error_file', '')
if not cherrypy.log.access_file:
access_file = cherrypy.config.get('logger.access_file', '')
# set up python logging
max_bytes = getattr(cherrypy.log, "rot_max_bytes", 100 * 1024 * 1024)
backup_count = getattr(cherrypy.log, "rot_backup_count", 2)
h = logging.handlers.RotatingFileHandler(error_file, 'a', max_bytes, backup_count, 'utf-8')
h.setLevel(logging.INFO)
h.setFormatter(cherrypy._cplogging.logfmt)
cherrypy.log.error_log.addHandler(h)
if error_file:
h = logging.handlers.RotatingFileHandler(error_file, 'a', max_bytes, backup_count, 'utf-8')
h.setLevel(logging.INFO)
h.setFormatter(cherrypy._cplogging.logfmt)
cherrypy.log.error_log.addHandler(h)
h = logging.handlers.RotatingFileHandler(access_file, 'a', max_bytes, backup_count, 'utf-8')
h.setLevel(logging.INFO)
h.setFormatter(cherrypy._cplogging.logfmt)
cherrypy.log.access_log.addHandler(h)
if access_file:
h = logging.handlers.RotatingFileHandler(access_file, 'a', max_bytes, backup_count, 'utf-8')
h.setLevel(logging.INFO)
h.setFormatter(cherrypy._cplogging.logfmt)
cherrypy.log.access_log.addHandler(h)

View File

@ -5,9 +5,10 @@ After=network.target
[Service]
User=autocat
Type=simple
RuntimeDirectory=autocat
WorkingDirectory=/var/lib/autocat/autocat3
ExecStartPre=-/usr/bin/mkdir /var/run/autocat
ExecStart=/usr/local/bin/pipenv run python CherryPyApp.py
ExecStart=/var/lib/autocat/.local/bin/pipenv run python CherryPyApp.py
[Install]
WantedBy=multi-user.target