Add log configuration
This commit is contained in:
parent
c87bf15146
commit
39c81ae7d1
@ -108,6 +108,21 @@ def get_level():
|
||||
|
||||
return _level
|
||||
|
||||
def set_file(outputfile):
|
||||
'''
|
||||
Set the file to output to, if enabled
|
||||
'''
|
||||
|
||||
global _outputfile
|
||||
_outputfile = outputfile
|
||||
|
||||
def get_file():
|
||||
'''
|
||||
Get the file to output to
|
||||
'''
|
||||
|
||||
return _outputfile
|
||||
|
||||
def raw(data):
|
||||
'''
|
||||
Outputs raw data to console without formatting
|
||||
|
@ -48,9 +48,19 @@ class Onionr:
|
||||
# Load global configuration data
|
||||
|
||||
exists = os.path.exists(config.get_config_file())
|
||||
config.set_config({'devmode': True}) # this is the default config, it will be overwritten if a config file already exists. Else, it saves it
|
||||
config.set_config({'devmode': True, 'log.file': True, 'log.console': True, 'log.outputfile': 'data/output.log', 'log.color': True}) # this is the default config, it will be overwritten if a config file already exists. Else, it saves it
|
||||
config.reload() # this will read the configuration file into memory
|
||||
|
||||
settings = 0b000
|
||||
if config.get('log.color', True):
|
||||
settings = settings | logger.USE_ANSI
|
||||
if config.get('log.console', True):
|
||||
settings = settings | logger.OUTPUT_TO_CONSOLE
|
||||
if config.get('log.file', False):
|
||||
settings = settings | logger.OUTPUT_TO_FILE
|
||||
logger.set_file(config.get('log.outputfile', 'data/output.log'))
|
||||
logger.set_settings(settings)
|
||||
|
||||
if config.get('devmode', True):
|
||||
self._developmentMode = True
|
||||
logger.set_level(logger.LEVEL_DEBUG)
|
||||
|
Loading…
Reference in New Issue
Block a user