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

Start to use provided logging.

parent 7c4aa9b8
......@@ -32,12 +32,8 @@ import xml_marshaller
class SlapOSControler(object):
def log(self, message):
print message
def __init__(self, config, process_group_pid_set=None, log=None):
if log is not None:
self.log = log
def __init__(self, config, log, process_group_pid_set=None):
self.log = log
self.config = config
# By erasing everything, we make sure that we are able to "update"
# existing profiles. This is quite dirty way to do updates...
......
......@@ -85,13 +85,8 @@ class Updater(object):
realtime_output = True
stdin = file(os.devnull)
def log(self, message):
print message
def __init__(self, repository_path, revision=None, git_binary=None,
log=None):
if log is not None:
self.log = log
def __init__(self, repository_path, log, revision=None, git_binary=None):
self.log = log
self.revision = revision
self._path_list = []
self.repository_path = repository_path
......
......@@ -48,9 +48,8 @@ def main(*args):
parsed_argument = parser.parse_args(list(args))
else:
parsed_argument = parser.parse_args()
logger = None
logger = logging.getLogger('erp5testnode')
if parsed_argument.console or parsed_argument.logfile:
logger = logging.getLogger('erp5testnode')
logger.setLevel(logging.INFO)
if parsed_argument.console:
logger.addHandler(logging.StreamHandler())
......@@ -58,8 +57,9 @@ def main(*args):
if parsed_argument.logfile:
logger.addHandler(logging.FileHandler(filename=parsed_argument.logfile))
logger.info('Activated logfile %r output' % parsed_argument.logfile)
if logger is not None:
CONFIG['logger'] = logger.info
else:
logger.addHandler(logging.NullHandler())
CONFIG['logger'] = logger.info
config = ConfigParser.SafeConfigParser()
# do not change case of option keys
config.optionxform = str
......
......@@ -46,10 +46,6 @@ class SubprocessError(EnvironmentError):
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
process_group_pid_set = set()
def sigterm_handler(signal, frame):
......@@ -100,6 +96,7 @@ def killPreviousRun():
PROFILE_PATH_KEY = 'profile_path'
def run(config):
log = config['logger']
slapgrid = None
global supervisord_pid_file
supervisord_pid_file = os.path.join(config['instance_root'], 'var', 'run',
......@@ -225,7 +222,7 @@ branch = %(branch)s
# revision
log(' %s at %s' % (repository_path, revision))
updater = Updater(repository_path, git_binary=config['git_binary'],
revision=revision)
revision=revision, log=log)
updater.checkout()
# 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