From a233ec91ff5ebe2de8928b49bb1dcb28caa15f99 Mon Sep 17 00:00:00 2001 From: Ben Steffensmeier Date: Fri, 6 Sep 2013 13:48:28 -0500 Subject: [PATCH] Issue #2336 Switch grib logging to use UFStatusHandler. Former-commit-id: 834f1dc0e758b6a64b0d4a58600f584c4fc95bb0 [formerly f4ea9726a589184e0f3212a99f6bf33f69a45e43] [formerly cbeca8c74f2988b65daa2955add02ca901235531] [formerly 834f1dc0e758b6a64b0d4a58600f584c4fc95bb0 [formerly f4ea9726a589184e0f3212a99f6bf33f69a45e43] [formerly cbeca8c74f2988b65daa2955add02ca901235531] [formerly 21726ccfb09b8d8e0a2aec6f6161544a9ff6bcd8 [formerly cbeca8c74f2988b65daa2955add02ca901235531 [formerly a509361f031c42a162cb04c6b88c41dc8f202cc6]]]] Former-commit-id: 21726ccfb09b8d8e0a2aec6f6161544a9ff6bcd8 Former-commit-id: 37b09127930931734d55115323af71cd5d8bba0b [formerly 57221d6f58f38351f20c56ae08221689080fd512] [formerly d90f59137fcc53b55885b48b0adf40b3ac5138dd [formerly a7b5d570a61af7f13175e15c37a81d2a53ced73c]] Former-commit-id: 04d3a406606a8aadf27b72248a35f10fc1fb4dc6 [formerly eb9bebe080ec20303cafe4aad950abdb9bd2b308] Former-commit-id: f2ddcef32903624a40aa8a45a0fa5c841369aca6 --- .../GribDecoder.py | 42 +++++++++++-------- .../META-INF/MANIFEST.MF | 25 +++++------ 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/GribDecoder.py b/edexOsgi/com.raytheon.edex.plugin.grib/GribDecoder.py index d5a0190ae4..12ab64a066 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/GribDecoder.py +++ b/edexOsgi/com.raytheon.edex.plugin.grib/GribDecoder.py @@ -22,7 +22,8 @@ import grib2 import numpy from math import pow import time, os, sys, math -import LogStream +import logging +import UFStatusHandler import tempfile from matplotlib.mlab import griddata @@ -122,14 +123,16 @@ THINNED_GRID_VALUES = THINNED_GRID_PT_MAP.values() # library to access the NCEP grib decoder for extracting data # # -# SOFTWARE HISTORY +# SOFTWARE HISTORY # -# Date Ticket# Engineer Description -# ------------ ---------- ----------- -------------------------- -# 04/7/09 #1994 bphillip Initial Creation. -# Mar 25, 2013 1821 bsteffen Reshape grib data arrays in -# place to improve performance. -# Sep 04, 2013 2298 rjpeter Removed setPluginName call +# Date Ticket# Engineer Description +# ------------- -------- ----------- -------------------------- +# Apr 07, 2009 1994 bphillip Initial Creation. +# Mar 25, 2013 1821 bsteffen Reshape grib data arrays in place to +# improve performance. +# Sep 04, 2013 2298 rjpeter Removed setPluginName call +# Sep 06, 2013 2336 bsteffen Switch from logstream to logging with +# UFStatusHandler. class GribDecoder(): ## @@ -141,7 +144,10 @@ class GribDecoder(): def __init__(self, text=None, filePath=None): # Assign public file name self.fileName = filePath - + + self.log = logging.getLogger("GribDecoder") + self.log.addHandler(UFStatusHandler.UFStatusHandler("com.raytheon.edex.plugin.grib", "EDEX")) + ## # Decodes the grib file @@ -166,7 +172,7 @@ class GribDecoder(): else: decodeFile = self.fileName if decodeFile == None: - LogStream.logProblem("Could not get final filename to decode: [", self.fileName, "]") + self.log.error("Could not get final filename to decode: [" + self.fileName + "]") return records gribFile = open(decodeFile, "rb") @@ -193,7 +199,7 @@ class GribDecoder(): recordIndex = recordIndex + 1 fieldIndex = 0 except: - LogStream.logProblem("Error processing file [", self.fileName, "]: ", LogStream.exc()) + self.log.exception("Error processing file [" + self.fileName + "]: ") finally: gribFile.close() @@ -526,7 +532,7 @@ class GribDecoder(): parameterAbbreviation = parameter.getAbbreviation() parameterUnit = parameter.getUnit() else: - LogStream.logEvent("No parameter information for center[" + str(centerID) + "], subcenter[" + + self.log.info("No parameter information for center[" + str(centerID) + "], subcenter[" + str(subcenterID) + "], tableName[" + tableName + "], parameter value[" + str(pdsTemplate[1]) + "]"); parameterName = MISSING @@ -543,7 +549,7 @@ class GribDecoder(): levelName = gribLevel.getAbbreviation(); levelUnit = gribLevel.getUnit() else: - LogStream.logEvent("No level information for center[" + str(centerID) + "], subcenter[" + + self.log.info("No level information for center[" + str(centerID) + "], subcenter[" + str(subcenterID) + "], tableName[" + LEVELS_TABLE + "], level value[" + str(pdsTemplate[9]) + "]"); @@ -1130,7 +1136,7 @@ class GribDecoder(): minorAxis = self._convertScaledValue(gdsTemplate[2], gdsTemplate[1]) majorAxis = minorAxis if majorAxis < 6000000.0 or minorAxis < 6000000.0: - LogStream.logEvent("Invalid earth shape majorAxis,minorAxis = " + str(majorAxis) + "," + str(minorAxis) + " defaulting to 6367470.0,6367470.0") + self.log.info("Invalid earth shape majorAxis,minorAxis = " + str(majorAxis) + "," + str(minorAxis) + " defaulting to 6367470.0,6367470.0") minorAxis = majorAxis = 6367470.0 # Earth assumed oblate spheriod with size as determined by IAU in 1965 @@ -1143,12 +1149,12 @@ class GribDecoder(): elif number == 3: minorAxis = self._convertScaledValue(gdsTemplate[4], gdsTemplate[3]) * 1000 if minorAxis < 6000000.0: - LogStream.logEvent("Invalid earth shape minorAxis = " + str(minorAxis) + " defaulting to " + MINOR_AXIS_DEFAULT) + self.log.info("Invalid earth shape minorAxis = " + str(minorAxis) + " defaulting to " + MINOR_AXIS_DEFAULT) minorAxis = MINOR_AXIS_DEFAULT majorAxis = self._convertScaledValue(gdsTemplate[6], gdsTemplate[5]) * 1000 if majorAxis < 6000000.0: - LogStream.logEvent("Invalid earth shape majorAxis = " + str(majorAxis) + " defaulting to " + MAJOR_AXIS_DEFAULT) + self.log.info("Invalid earth shape majorAxis = " + str(majorAxis) + " defaulting to " + MAJOR_AXIS_DEFAULT) majorAxis = MAJOR_AXIS_DEFAULT # Earth assumed oblate spheriod as defined in IAG-GRS80 model @@ -1171,12 +1177,12 @@ class GribDecoder(): elif number == 7: minorAxis = self._convertScaledValue(gdsTemplate[4], gdsTemplate[3]) if minorAxis < 6000000.0: - LogStream.logEvent("Invalid earth shape minorAxis = " + str(minorAxis) + " defaulting to " + MINOR_AXIS_DEFAULT) + self.log.info("Invalid earth shape minorAxis = " + str(minorAxis) + " defaulting to " + MINOR_AXIS_DEFAULT) minorAxis = MINOR_AXIS_DEFAULT majorAxis = self._convertScaledValue(gdsTemplate[6], gdsTemplate[5]) if majorAxis < 6000000.0: - LogStream.logEvent("Invalid earth shape majorAxis = " + str(majorAxis) + " defaulting to " + MAJOR_AXIS_DEFAULT) + self.log.info("Invalid earth shape majorAxis = " + str(majorAxis) + " defaulting to " + MAJOR_AXIS_DEFAULT) majorAxis = MAJOR_AXIS_DEFAULT # Earth model assumed spherical with radius 6,371,200 m, diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.edex.plugin.grib/META-INF/MANIFEST.MF index 42a8b0697d..8be16cf787 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.edex.plugin.grib/META-INF/MANIFEST.MF @@ -13,24 +13,19 @@ Require-Bundle: javax.measure, org.apache.commons.configuration, com.raytheon.uf.common.localization, com.raytheon.uf.common.serialization.comm, - com.raytheon.uf.edex.python.decoder;bundle-version="1.11.26", - com.raytheon.uf.edex.awipstools;bundle-version="1.12.1174", - com.raytheon.uf.common.awipstools;bundle-version="1.12.1174", - ucar.nc2;bundle-version="1.0.0", - com.raytheon.uf.common.dataplugin.level;bundle-version="1.12.1174", - com.raytheon.uf.common.dataplugin.grid;bundle-version="1.0.0", + com.raytheon.uf.common.status, + com.raytheon.uf.edex.python.decoder, + com.raytheon.uf.edex.awipstools, + com.raytheon.uf.common.awipstools, + ucar.nc2, + com.raytheon.uf.common.dataplugin.level, com.raytheon.uf.common.dataplugin.grid, - com.raytheon.uf.common.parameter;bundle-version="1.0.0" + com.raytheon.uf.common.dataplugin.grid, + com.raytheon.uf.common.parameter, + com.raytheon.uf.edex.plugin.grid, + com.raytheon.uf.common.dataplugin.grib Import-Package: com.raytheon.edex.exception, com.raytheon.uf.common.comm, - com.raytheon.uf.common.dataplugin.grib, - com.raytheon.uf.common.dataplugin.grib.request, - com.raytheon.uf.common.gridcoverage, - com.raytheon.uf.common.gridcoverage.exception, - com.raytheon.uf.common.gridcoverage.lookup, - com.raytheon.uf.common.gridcoverage.subgrid, - com.raytheon.uf.common.status, - com.raytheon.uf.edex.plugin.grid.dao, org.apache.camel, org.apache.commons.logging Export-Package: com.raytheon.edex.objects.hibernate.grib,