mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Add the logger to the opts dict
This commit is contained in:
parent
5bcdcc2bd7
commit
bbe7228c8f
@ -43,6 +43,10 @@ def minion_config(path):
|
||||
else:
|
||||
opts['open_mode'] = False
|
||||
|
||||
opts['logger'] = master_logger(opts['log_file'],
|
||||
opts['log_level'],
|
||||
opts['out_level'])
|
||||
|
||||
opts['facter'] = facter_data()
|
||||
|
||||
return opts
|
||||
@ -88,8 +92,54 @@ def master_config(path):
|
||||
else:
|
||||
opts['auto_accept'] = False
|
||||
|
||||
opts['logger'] = master_logger(opts['log_file'],
|
||||
opts['log_level'],
|
||||
opts['out_level'])
|
||||
|
||||
return opts
|
||||
|
||||
def master_logger(log_file, log_level, console_level):
|
||||
'''
|
||||
Returns a logger fo use with a salt master
|
||||
'''
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
fh = logging.FileHandler(log_file)
|
||||
fh.setLevel(getattr(logging, log_level))
|
||||
|
||||
ch = logging.StreamHandler()
|
||||
ch.setLevel(getattr(logging, console_level))
|
||||
|
||||
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
||||
ch.setFormatter(formatter)
|
||||
fh.setFormatter(formatter)
|
||||
logger.addHandler(ch)
|
||||
logger.addHandler(fh)
|
||||
|
||||
return logger
|
||||
|
||||
def minion_logger(log_file, log_level, console_level):
|
||||
'''
|
||||
Returns a logger fo use with a salt minion
|
||||
'''
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
fh = logging.FileHandler(log_file)
|
||||
fh.setLevel(getattr(logging, log_level))
|
||||
|
||||
ch = logging.StreamHandler()
|
||||
ch.setLevel(getattr(logging, console_level))
|
||||
|
||||
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
||||
ch.setFormatter(formatter)
|
||||
fh.setFormatter(formatter)
|
||||
logger.addHandler(ch)
|
||||
logger.addHandler(fh)
|
||||
|
||||
return logger
|
||||
|
||||
def facter_data():
|
||||
'''
|
||||
Returns a dict of data about the minion allowing modules to differ
|
||||
|
@ -50,41 +50,4 @@ def check_root():
|
||||
+ 'http://xkcd.com/838/'
|
||||
sys.exit(1)
|
||||
|
||||
def master_logger():
|
||||
'''
|
||||
Returns a logger fo use with a salt master
|
||||
'''
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
fh = logging.FileHandler('test.log')
|
||||
fh.setLevel(logging.DEBUG)
|
||||
|
||||
ch = logging.StreamHandler()
|
||||
ch.setLevel(logging.ERROR)
|
||||
|
||||
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
||||
ch.setFormatter(formatter)
|
||||
fh.setFormatter(formatter)
|
||||
logger.addHandler(ch)
|
||||
logger.addHandler(fh)
|
||||
|
||||
def minion_logger():
|
||||
'''
|
||||
Returns a logger fo use with a salt minion
|
||||
'''
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
fh = logging.FileHandler('test.log')
|
||||
fh.setLevel(logging.DEBUG)
|
||||
|
||||
ch = logging.StreamHandler()
|
||||
ch.setLevel(logging.ERROR)
|
||||
|
||||
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
||||
ch.setFormatter(formatter)
|
||||
fh.setFormatter(formatter)
|
||||
logger.addHandler(ch)
|
||||
logger.addHandler(fh)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user