diff options
| author | Davanum Srinivas <davanum@gmail.com> | 2012-12-05 16:11:48 -0500 |
|---|---|---|
| committer | Davanum Srinivas <dims@linux.vnet.ibm.com> | 2012-12-06 07:38:39 -0500 |
| commit | 9b8128910787ac5f3e80ab81266d971ff20d1805 (patch) | |
| tree | 9afa0127aeb629fcf9bc7b50d170540637082bb9 /openstack/common | |
| parent | 255a27333092be0523949bd624c94b740515d018 (diff) | |
| download | oslo-9b8128910787ac5f3e80ab81266d971ff20d1805.tar.gz oslo-9b8128910787ac5f3e80ab81266d971ff20d1805.tar.xz oslo-9b8128910787ac5f3e80ab81266d971ff20d1805.zip | |
Allow nova and others to override some logging defaults
- In log.py, indicate that logging module allows tweaking
of just logging_context_format_string option
- In cfg.py, add a method that can alter the default given
the options and new default
- add testcases for log.set_defaults and cfg.set_defaults
Fixes LP #1083218
Change-Id: Iefdbce8505eb7a07f2b59d4ed7564b0146f1b0cd
Diffstat (limited to 'openstack/common')
| -rw-r--r-- | openstack/common/cfg.py | 7 | ||||
| -rw-r--r-- | openstack/common/log.py | 6 |
2 files changed, 13 insertions, 0 deletions
diff --git a/openstack/common/cfg.py b/openstack/common/cfg.py index 69f0de8..004b3e9 100644 --- a/openstack/common/cfg.py +++ b/openstack/common/cfg.py @@ -480,6 +480,13 @@ def _is_opt_registered(opts, opt): return False +def set_defaults(opts, **kwargs): + for opt in opts: + if opt.dest in kwargs: + opt.default = kwargs[opt.dest] + break + + class Opt(object): """Base class for all configuration options. diff --git a/openstack/common/log.py b/openstack/common/log.py index 8469fe8..707a10a 100644 --- a/openstack/common/log.py +++ b/openstack/common/log.py @@ -289,6 +289,12 @@ def setup(product_name): _setup_logging_from_conf(product_name) +def set_defaults(logging_context_format_string): + cfg.set_defaults(log_opts, + logging_context_format_string= + logging_context_format_string) + + def _find_facility_from_conf(): facility_names = logging.handlers.SysLogHandler.facility_names facility = getattr(logging.handlers.SysLogHandler, |
