Updated Openstack Common
Change-Id: If93d58783d42e336e98ae6407e241c2de1942f6d
This commit is contained in:
		@@ -26,7 +26,7 @@ Usual usage in an openstack.common module:
 | 
			
		||||
import gettext
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
t = gettext.translation('conductor', 'locale', fallback=True)
 | 
			
		||||
t = gettext.translation('openstack-common', 'locale', fallback=True)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def _(msg):
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,6 @@ It also allows setting of formatting information through conf.
 | 
			
		||||
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
import ConfigParser
 | 
			
		||||
import cStringIO
 | 
			
		||||
import inspect
 | 
			
		||||
import itertools
 | 
			
		||||
@@ -88,11 +87,11 @@ logging_cli_opts = [
 | 
			
		||||
               metavar='PATH',
 | 
			
		||||
               deprecated_name='logfile',
 | 
			
		||||
               help='(Optional) Name of log file to output to. '
 | 
			
		||||
                    'If no default is set, logging will go to stdout.'),
 | 
			
		||||
                    'If not set, logging will go to stdout.'),
 | 
			
		||||
    cfg.StrOpt('log-dir',
 | 
			
		||||
               deprecated_name='logdir',
 | 
			
		||||
               help='(Optional) The base directory used for relative '
 | 
			
		||||
                    '--log-file paths'),
 | 
			
		||||
               help='(Optional) The directory to keep log files in '
 | 
			
		||||
                    '(will be prepended to --log-file)'),
 | 
			
		||||
    cfg.BoolOpt('use-syslog',
 | 
			
		||||
                default=False,
 | 
			
		||||
                help='Use syslog for logging.'),
 | 
			
		||||
@@ -324,30 +323,10 @@ def _create_logging_excepthook(product_name):
 | 
			
		||||
    return logging_excepthook
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class LogConfigError(Exception):
 | 
			
		||||
 | 
			
		||||
    message = _('Error loading logging config %(log_config)s: %(err_msg)s')
 | 
			
		||||
 | 
			
		||||
    def __init__(self, log_config, err_msg):
 | 
			
		||||
        self.log_config = log_config
 | 
			
		||||
        self.err_msg = err_msg
 | 
			
		||||
 | 
			
		||||
    def __str__(self):
 | 
			
		||||
        return self.message % dict(log_config=self.log_config,
 | 
			
		||||
                                   err_msg=self.err_msg)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def _load_log_config(log_config):
 | 
			
		||||
    try:
 | 
			
		||||
        logging.config.fileConfig(log_config)
 | 
			
		||||
    except ConfigParser.Error, exc:
 | 
			
		||||
        raise LogConfigError(log_config, str(exc))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def setup(product_name):
 | 
			
		||||
    """Setup logging."""
 | 
			
		||||
    if CONF.log_config:
 | 
			
		||||
        _load_log_config(CONF.log_config)
 | 
			
		||||
        logging.config.fileConfig(CONF.log_config)
 | 
			
		||||
    else:
 | 
			
		||||
        _setup_logging_from_conf()
 | 
			
		||||
    sys.excepthook = _create_logging_excepthook(product_name)
 | 
			
		||||
 
 | 
			
		||||
@@ -30,6 +30,7 @@ LOG = logging.getLogger(__name__)
 | 
			
		||||
notifier_opts = [
 | 
			
		||||
    cfg.MultiStrOpt('notification_driver',
 | 
			
		||||
                    default=[],
 | 
			
		||||
                    deprecated_name='list_notifier_drivers',
 | 
			
		||||
                    help='Driver or drivers to handle sending notifications'),
 | 
			
		||||
    cfg.StrOpt('default_notification_level',
 | 
			
		||||
               default='INFO',
 | 
			
		||||
 
 | 
			
		||||
@@ -59,10 +59,10 @@ CONF.register_opts(socket_opts)
 | 
			
		||||
LOG = logging.getLogger(__name__)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def run_server(application, port, **kwargs):
 | 
			
		||||
def run_server(application, port):
 | 
			
		||||
    """Run a WSGI server with the given application."""
 | 
			
		||||
    sock = eventlet.listen(('0.0.0.0', port))
 | 
			
		||||
    eventlet.wsgi.server(sock, application, **kwargs)
 | 
			
		||||
    eventlet.wsgi.server(sock, application)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Service(service.Service):
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user