This is an automated email from the ASF dual-hosted git repository.

japetrsn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-package-kafka.git


The following commit(s) were added to refs/heads/master by this push:
     new 9d5ee62  Change some log levels and allow log level to be set on 
startup (#357)
9d5ee62 is described below

commit 9d5ee62b544423c067d5b5dd38ad6fe41cbcff4c
Author: James Dubee <[email protected]>
AuthorDate: Tue Nov 12 19:50:27 2019 -0500

    Change some log levels and allow log level to be set on startup (#357)
---
 provider/app.py      |  9 ++++++++-
 provider/consumer.py | 12 ++++++------
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/provider/app.py b/provider/app.py
index 1616cc3..0e1ee97 100644
--- a/provider/app.py
+++ b/provider/app.py
@@ -50,8 +50,15 @@ def healthRoute():
 
 
 def main():
+    logLevels = {
+        "info": logging.INFO,
+        "debug": logging.DEBUG,
+        "error": logging.ERROR,
+        "warning": logging.WARNING,
+        "critical": logging.CRITICAL
+    }
     logger = logging.getLogger()
-    logger.setLevel(logging.INFO)
+    logger.setLevel(logLevels.get(os.getenv('LOG_LEVEL', "info")))
 
     component = os.getenv('INSTANCE', 'messageHubTrigger-0')
 
diff --git a/provider/consumer.py b/provider/consumer.py
index 8742af3..0c0ee8e 100644
--- a/provider/consumer.py
+++ b/provider/consumer.py
@@ -500,13 +500,13 @@ class ConsumerProcess (Process):
             value.decode('utf-8')
         except UnicodeDecodeError:
             try:
-                logging.warn('[{}] Value is not UTF-8 encoded. Attempting 
encoding...'.format(self.trigger))
+                logging.debug('[{}] Value is not UTF-8 encoded. Attempting 
encoding...'.format(self.trigger))
                 value = value.encode('utf-8')
             except UnicodeDecodeError:
-                logging.warn('[{}] Value contains non-unicode bytes. Replacing 
invalid bytes.'.format(self.trigger))
+                logging.debug('[{}] Value contains non-unicode bytes. 
Replacing invalid bytes.'.format(self.trigger))
                 value = unicode(value, errors='replace').encode('utf-8')
         except AttributeError:
-            logging.warn('[{}] Cannot decode a NoneType message 
value'.format(self.trigger))
+            logging.debug('[{}] Cannot decode a NoneType message 
value'.format(self.trigger))
 
         return value
 
@@ -521,7 +521,7 @@ class ConsumerProcess (Process):
                 return parsed
             except ValueError as e:
                 # message is not a JSON object, return the message as a JSON 
value
-                logging.warn('[{}] I was asked to encode a message as JSON, 
but I failed with "{}".'.format(self.trigger, e))
+                logging.debug('[{}] I was asked to encode a message as JSON, 
but I failed with "{}".'.format(self.trigger, e))
                 value = "\"{}\"".format(value)
                 return value
         elif self.encodeValueAsBase64:
@@ -530,7 +530,7 @@ class ConsumerProcess (Process):
                 logging.debug('[{}] Successfully encoded a binary 
message.'.format(self.trigger))
                 return parsed
             except:
-                logging.warn('[{}] Unable to encode a binary 
message.'.format(self.trigger))
+                logging.debug('[{}] Unable to encode a binary 
message.'.format(self.trigger))
                 pass
 
         logging.debug('[{}] Returning un-encoded message'.format(self.trigger))
@@ -543,7 +543,7 @@ class ConsumerProcess (Process):
                 logging.debug('[{}] Successfully encoded a binary 
key.'.format(self.trigger))
                 return parsed
             except:
-                logging.warn('[{}] Unable to encode a binary 
key.'.format(self.trigger))
+                logging.debug('[{}] Unable to encode a binary 
key.'.format(self.trigger))
                 pass
 
         key = self.__getUTF8Encoding(key)

Reply via email to