From: Holger Levsen Date: Wed, 2 Nov 2011 10:59:07 +0000 (+0100) Subject: provide logging too X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=9f164462a1a9e52110368cdc08c848d81d467b9c;p=profitbricks%2Fjenkins-build-scripts.git provide logging too --- diff --git a/kernel_build.py b/kernel_build.py index b9b6eec..f94e027 100644 --- a/kernel_build.py +++ b/kernel_build.py @@ -43,6 +43,7 @@ env['PB_SUITE'] = os.environ.get('DISTRIBUTION') if os.environ.get('DISTRIBUTION') == 'production': env['PB_SUITE'] = 'production-proposed-updates' +# FIXME: move this into own logger Class logger = logging.getLogger(sys.argv[0]) logger.setLevel(logging.DEBUG) stream_handler = logging.StreamHandler() diff --git a/kernel_persistence.py b/kernel_persistence.py index b5542ae..3d72ade 100644 --- a/kernel_persistence.py +++ b/kernel_persistence.py @@ -7,6 +7,8 @@ from sqlalchemy.orm import sessionmaker from sqlalchemy import Table, Column, Integer, String, MetaData, Sequence from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm.exc import NoResultFound +import logging +from logging import Formatter CWD = os.environ.get('WORKSPACE') PERSISTENCE_FILE = os.path.join(CWD, '..', '.persistence') @@ -16,6 +18,15 @@ engine = create_engine('sqlite:///%s' %(PERSISTENCE_FILE)) Session = sessionmaker(bind=engine) Base.metadata.create_all(engine) +# FIXME: move this into own logger Class +logger = logging.getLogger(sys.argv[0]) +logger.setLevel(logging.DEBUG) +stream_handler = logging.StreamHandler() +stream_handler.setLevel(logging.DEBUG) +formatter = Formatter('%(asctime)s %(name)s[%(process)d] %(levelname)s: %(message)s') +stream_handler.setFormatter(formatter) +logger.addHandler(stream_handler) + class KernelVersion(Base): __tablename__ = 'branch_kernel_version' id = Column(Integer, Sequence('branch_id'), primary_key=True)