-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmylog.py
More file actions
50 lines (44 loc) · 955 Bytes
/
Copy pathmylog.py
File metadata and controls
50 lines (44 loc) · 955 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
# copyright Stephan Herschel - 2009-2011
import inspect
import logging
class MyLogging:
"""
logging mixin
"""
logging=True
def logstart(s):
"""
starten des logs
"""
debug=False
if debug:
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(levelname)s %(message)s',
filename='albumatix.log',
filemode='w')
else:
logging.basicConfig(level=logging.INFO,
format='%(levelname)s %(message)s',
filename='albumatix.log',
filemode='w')
def logdbg(s, pFrame):
"""
schreibt einen debug-logentry
pFrame ... inspect.currentframe()
"""
if s.logging:
logging.debug(str(s.__class__)+'.'+
inspect.getframeinfo(pFrame)[2]+
str(inspect.getargvalues(pFrame)[3]) )
def loginfo(s, pInf):
"""
schreibt einen info-logentry
"""
if s.logging:
logging.info(pInf)
def logerr(s, pInf):
"""
schreibt einen info-logentry
"""
if s.logging:
logging.error(pInf)