main: Create helper for logging boostraping
This commit is contained in:
parent
bdba83b1be
commit
51b778fcd6
@ -38,20 +38,9 @@ def main():
|
|||||||
if args.show_deps:
|
if args.show_deps:
|
||||||
commands.show_deps()
|
commands.show_deps()
|
||||||
|
|
||||||
# TODO: figure out a way to make the boilerplate in this file reusable in
|
bootstrap_logging(args)
|
||||||
# scanner and other places we need it.
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Initial config without extensions to bootstrap logging.
|
|
||||||
logging_initialized = False
|
|
||||||
logging_config, _ = config_lib.load(
|
|
||||||
args.config_files, [], args.config_overrides)
|
|
||||||
|
|
||||||
# TODO: setup_logging needs defaults in-case config values are None
|
|
||||||
log.setup_logging(
|
|
||||||
logging_config, args.verbosity_level, args.save_debug_log)
|
|
||||||
logging_initialized = True
|
|
||||||
|
|
||||||
create_file_structures()
|
create_file_structures()
|
||||||
check_old_locations()
|
check_old_locations()
|
||||||
|
|
||||||
@ -84,11 +73,20 @@ def main():
|
|||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
if logging_initialized:
|
logger.exception(ex)
|
||||||
logger.exception(ex)
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def bootstrap_logging(args):
|
||||||
|
# Initial config without extensions to bootstrap logging.
|
||||||
|
logging_config, _ = config_lib.load(
|
||||||
|
args.config_files, [], args.config_overrides)
|
||||||
|
|
||||||
|
# TODO: setup_logging needs defaults in-case config values are None
|
||||||
|
log.setup_logging(
|
||||||
|
logging_config, args.verbosity_level, args.save_debug_log)
|
||||||
|
|
||||||
|
|
||||||
def create_file_structures():
|
def create_file_structures():
|
||||||
path.get_or_create_dir(b'$XDG_DATA_DIR/mopidy')
|
path.get_or_create_dir(b'$XDG_DATA_DIR/mopidy')
|
||||||
path.get_or_create_file(b'$XDG_CONFIG_DIR/mopidy/mopidy.conf')
|
path.get_or_create_file(b'$XDG_CONFIG_DIR/mopidy/mopidy.conf')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user