Allow log statements to be printed out in stdout
This patch allows for log statements to be displayed in stdout.
Change-Id: Ib430dd51cad125a8d0a4a4d054d45ed9346ca9fb
“Fernando
8 years ago
|
0 |
# Copyright (c) 2015 IBM
|
|
1 |
# All Rights Reserved.
|
|
2 |
#
|
|
3 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
4 |
# not use this file except in compliance with the License. You may obtain
|
|
5 |
# a copy of the License at
|
|
6 |
#
|
|
7 |
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8 |
#
|
|
9 |
# Unless required by applicable law or agreed to in writing, software
|
|
10 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
11 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
12 |
# License for the specific language governing permissions and limitations
|
|
13 |
# under the License.
|
|
14 |
|
|
15 |
from oslo_config import cfg
|
|
16 |
from oslo_log import log
|
|
17 |
|
|
18 |
CONF = cfg.CONF
|
|
19 |
|
|
20 |
_DEFAULT_LOG_LEVELS = ['castellan=WARN']
|
|
21 |
|
|
22 |
_DEFAULT_LOGGING_CONTEXT_FORMAT = ('%(asctime)s.%(msecs)03d %(process)d '
|
|
23 |
'%(levelname)s %(name)s [%(request_id)s '
|
|
24 |
'%(user_identity)s] %(instance)s'
|
|
25 |
'%(message)s')
|
|
26 |
|
|
27 |
|
|
28 |
def configure_logging():
|
|
29 |
log.set_defaults(_DEFAULT_LOGGING_CONTEXT_FORMAT, _DEFAULT_LOG_LEVELS)
|
|
30 |
log.register_options(CONF)
|
12 | 12 |
# License for the specific language governing permissions and limitations
|
13 | 13 |
# under the License.
|
14 | 14 |
|
|
15 |
from castellan.common import config
|
|
16 |
|
15 | 17 |
from oslo_config import cfg
|
|
18 |
from oslo_log import log as logging
|
16 | 19 |
from oslo_utils import importutils
|
17 | 20 |
|
18 | 21 |
key_manager_opts = [
|
|
24 | 27 |
|
25 | 28 |
|
26 | 29 |
def API(configuration=None):
|
27 | |
conf = configuration or cfg.CONF
|
|
30 |
conf = configuration or config.CONF
|
28 | 31 |
conf.register_opts(key_manager_opts, group='key_manager')
|
|
32 |
|
|
33 |
config.configure_logging()
|
|
34 |
logging.setup(conf, "castellan")
|
29 | 35 |
|
30 | 36 |
cls = importutils.import_class(conf.key_manager.api_class)
|
31 | 37 |
return cls(configuration=conf)
|