Rev4175, Console and file logging disable support
This commit is contained in:
parent
d610f94e7d
commit
7b9b48e62d
1 changed files with 20 additions and 9 deletions
|
@ -13,7 +13,7 @@ class Config(object):
|
|||
|
||||
def __init__(self, argv):
|
||||
self.version = "0.7.0"
|
||||
self.rev = 4172
|
||||
self.rev = 4175
|
||||
self.argv = argv
|
||||
self.action = None
|
||||
self.pending_changes = {}
|
||||
|
@ -204,7 +204,7 @@ class Config(object):
|
|||
# Config parameters
|
||||
self.parser.add_argument('--verbose', help='More detailed logging', action='store_true')
|
||||
self.parser.add_argument('--debug', help='Debug mode', action='store_true')
|
||||
self.parser.add_argument('--silent', help='Disable logging to terminal output', action='store_true')
|
||||
self.parser.add_argument('--silent', help='Only log errors to terminal output', action='store_true')
|
||||
self.parser.add_argument('--debug_socket', help='Debug socket connections', action='store_true')
|
||||
|
||||
self.parser.add_argument('--batch', help="Batch mode (No interactive input for commands)", action='store_true')
|
||||
|
@ -212,8 +212,10 @@ class Config(object):
|
|||
self.parser.add_argument('--config_file', help='Path of config file', default=config_file, metavar="path")
|
||||
self.parser.add_argument('--data_dir', help='Path of data directory', default=data_dir, metavar="path")
|
||||
|
||||
self.parser.add_argument('--console_log_level', help='Level of logging to console', default="default", choices=["default", "DEBUG", "INFO", "ERROR", "off"])
|
||||
|
||||
self.parser.add_argument('--log_dir', help='Path of logging directory', default=log_dir, metavar="path")
|
||||
self.parser.add_argument('--log_level', help='Level of logging to file', default="DEBUG", choices=["DEBUG", "INFO", "ERROR"])
|
||||
self.parser.add_argument('--log_level', help='Level of logging to file', default="DEBUG", choices=["DEBUG", "INFO", "ERROR", "off"])
|
||||
self.parser.add_argument('--log_rotate', help='Log rotate interval', default="daily", choices=["hourly", "daily", "weekly", "off"])
|
||||
self.parser.add_argument('--log_rotate_backup_count', help='Log rotate backup count', default=5, type=int)
|
||||
|
||||
|
@ -540,12 +542,15 @@ class Config(object):
|
|||
else:
|
||||
format = '%(name)s %(message)s'
|
||||
|
||||
if self.console_log_level == "default":
|
||||
if self.silent:
|
||||
level = logging.ERROR
|
||||
elif self.debug:
|
||||
level = logging.DEBUG
|
||||
else:
|
||||
level = logging.INFO
|
||||
else:
|
||||
level = logging.getLevelName(self.console_log_level)
|
||||
|
||||
console_logger = logging.StreamHandler()
|
||||
console_logger.setFormatter(logging.Formatter(format, "%H:%M:%S"))
|
||||
|
@ -574,7 +579,13 @@ class Config(object):
|
|||
logging.getLogger('').setLevel(logging.getLevelName(self.log_level))
|
||||
logging.getLogger('').addHandler(file_logger)
|
||||
|
||||
def initLogging(self, console_logging=True, file_logging=True):
|
||||
def initLogging(self, console_logging=None, file_logging=None):
|
||||
if console_logging == None:
|
||||
console_logging = self.console_log_level != "off"
|
||||
|
||||
if file_logging == None:
|
||||
file_logging = self.log_level != "off"
|
||||
|
||||
# Create necessary files and dirs
|
||||
if not os.path.isdir(self.log_dir):
|
||||
os.mkdir(self.log_dir)
|
||||
|
|
Loading…
Reference in a new issue