forked from synesissoftware/Diagnosticism.Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.py
More file actions
executable file
·45 lines (30 loc) · 986 Bytes
/
Copy pathlog.py
File metadata and controls
executable file
·45 lines (30 loc) · 986 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
#! /usr/bin/env python3
import diagnosticism as d
import diagnosticism.severity as sev
import os
ENV_VAR_NAME = 'DP_LOG_THRESHOLD'
FILTER_LEVEL = sev.INFO
d.enable_logging(('DIAGNOSTICISM_ENABLE_LOGGING', 'ENABLE_LOGGING'), True)
if ENV_VAR_NAME in os.environ:
try:
threshold = int(os.environ[ENV_VAR_NAME])
d.set_log_filter(threshold)
except ValueError:
d.abort("environment variable '%s' exists and has a value not convertible to `int`" % (ENV_VAR_NAME))
else:
d.set_log_filter(FILTER_LEVEL)
d.log(sev.BENCHMARK, 'benchmark')
d.log(sev.TRACE, 'trace')
d.log(sev.DEBUG5, 'debug5')
d.log(sev.DEBUG4, 'debug4')
d.log(sev.DEBUG3, 'debug3')
d.log(sev.DEBUG2, 'debug2')
d.log(sev.DEBUG1, 'debug1')
d.log(sev.DEBUG0, 'debug0')
d.log(sev.INFO, 'informational')
d.log(sev.NOTICE, 'notice')
d.log(sev.WARNING, 'warning')
d.log(sev.FAILURE, 'failure')
d.log(sev.CRITICAL, 'critical')
d.log(sev.ALERT, "alert")
d.log(sev.VIOLATION, "VIOLATION")