-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLogging.py
executable file
·31 lines (26 loc) · 982 Bytes
/
Logging.py
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
import sys,os
import logging
import logging.config
import inspect
from configobj import ConfigObj
#mergeConfigFileName = "/opt/merger/dataFlowMerger.conf"
mergeConfigFileName = "/nfshome0/ceballos/merger/dataFlowMergerMini.conf"
try:
if os.path.isfile(mergeConfigFileName):
config = ConfigObj(mergeConfigFileName)
else:
print "Configuration file not found: {0}!".format(mergeConfigFileName)
sys.exit(1)
except IOError, e:
print "Unable to open configuration file: {0}!".format(mergeConfigFileName)
sys.exit(1)
loggingConfigFile = config['Misc']['logConfigFile']
logging.config.fileConfig(loggingConfigFile)
def getLogger():
frm = inspect.stack()[1]
mod = inspect.getfile(frm[0])
dotPosition = mod.rfind('.')
logging.getLogger("requests").setLevel(logging.WARNING)
logger = logging.getLogger('Merger.' + mod[mod.rfind('/')+1:dotPosition if dotPosition != -1 else len(mod)])
return logger
log = getLogger()