From: Eric Harney Date: Thu, 25 Feb 2016 17:13:11 +0000 (-0500) Subject: Capture warnings into logs X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=7e81d19aa3848d7422e613331391fe2adfe95ddf;p=openstack-build%2Fcinder-build.git 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 --- diff --git a/cinder/cmd/api.py b/cinder/cmd/api.py index 9057883c5..7fe1cb56d 100644 --- a/cinder/cmd/api.py +++ b/cinder/cmd/api.py @@ -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) diff --git a/cinder/cmd/backup.py b/cinder/cmd/backup.py index cc265e535..1fb8c1512 100644 --- a/cinder/cmd/backup.py +++ b/cinder/cmd/backup.py @@ -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') diff --git a/cinder/cmd/manage.py b/cinder/cmd/manage.py index 5c8ab2bcb..0dec106f3 100644 --- a/cinder/cmd/manage.py +++ b/cinder/cmd/manage.py @@ -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) diff --git a/cinder/cmd/scheduler.py b/cinder/cmd/scheduler.py index bea47e2b6..9692fafe9 100644 --- a/cinder/cmd/scheduler.py +++ b/cinder/cmd/scheduler.py @@ -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') diff --git a/cinder/cmd/volume.py b/cinder/cmd/volume.py index c9877aefe..a20344c6d 100644 --- a/cinder/cmd/volume.py +++ b/cinder/cmd/volume.py @@ -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()