[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/4ydx/netdata/master/python.d/python_modules/msg.py [Back]  [Original]

# -*- coding: utf-8 -*-
# Description: logging for netdata python.d modules

import sys
from time import time, strftime

DEBUG_FLAG = False
PROGRAM = ""
LOG_COUNTER = 2
LOG_INTERVAL = 5
NEXT_CHECK = 0

WRITE = sys.stderr.write
FLUSH = sys.stderr.flush


def log_msg(msg_type, *args):
    """
    Print message on stderr.
    :param msg_type: str
    """
    global LOG_COUNTER
    if not DEBUG_FLAG:
        LOG_COUNTER -= 1
    now = time()
    if LOG_COUNTER >= 0:
        timestamp = strftime('%y-%m-%d %X')
        msg = "%s: %s %s: %s" % (timestamp, PROGRAM, str(msg_type), " ".join(args))
        WRITE(msg + "\n")
        FLUSH()

    global NEXT_CHECK
    if NEXT_CHECK 

Web Proxy Viewer  |  New URL  |  Original Page