Skip to content
Snippets Groups Projects
Commit 25ab40dd authored by Steven Murray's avatar Steven Murray
Browse files

cta/CTA#524 Added -l/--logfile option to cta-fst-gcd

parent ee44d99f
Branches
Tags
No related merge requests found
...@@ -100,10 +100,10 @@ class Gc: ...@@ -100,10 +100,10 @@ class Gc:
logging.config.dictConfig(config) logging.config.dictConfig(config)
def configurereallogging(self): def configurereallogging(self):
if None == self.logfilepath: if None == self.logfile:
raise Exception("Cannot configure file based logging because the log file path has not been set") raise Exception("Cannot configure file based logging because the log file path has not been set")
loggingdir = os.path.dirname(self.logfilepath) loggingdir = os.path.dirname(self.logfile)
if not os.path.isdir(loggingdir): if not os.path.isdir(loggingdir):
raise UserError("The logging directory {} is not a directory or does not exist".format(loggingdir)) raise UserError("The logging directory {} is not a directory or does not exist".format(loggingdir))
if not os.access(loggingdir, os.W_OK): if not os.access(loggingdir, os.W_OK):
...@@ -124,7 +124,7 @@ class Gc: ...@@ -124,7 +124,7 @@ class Gc:
'level': 'INFO', 'level': 'INFO',
'formatter': 'stdout', 'formatter': 'stdout',
'class': 'logging.handlers.TimedRotatingFileHandler', 'class': 'logging.handlers.TimedRotatingFileHandler',
'filename' : self.logfilepath, 'filename' : self.logfile,
'when' : 'midnight' 'when' : 'midnight'
} }
}, },
...@@ -142,16 +142,16 @@ class Gc: ...@@ -142,16 +142,16 @@ class Gc:
raise UserError(err) raise UserError(err)
def configurelogging(self): def configurelogging(self):
if None == self.logfilepath: if None == self.logfile:
self.configuredummylogging() self.configuredummylogging()
else: else:
self.configurereallogging() self.configurereallogging()
def __init__(self, env, logfilepath = '/var/log/eos/fst/cta-fst-gcd.log'): def __init__(self, env, logfile):
self.programname = 'cta-fst-gcd' self.programname = 'cta-fst-gcd'
self.env = env self.env = env
self.conffilepath = '/etc/cta/cta-fst-gcd.conf' self.conffilepath = '/etc/cta/cta-fst-gcd.conf'
self.logfilepath = logfilepath self.logfile = logfile
self.fqdn = socket.getfqdn() self.fqdn = socket.getfqdn()
self.localfilesystempaths = [] self.localfilesystempaths = []
self.nbfilesconsideredsincelastreport = 0 self.nbfilesconsideredsincelastreport = 0
...@@ -305,9 +305,10 @@ class Gc: ...@@ -305,9 +305,10 @@ class Gc:
def main(): def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("-l", "--logfile", default="/var/log/eos/fst/cta-fst-gcd.log", help="Log file path")
args = parser.parse_args() args = parser.parse_args()
gc = Gc(os.environ) gc = Gc(env=os.environ, logfile=args.logfile)
try: try:
gc.run() gc.run()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment