4.2.0r3
[enigma2.git] / usr / lib / enigma2 / python / Tools / LogConfig.py
1 LOG_TYPE_DEBUG = "D/ "
2 LOG_TYPE_INFO = "I/ "
3 LOG_TYPE_WARNING = "W/ "
4 LOG_TYPE_ERROR = "E/ "
5
6 LOG_LEVEL_ERROR = 0
7 LOG_LEVEL_WARNING = 1
8 LOG_LEVEL_INFO = 2
9 LOG_LEVEL_DEBUG = 3
10
11 class LogConfig(object):
12         _initialized = False
13
14         @staticmethod
15         def init():
16                 if LogConfig._initialized:
17                         return
18                 else:
19                         from Components.config import config, ConfigSubsection, ConfigOnOff, ConfigSelection
20                         config.log = ConfigSubsection()
21                         config.log.level = ConfigSelection(
22                                 choices={ str(LOG_LEVEL_DEBUG) : "DEBUG", str(LOG_LEVEL_INFO) : "INFO", str(LOG_LEVEL_WARNING) : "WARNING", str(LOG_LEVEL_ERROR) : "ERROR",  }, default=str(LOG_LEVEL_INFO))
23                         config.log.verbose = ConfigOnOff(default=False)
24                         config.log.colored = ConfigOnOff(default=True)
25                         LogConfig._initialized = True
26
27         @staticmethod
28         def level():
29                 from Components.config import config
30                 return int(config.log.level.value)
31
32         @staticmethod
33         def verbose():
34                 from Components.config import config
35                 return config.log.verbose.value
36
37         @staticmethod
38         def colored():
39                 from Components.config import config
40                 return config.log.colored.value