Add file logging support

This commit is contained in:
Joshua Boniface 2019-11-13 11:14:53 -05:00
parent 6751b41e6a
commit 487e18edf1
2 changed files with 23 additions and 0 deletions

View file

@ -40,10 +40,23 @@ import os
import sys
import yaml
import subprocess
from datetime import datetime
def debug(msg):
log_to_file = False
logfile = ""
try:
log_to_file = config['log_to_file']
logfile = config['logfile']
except:
pass
sys.stdout.write(str(msg) + '\n')
if log_to_file and logfile:
with open(logfile, 'a') as logfhd:
logfhd.write(str(datetime.now()) + ' ' + str(msg) + '\n')
###############################################################################
# Configuration parsing
###############################################################################
@ -70,6 +83,8 @@ try:
'state_tempdir': o_config['rffmpeg']['state']['tempdir'],
'state_filename': o_config['rffmpeg']['state']['filename'],
'state_contents': o_config['rffmpeg']['state']['contents'],
'log_to_file': o_config['rffmpeg']['logging']['file'],
'logfile': o_config['rffmpeg']['logging']['logfile'],
'remote_hosts': o_config['rffmpeg']['remote']['hosts'],
'remote_user': o_config['rffmpeg']['remote']['user'],
'remote_args': o_config['rffmpeg']['remote']['args'],

View file

@ -15,6 +15,14 @@ rffmpeg:
# Contents of the state instance file
contents: "{host}"
# Logging configuration
logging:
# Enable or disable file logging
file: true
# Log messages to this file - ensure the user running rffmpeg can write to it
logfile: "/var/log/jellyfin/rffmpeg.log"
# Remote (SSH) configuration
remote:
# A YAML list of remote hosts to connect to