Commit 12345392 authored by Łukasz Nowak's avatar Łukasz Nowak

Start to use provided logging.

parent 7c4aa9b8
...@@ -32,11 +32,7 @@ import xml_marshaller ...@@ -32,11 +32,7 @@ import xml_marshaller
class SlapOSControler(object): class SlapOSControler(object):
def log(self, message): def __init__(self, config, log, process_group_pid_set=None):
print message
def __init__(self, config, process_group_pid_set=None, log=None):
if log is not None:
self.log = log self.log = log
self.config = config self.config = config
# By erasing everything, we make sure that we are able to "update" # By erasing everything, we make sure that we are able to "update"
......
...@@ -85,12 +85,7 @@ class Updater(object): ...@@ -85,12 +85,7 @@ class Updater(object):
realtime_output = True realtime_output = True
stdin = file(os.devnull) stdin = file(os.devnull)
def log(self, message): def __init__(self, repository_path, log, revision=None, git_binary=None):
print message
def __init__(self, repository_path, revision=None, git_binary=None,
log=None):
if log is not None:
self.log = log self.log = log
self.revision = revision self.revision = revision
self._path_list = [] self._path_list = []
......
...@@ -48,9 +48,8 @@ def main(*args): ...@@ -48,9 +48,8 @@ def main(*args):
parsed_argument = parser.parse_args(list(args)) parsed_argument = parser.parse_args(list(args))
else: else:
parsed_argument = parser.parse_args() parsed_argument = parser.parse_args()
logger = None
if parsed_argument.console or parsed_argument.logfile:
logger = logging.getLogger('erp5testnode') logger = logging.getLogger('erp5testnode')
if parsed_argument.console or parsed_argument.logfile:
logger.setLevel(logging.INFO) logger.setLevel(logging.INFO)
if parsed_argument.console: if parsed_argument.console:
logger.addHandler(logging.StreamHandler()) logger.addHandler(logging.StreamHandler())
...@@ -58,7 +57,8 @@ def main(*args): ...@@ -58,7 +57,8 @@ def main(*args):
if parsed_argument.logfile: if parsed_argument.logfile:
logger.addHandler(logging.FileHandler(filename=parsed_argument.logfile)) logger.addHandler(logging.FileHandler(filename=parsed_argument.logfile))
logger.info('Activated logfile %r output' % parsed_argument.logfile) logger.info('Activated logfile %r output' % parsed_argument.logfile)
if logger is not None: else:
logger.addHandler(logging.NullHandler())
CONFIG['logger'] = logger.info CONFIG['logger'] = logger.info
config = ConfigParser.SafeConfigParser() config = ConfigParser.SafeConfigParser()
# do not change case of option keys # do not change case of option keys
......
...@@ -46,10 +46,6 @@ class SubprocessError(EnvironmentError): ...@@ -46,10 +46,6 @@ class SubprocessError(EnvironmentError):
from Updater import Updater from Updater import Updater
def log(message):
# Log to stdout, with a timestamp.
print time.strftime('%Y/%m/%d %H:%M:%S'), message
supervisord_pid_file = None supervisord_pid_file = None
process_group_pid_set = set() process_group_pid_set = set()
def sigterm_handler(signal, frame): def sigterm_handler(signal, frame):
...@@ -100,6 +96,7 @@ def killPreviousRun(): ...@@ -100,6 +96,7 @@ def killPreviousRun():
PROFILE_PATH_KEY = 'profile_path' PROFILE_PATH_KEY = 'profile_path'
def run(config): def run(config):
log = config['logger']
slapgrid = None slapgrid = None
global supervisord_pid_file global supervisord_pid_file
supervisord_pid_file = os.path.join(config['instance_root'], 'var', 'run', supervisord_pid_file = os.path.join(config['instance_root'], 'var', 'run',
...@@ -225,7 +222,7 @@ branch = %(branch)s ...@@ -225,7 +222,7 @@ branch = %(branch)s
# revision # revision
log(' %s at %s' % (repository_path, revision)) log(' %s at %s' % (repository_path, revision))
updater = Updater(repository_path, git_binary=config['git_binary'], updater = Updater(repository_path, git_binary=config['git_binary'],
revision=revision) revision=revision, log=log)
updater.checkout() updater.checkout()
# Now prepare the installation of SlapOS and create instance # Now prepare the installation of SlapOS and create instance
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment