-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpdulog.py
More file actions
46 lines (31 loc) · 932 Bytes
/
pdulog.py
File metadata and controls
46 lines (31 loc) · 932 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
# module: pdulog.py
import logging
verbose = 0
debug = False
quiet = False
logging.basicConfig(filename='pdu-log.log',
filemode='a',
format='%(asctime)s,%(msecs)d %(levelname)s %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
level=logging.INFO)
logging.debug("===== Running PDU-Commander CLI =====")
logger = logging.getLogger('PDU-CLI')
def DebugOn():
logger.level = logging.DEBUG
debug = True
def Debg(_debg_msg):
logger.debug(_debg_msg)
if 2 <= verbose and not quiet:
print('DEBUG:', _debg_msg)
def Info(_info_msg):
logger.info(_info_msg)
if 1<= verbose and not quiet:
print('INFO:', _info_msg)
def Warn(_warn_msg):
logger.warning(_warn_msg)
if not quiet:
print('WARNING:', _warn_msg)
def Err(_err_msg):
logger.error(_err_msg)
if not quiet:
print('ERROR:', _err_msg)