]> arthur.barton.de Git - netdata.git/blobdiff - python.d/python_modules/msg.py
show what prevented logging
[netdata.git] / python.d / python_modules / msg.py
index c1421605d90ed2f94d38cdafb1b8810a3b3a3a72..e10819c28432b3fe53e739e438f233817fc606a5 100644 (file)
@@ -2,7 +2,7 @@
 # Description: logging for netdata python.d modules
 
 import sys
-from time import time
+from time import time, strftime
 
 DEBUG_FLAG = False
 PROGRAM = ""
@@ -24,7 +24,8 @@ def log_msg(msg_type, *args):
         LOG_COUNTER -= 1
     now = time()
     if LOG_COUNTER >= 0:
-        msg = "%s %s: %s" % (PROGRAM, str(msg_type), " ".join(args))
+        timestamp = strftime('%Y-%m-%d %X')
+        msg = "%s: %s %s: %s" % (timestamp, PROGRAM, str(msg_type), " ".join(args))
         WRITE(msg + "\n")
         FLUSH()
 
@@ -32,7 +33,8 @@ def log_msg(msg_type, *args):
     if NEXT_CHECK <= now:
         NEXT_CHECK = now - (now % LOG_INTERVAL) + LOG_INTERVAL
         if LOG_COUNTER < 0:
-            msg = "Prevented %s log messages from displaying" % str(0 - LOG_COUNTER)
+            timestamp = strftime('%Y-%m-%d %X')
+            msg = "%s: python.d.plugin: Prevented %s log messages from displaying" % (timestamp, str(0 - LOG_COUNTER))
             WRITE(msg + "\n")
             FLUSH()