From 7e81d19aa3848d7422e613331391fe2adfe95ddf Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Thu, 25 Feb 2016 12:13:11 -0500 Subject: [PATCH] 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 --- cinder/cmd/api.py | 2 ++ cinder/cmd/backup.py | 2 ++ cinder/cmd/manage.py | 2 ++ cinder/cmd/scheduler.py | 2 ++ cinder/cmd/volume.py | 2 ++ 5 files changed, 10 insertions(+) diff --git a/cinder/cmd/api.py b/cinder/cmd/api.py index 9057883c566..7fe1cb56d5a 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 cc265e535fa..1fb8c1512a0 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 5c8ab2bcb84..0dec106f396 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 bea47e2b63e..9692fafe9f5 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 c9877aefedd..a20344c6de3 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()