Use oslo logging setup.

The one reason we kept our own version was because of the qpid
logging that is quite useful. But this is now easily done via
the "default_log_levels" option.

I have setup the api servers with:
 ampqlib,qpid.messaging,keystone,eventlet
and the engine with:
 ampqlib,qpid.messaging,keystone,eventlet,sqlalchemy

bug: 1143629
Change-Id: I04eeab469ab59da550e08188d53b2cfbb576c04d
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
Angus Salkeld 2013-03-04 17:00:47 +11:00
parent c538c6b6e4
commit f9f11a5bc3
5 changed files with 31 additions and 63 deletions

View File

@ -46,7 +46,12 @@ LOG = logging.getLogger('heat.api')
if __name__ == '__main__':
try:
cfg.CONF(project='heat', prog='heat-api')
config.setup_logging()
cfg.CONF.default_log_levels = ['amqplib=WARN',
'qpid.messaging=INFO',
'keystone=INFO',
'eventlet.wsgi.server=WARN',
]
logging.setup('heat')
app = config.load_paste_app()

View File

@ -48,7 +48,12 @@ LOG = logging.getLogger('heat.api.cfn')
if __name__ == '__main__':
try:
cfg.CONF(project='heat', prog='heat-api-cfn')
config.setup_logging()
cfg.CONF.default_log_levels = ['amqplib=WARN',
'qpid.messaging=INFO',
'keystone=INFO',
'eventlet.wsgi.server=WARN',
]
logging.setup('heat')
app = config.load_paste_app()

View File

@ -48,7 +48,12 @@ LOG = logging.getLogger('heat.api.cloudwatch')
if __name__ == '__main__':
try:
cfg.CONF(project='heat', prog='heat-api-cloudwatch')
config.setup_logging()
cfg.CONF.default_log_levels = ['amqplib=WARN',
'qpid.messaging=INFO',
'keystone=INFO',
'eventlet.wsgi.server=WARN',
]
logging.setup('heat')
app = config.load_paste_app()

View File

@ -27,7 +27,6 @@ eventlet.monkey_patch()
import os
import sys
# If ../heat/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
@ -47,13 +46,18 @@ from heat.common import config
from heat.db import api as db_api
logger = logging.getLogger('heat.engine')
LOG = logging.getLogger('heat.engine')
if __name__ == '__main__':
cfg.CONF(project='heat', prog='heat-engine')
config.setup_logging()
cfg.CONF.default_log_levels = ['amqplib=WARN',
'sqlalchemy=WARN',
'qpid.messaging=INFO',
'keystone=INFO',
'eventlet.wsgi.server=WARN',
]
logging.setup('heat')
from heat.engine import service as engine

View File

@ -18,16 +18,15 @@
Routines for configuring Heat
"""
import logging
import logging.config
import logging.handlers
import logging as sys_logging
import os
import sys
from eventlet.green import socket
from oslo.config import cfg
from heat.common import wsgi
from heat.openstack.common import log as logging
from heat.openstack.common import rpc
DEFAULT_PORT = 8000
@ -128,57 +127,6 @@ def register_engine_opts():
rpc.set_defaults(control_exchange='heat')
def setup_logging():
"""
Sets up the logging options for a log with supplied name
"""
if cfg.CONF.log_config:
# Use a logging configuration file for all settings...
if os.path.exists(cfg.CONF.log_config):
logging.config.fileConfig(cfg.CONF.log_config)
return
else:
raise RuntimeError("Unable to locate specified logging "
"config file: %s" % cfg.CONF.log_config)
root_logger = logging.root
if cfg.CONF.debug:
root_logger.setLevel(logging.DEBUG)
elif cfg.CONF.verbose:
root_logger.setLevel(logging.INFO)
else:
root_logger.setLevel(logging.WARNING)
# quiet down the qpid logging, without this qpid dumps raw hex stuff
# into our logs, which is generally too low-level to be useful to us
if cfg.CONF.rpc_backend.split('.')[-1] == 'impl_qpid':
root_logger.manager.getLogger('qpid.messaging').setLevel(logging.INFO)
formatter = logging.Formatter(cfg.CONF.log_format,
cfg.CONF.log_date_format)
if cfg.CONF.use_syslog:
try:
facility = getattr(logging.handlers.SysLogHandler,
cfg.CONF.syslog_log_facility)
except AttributeError:
raise ValueError(_("Invalid syslog facility"))
handler = logging.handlers.SysLogHandler(address='/dev/log',
facility=facility)
elif cfg.CONF.log_file:
logfile = cfg.CONF.log_file
if cfg.CONF.log_dir:
logfile = os.path.join(cfg.CONF.log_dir, logfile)
handler = logging.handlers.WatchedFileHandler(logfile)
else:
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(formatter)
root_logger.addHandler(handler)
def _register_paste_deploy_opts():
"""
Idempotent registration of paste_deploy option group
@ -244,7 +192,8 @@ def load_paste_app(app_name=None):
# Log the options used when starting if we're in debug mode...
if cfg.CONF.debug:
cfg.CONF.log_opt_values(logging.getLogger(app_name), logging.DEBUG)
cfg.CONF.log_opt_values(logging.getLogger(app_name),
sys_logging.DEBUG)
return app
except (LookupError, ImportError), e: