forked from netdata/netdata
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmsg.py
More file actions
51 lines (37 loc) · 818 Bytes
/
msg.py
File metadata and controls
51 lines (37 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -*- coding: utf-8 -*-
# Description: logging for netdata python.d modules
import sys
DEBUG_FLAG = False
PROGRAM = ""
def log_msg(msg_type, *args):
"""
Print message on stderr.
:param msg_type: str
"""
msg = "%s %s: %s" % (PROGRAM, str(msg_type), " ".join(args))
sys.stderr.write(msg + "\n")
sys.stderr.flush()
def debug(*args):
"""
Print debug message on stderr.
"""
if not DEBUG_FLAG:
return
log_msg("DEBUG", *args)
def error(*args):
"""
Print message on stderr.
"""
log_msg("ERROR", *args)
def info(*args):
"""
Print message on stderr.
"""
log_msg("INFO", *args)
def fatal(*args):
"""
Print message on stderr and exit.
"""
log_msg("FATAL", *args)
sys.stdout.write('DISABLE\n')
sys.exit(1)