Capture warnings into logs

Modules that issue warnings via the python
warnings module result in messages printed
to stderr.

This change results in them being captured
into Cinder logs instead.  This means that
logs from production environments contain
all of the relevant info for debugging
issues.

Change-Id: I16a31e1ef0df824dd513f43fd22d631fa647e004
This commit is contained in:
Eric Harney 2016-02-25 12:13:11 -05:00
parent faba1e5f20
commit 7e81d19aa3
5 changed files with 10 additions and 0 deletions

View File

@ -20,6 +20,7 @@
import eventlet
eventlet.monkey_patch()
import logging as python_logging
import sys
from cinder import objects
@ -47,6 +48,7 @@ def main():
CONF(sys.argv[1:], project='cinder',
version=version.version_string())
logging.setup(CONF, "cinder")
python_logging.captureWarnings(True)
utils.monkey_patch()
gmr.TextGuruMeditation.setup_autorun(version)

View File

@ -17,6 +17,7 @@
"""Starter script for Cinder Volume Backup."""
import logging as python_logging
import sys
import eventlet
@ -45,6 +46,7 @@ def main():
CONF(sys.argv[1:], project='cinder',
version=version.version_string())
logging.setup(CONF, "cinder")
python_logging.captureWarnings(True)
utils.monkey_patch()
gmr.TextGuruMeditation.setup_autorun(version)
server = service.Service.create(binary='cinder-backup')

View File

@ -55,6 +55,7 @@
from __future__ import print_function
import logging as python_logging
import os
import sys
@ -554,6 +555,7 @@ def main():
CONF(sys.argv[1:], project='cinder',
version=version.version_string())
logging.setup(CONF, "cinder")
python_logging.captureWarnings(True)
except cfg.ConfigDirNotFoundError as details:
print(_("Invalid directory: %s") % details)
sys.exit(2)

View File

@ -20,6 +20,7 @@
import eventlet
eventlet.monkey_patch()
import logging as python_logging
import sys
from oslo_config import cfg
@ -45,6 +46,7 @@ def main():
CONF(sys.argv[1:], project='cinder',
version=version.version_string())
logging.setup(CONF, "cinder")
python_logging.captureWarnings(True)
utils.monkey_patch()
gmr.TextGuruMeditation.setup_autorun(version)
server = service.Service.create(binary='cinder-scheduler')

View File

@ -17,6 +17,7 @@
"""Starter script for Cinder Volume."""
import logging as python_logging
import os
import eventlet
@ -60,6 +61,7 @@ def main():
CONF(sys.argv[1:], project='cinder',
version=version.version_string())
logging.setup(CONF, "cinder")
python_logging.captureWarnings(True)
utils.monkey_patch()
gmr.TextGuruMeditation.setup_autorun(version)
launcher = service.get_launcher()