fix logging and configfile location on freebsd
This commit is contained in:
parent
3d6997b3be
commit
d1d9c3ca15
18
bin/zsnapper
18
bin/zsnapper
@ -288,7 +288,8 @@ def weed_snapshots(fslist, snapshots, config, failed_snapshots):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read('/etc/zsnapper.ini')
|
config.read('/usr/local/etc/zsnapper.ini', '/etc/zsnapper.ini')
|
||||||
|
|
||||||
ret = RET_CODES['SUCCESS']
|
ret = RET_CODES['SUCCESS']
|
||||||
log = logging.getLogger(LOGGER)
|
log = logging.getLogger(LOGGER)
|
||||||
|
|
||||||
@ -403,9 +404,22 @@ if __name__ == '__main__':
|
|||||||
handler.setLevel(logging.WARNING)
|
handler.setLevel(logging.WARNING)
|
||||||
log.addHandler(handler)
|
log.addHandler(handler)
|
||||||
|
|
||||||
handler = logging.handlers.SysLogHandler(address='/dev/log')
|
handler = None
|
||||||
|
for logsocket in ('/var/run/log', '/dev/log'):
|
||||||
|
try:
|
||||||
|
mode = os.stat(logsocket).st_mode
|
||||||
|
except FileNotFoundError:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if stat.S_ISSOCK(mode):
|
||||||
|
handler = logging.handlers.SysLogHandler(address=logsocket)
|
||||||
formatter = logging.Formatter(fmt='zsnapper[%(process)s] %(message)s')
|
formatter = logging.Formatter(fmt='zsnapper[%(process)s] %(message)s')
|
||||||
handler.setFormatter(formatter)
|
handler.setFormatter(formatter)
|
||||||
handler.setLevel(logging.INFO)
|
handler.setLevel(logging.INFO)
|
||||||
log.addHandler(handler)
|
log.addHandler(handler)
|
||||||
|
break
|
||||||
|
|
||||||
|
if not handler:
|
||||||
|
log.warning('No syslog socket found, will not log to syslog')
|
||||||
|
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
Loading…
Reference in New Issue
Block a user