Fix logging
This commit is contained in:
parent
786a7b7b82
commit
972b5a60f1
29
dozo.py
29
dozo.py
|
@ -34,11 +34,18 @@ def _batch(debug):
|
||||||
plugins.run_batch()
|
plugins.run_batch()
|
||||||
|
|
||||||
|
|
||||||
def get_logger(level=logging.WARNING):
|
def get_logger(verbose, debug):
|
||||||
|
if debug:
|
||||||
|
level = logging.DEBUG
|
||||||
|
elif verbose:
|
||||||
|
level = logging.INFO
|
||||||
|
else:
|
||||||
|
level = logging.WARNING
|
||||||
|
|
||||||
logging.basicConfig(format='%(levelname)s:%(message)s', level=level)
|
logging.basicConfig(format='%(levelname)s:%(message)s', level=level)
|
||||||
logging.debug('This message should appear on the console')
|
logging.debug('This message should appear on the console')
|
||||||
logging.info('So should this')
|
logging.info('So should this')
|
||||||
logging.getLogger('asyncio').setLevel(logging.WARNING)
|
logging.getLogger('asyncio').setLevel(level)
|
||||||
logger = logging.getLogger('dozo')
|
logger = logging.getLogger('dozo')
|
||||||
logger.level = level
|
logger.level = level
|
||||||
return logger
|
return logger
|
||||||
|
@ -83,18 +90,11 @@ def _sort(debug, dry_run, destination, copy, exclude_regex, filter_by_ext, ignor
|
||||||
else:
|
else:
|
||||||
mode = 'move'
|
mode = 'move'
|
||||||
|
|
||||||
if debug:
|
logger = get_logger(verbose, debug)
|
||||||
constants.debug = logging.DEBUG
|
|
||||||
elif verbose:
|
|
||||||
constants.debug = logging.INFO
|
|
||||||
else:
|
|
||||||
constants.debug = logging.WARNING
|
|
||||||
|
|
||||||
if max_deep is not None:
|
if max_deep is not None:
|
||||||
max_deep = int(max_deep)
|
max_deep = int(max_deep)
|
||||||
|
|
||||||
logger = get_logger(constants.debug)
|
|
||||||
|
|
||||||
cache = True
|
cache = True
|
||||||
if reset_cache:
|
if reset_cache:
|
||||||
cache = False
|
cache = False
|
||||||
|
@ -221,18 +221,11 @@ def _compare(debug, dry_run, find_duplicates, output_dir, remove_duplicates,
|
||||||
revert_compare, similar_to, similarity, verbose, path):
|
revert_compare, similar_to, similarity, verbose, path):
|
||||||
'''Compare files in directories'''
|
'''Compare files in directories'''
|
||||||
|
|
||||||
logger = logging.getLogger('dozo')
|
logger = get_logger(verbose, debug)
|
||||||
if debug:
|
|
||||||
logger.setLevel(logging.DEBUG)
|
|
||||||
elif verbose:
|
|
||||||
logger.setLevel(logging.INFO)
|
|
||||||
else:
|
|
||||||
logger.setLevel(logging.ERROR)
|
|
||||||
|
|
||||||
# Initialize Db
|
# Initialize Db
|
||||||
db = Db(path)
|
db = Db(path)
|
||||||
|
|
||||||
logger = get_logger(constants.debug)
|
|
||||||
|
|
||||||
filesystem = FileSystem(mode='move', dry_run=dry_run, logger=logger)
|
filesystem = FileSystem(mode='move', dry_run=dry_run, logger=logger)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue