Logging for cron job does now work to syslog if defined so in the config file (previously it thought it should write to a file called 'syslog' instead of the real syslog)
This commit is contained in:
parent
dbb65bbf7f
commit
efe2187bb5
|
@ -24,14 +24,18 @@ import GnuPG
|
||||||
import MySQLdb
|
import MySQLdb
|
||||||
import smtplib
|
import smtplib
|
||||||
import markdown
|
import markdown
|
||||||
|
import syslog
|
||||||
from email.MIMEText import MIMEText
|
from email.MIMEText import MIMEText
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
|
|
||||||
def appendLog(msg):
|
def appendLog(msg):
|
||||||
if cfg.has_key('logging') and cfg['logging'].has_key('file'):
|
if 'logging' in cfg and 'file' in cfg['logging']:
|
||||||
log = open(cfg['logging']['file'], 'a')
|
if cfg['logging'].get('file') == "syslog":
|
||||||
log.write(msg + "\n")
|
syslog.syslog(syslog.LOG_INFO | syslog.LOG_MAIL, msg)
|
||||||
log.close()
|
else:
|
||||||
|
logfile = open(cfg['logging']['file'], 'a')
|
||||||
|
logfile.write(msg + "\n")
|
||||||
|
logfile.close()
|
||||||
|
|
||||||
def send_msg( mailsubject, messagefile, recipients = None ):
|
def send_msg( mailsubject, messagefile, recipients = None ):
|
||||||
mailbody = file( cfg['cron']['mail_templates'] + "/" + messagefile).read()
|
mailbody = file( cfg['cron']['mail_templates'] + "/" + messagefile).read()
|
||||||
|
|
Loading…
Reference in New Issue