1 # -*- coding: utf-8 -*-
2 # Description: logging for netdata python.d modules
5 from time import time, strftime
13 WRITE = sys.stderr.write
14 FLUSH = sys.stderr.flush
17 def log_msg(msg_type, *args):
19 Print message on stderr.
27 timestamp = strftime('%y-%m-%d %X')
28 msg = "%s: %s %s: %s" % (timestamp, PROGRAM, str(msg_type), " ".join(args))
34 NEXT_CHECK = now - (now % LOG_INTERVAL) + LOG_INTERVAL
36 timestamp = strftime('%y-%m-%d %X')
37 msg = "%s: Prevented %s log messages from displaying" % (timestamp, str(0 - LOG_COUNTER))
44 Print debug message on stderr.
49 log_msg("DEBUG", *args)
54 Print message on stderr.
56 log_msg("ERROR", *args)
61 Print message on stderr.
63 log_msg("INFO", *args)
68 Print message on stderr and exit.
70 log_msg("FATAL", *args)
71 # using sys.stdout causes IOError: Broken Pipe
73 # sys.stdout.write('DISABLE\n')