logging and rndc
This commit is contained in:
@ -1,25 +1,21 @@
|
||||
import syslog
|
||||
import sys
|
||||
|
||||
|
||||
class Logger(object):
|
||||
@staticmethod
|
||||
def log(data):
|
||||
syslog.syslog(syslog.LOG_INFO, data)
|
||||
if Logger.debugFlag:
|
||||
# print data
|
||||
sys.stderr.write(data)
|
||||
with open(Logger.filename, 'a') as f:
|
||||
f.write(data)
|
||||
|
||||
@staticmethod
|
||||
def debug(data):
|
||||
if Logger.debugFlag:
|
||||
syslog.syslog(syslog.LOG_DEBUG, data)
|
||||
# print data
|
||||
sys.stderr.write(data)
|
||||
with open(Logger.filename, 'a') as f:
|
||||
f.write(data)
|
||||
|
||||
@staticmethod
|
||||
def openlog():
|
||||
syslog.openlog('yadyn', syslog.LOG_PID, syslog.LOG_LOCAL0)
|
||||
def openlog(filename):
|
||||
Logger.filename = filename
|
||||
|
||||
@staticmethod
|
||||
def debugEnable():
|
||||
@ -30,4 +26,4 @@ class Logger(object):
|
||||
Logger.debugFlag = False
|
||||
|
||||
debugFlag = False
|
||||
|
||||
filename = '/tmp/yadyn.log'
|
||||
|
@ -48,6 +48,7 @@ PID_FILE = "/var/run/yadyn.pid"
|
||||
ENTRIES_FILE = "/opt/app/var/data/entries"
|
||||
CUSTOMERS_FILE = "/opt/app/var/data/customers"
|
||||
ACTIONLOG_DIR = "/opt/app/var/log/actionlog"
|
||||
LOG_FILE = "/opt/app/var/log/yadyn.log"
|
||||
ADMIN_PWD = 'test123'
|
||||
DNS_DUMMY = False
|
||||
DEBUG = True
|
||||
@ -69,7 +70,7 @@ if pid:
|
||||
|
||||
|
||||
|
||||
Logger.openlog()
|
||||
Logger.openlog(LOG_FILE)
|
||||
if DEBUG:
|
||||
Logger.debugEnable()
|
||||
|
||||
|
Reference in New Issue
Block a user