Add oslo.log integration

This commit adds oslo.log integration to Deckhand.
This commit is contained in:
Felipe Monteiro 2017-07-05 20:59:09 +01:00
parent c4dbb82db0
commit 6a25e6f06b
8 changed files with 131 additions and 6 deletions

View File

@ -1,2 +1,4 @@
Alan Meadows <alan.meadows@gmail.com>
Felipe Monteiro <felipe.monteiro@att.com>
Felipe Monteiro <fmontei@users.noreply.github.com>
Scott Hussey <sh8121@att.com>

View File

@ -1,7 +1,8 @@
CHANGES
=======
* Implement core Deckhand API framework
* Add oslo.log integration to Deckhand.
* DECKHAND-2: Design core Deckhand API framework
* Oslo config integration (#1)
* Add ChangeLog
* Initial commit

View File

@ -8,6 +8,6 @@ To run::
$ sudo pip install uwsgi
$ virtualenv -p python3 /var/tmp/deckhand
$ . /var/tmp/deckhand/bin/activate
$ sudo pip install .
$ pip install .
$ python setup.py install
$ uwsgi --http :9000 -w deckhand.deckhand --callable deckhand --enable-threads -L

View File

@ -23,11 +23,25 @@ Barbican options for allowing Deckhand to communicate with Barbican.
barbican_opts = []
logging_group = cfg.OptGroup(
name='logging',
title='Logging Options',
help='Logging options for Deckhand.')
logging_opts = [
cfg.StrOpt('global_logger_name',
default='deckhand',
help='Logger name for the top-level logger.')
]
def register_opts(conf):
conf.register_group(barbican_group)
conf.register_opts(barbican_opts, group=barbican_group)
conf.register_group(logging_group)
conf.register_opts(logging_opts, group=logging_group)
def list_opts():
return {barbican_group: barbican_opts}
return {barbican_group: barbican_opts,
logging_group: logging_opts}

View File

@ -15,16 +15,46 @@
import os
import falcon
from oslo_config import cfg
from oslo_log import log as logging
from deckhand.conf import config
from deckhand.control import base as api_base
from deckhand.control import secrets
CONF = cfg.CONF
def __setup_logging():
LOGGER_NAME = CONF.logging.global_logger_name
LOG = logging.getLogger(__name__, LOGGER_NAME)
logging.register_options(CONF)
current_path = os.path.dirname(os.path.realpath(__file__))
root_path = os.path.abspath(os.path.join(current_path, os.pardir,
os.pardir))
logging_cfg_path = "%s/etc/deckhand/logging.conf" % root_path
# If logging conf is in place we need to set log_config_append. Only do so
# if the log path already exists.
if ((not hasattr(CONF, 'log_config_append') or
CONF.log_config_append is None) and
os.path.isfile(logging_cfg_path)):
CONF.log_config_append = logging_cfg_path
logging.setup(CONF, LOGGER_NAME)
LOG.debug('Initiated Deckhand logging.')
def start_api(state_manager=None):
"""Start the Deckhand API service.
"""Main entry point for initializing the Deckhand API service.
Create routes for the v1.0 API.
Create routes for the v1.0 API and sets up logging.
"""
config.register_opts(CONF)
__setup_logging()
control_api = falcon.API(request_type=api_base.DeckhandRequest)
v1_0_routes = [

35
etc/deckhand/logging.conf Normal file
View File

@ -0,0 +1,35 @@
[loggers]
keys=root
[handlers]
keys=file,devel,syslog
[formatters]
keys=simple,tests
[logger_root]
level=DEBUG
handlers=file
[handler_file]
class=FileHandler
level=DEBUG
args=('deckhand.log', 'w+')
formatter=tests
[handler_syslog]
class=handlers.SysLogHandler
level=ERROR
args = ('/dev/log', handlers.SysLogHandler.LOG_USER)
[handler_devel]
class=StreamHandler
level=DEBUG
args=(sys.stdout,)
formatter=simple
[formatter_tests]
class = oslo_log.formatters.ContextFormatter
[formatter_simple]
format=%(asctime)s.%(msecs)03d %(process)d %(levelname)s: %(message)s

View File

@ -0,0 +1,35 @@
[loggers]
keys=root
[handlers]
keys=file,devel,syslog
[formatters]
keys=simple,tests
[logger_root]
level=DEBUG
handlers=file
[handler_file]
class=FileHandler
level=DEBUG
args=('deckhand.log', 'w+')
formatter=tests
[handler_syslog]
class=handlers.SysLogHandler
level=ERROR
args = ('/dev/log', handlers.SysLogHandler.LOG_USER)
[handler_devel]
class=StreamHandler
level=DEBUG
args=(sys.stdout,)
formatter=simple
[formatter_tests]
class = oslo_log.formatters.ContextFormatter
[formatter_simple]
format=%(asctime)s.%(msecs)03d %(process)d %(levelname)s: %(message)s

View File

@ -1,6 +1,14 @@
falcon==1.1.0
pbr!=2.1.0,>=2.0.0 # Apache-2.0
six>=1.9.0 # MIT
stevedore>=1.20.0 # Apache-2.0
oslo.config>=3.22.0 # Apache-2.0
oslo.config>=3.22.0 # Apache-2.0
oslo.context>=2.14.0 # Apache-2.0
oslo.log>=3.22.0 # Apache-2.0
oslo.serialization>=1.10.0 # Apache-2.0
oslo.utils>=3.20.0 # Apache-2.0
oslo.i18n!=3.15.2,>=2.1.0 # Apache-2.0
python-barbicanclient>=4.0.0 # Apache-2.0
keystoneauth1>=2.21.0 # Apache-2.0