From 890ad46210da1bf589d11f6b51ca61ca9d96276c Mon Sep 17 00:00:00 2001
From: davidh-ssec <david.hoese@ssec.wisc.edu>
Date: Tue, 5 Sep 2017 09:34:22 -0500
Subject: [PATCH] Fix hacky logging level addition

---
 aossceilo/ingest.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/aossceilo/ingest.py b/aossceilo/ingest.py
index 697b1d7..61a3e65 100755
--- a/aossceilo/ingest.py
+++ b/aossceilo/ingest.py
@@ -36,9 +36,14 @@ from datetime import datetime, timedelta
 
 import serial
 
-# FIXME: bad-joo-joo
-logging._levelNames[9] = 'TRACE'
-logging._levelNames['TRACE'] = 9
+# https://stackoverflow.com/a/13638084/433202
+TRACE_LEVEL_NUM = 9
+logging.addLevelName(TRACE_LEVEL_NUM, "TRACE")
+def debugv(self, message, *args, **kws):
+    # Yes, logger takes its '*args' as 'args'.
+    if self.isEnabledFor(TRACE_LEVEL_NUM):
+        self._log(TRACE_LEVEL_NUM, message, args, **kws)
+logging.Logger.debugv = debugv
 
 LOG = logging.getLogger(__name__)
 
-- 
GitLab