diff --git a/voussoirkit/vlogging.py b/voussoirkit/vlogging.py index c15f33f..e421902 100644 --- a/voussoirkit/vlogging.py +++ b/voussoirkit/vlogging.py @@ -38,6 +38,8 @@ root.setLevel(NOTSET) LOUD = 1 SILENT = 99999999999 +_did_earlybird = False + def add_loud(log): ''' Add the `loud` method to the given logger. @@ -89,7 +91,9 @@ def earlybird_config(): However, this might have the downside of making your program more difficult to debug because sys.argv is permanently altered. ''' + global _did_earlybird sys.argv = basic_config_by_argv(sys.argv) + _did_earlybird = True def get_level_by_argv(argv): ''' @@ -199,7 +203,12 @@ def main_decorator(main): betterhelp.HELPTEXT_EPILOGUES.add(BETTERHELP_EPILOGUE) @functools.wraps(main) def wrapped(argv, *args, **kwargs): - (level, argv) = get_level_by_argv(argv) - add_root_handler(level) + # The reason we don't call basic_config is that another module may have + # attached a root handler for another purpose. + # However we do check _did_earlybird so that we don't get double + # handlers from this module. + if not _did_earlybird: + (level, argv) = get_level_by_argv(argv) + add_root_handler(level) return main(argv, *args, **kwargs) return wrapped