-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogConfig.py
50 lines (36 loc) · 1.36 KB
/
LogConfig.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
##
# @package LogConfig Module contains reads the logging configurations and stores in the variable
#
from os import listdir, path
import yaml
class LogConfig:
class __LogConfig:
def __init__( self ):
pass
## Dictionary conataining the configuration
config = {}
## Path where all Configuration file is stored
CONFIG_PATH = '/fw/DataLogger/config/logging.yaml'
## Function to read the configuration
#
def readConfiguration( self ):
with open( self.CONFIG_PATH, 'r' ) as f:
self.config = yaml.safe_load(f.read())
## Function to return the logging configuration
# @return config dictionary: Dictionary containing the logging configuration
#
def getConfig( self ):
return self.config
## Singleton instance of the private __LogConfig class
instance = None
def __init__( self ):
if not LogConfig.instance:
LogConfig.instance = LogConfig.__LogConfig()
try:
LogConfig.instance.readConfiguration()
except Exception as e:
print( "Error reading the logging configuration ",e)
# TODO: Figure out why it doesn't work without name argument
def __getattr__( self, name ):
return getattr( self.instance, name )