powerlog: Don't hijack logger when import as module
BRANCH=master
TEST=No log spam when import as module from autotest
Commit-Ready: ChromeOS CL Exonerator Bot
@@ -848,12 +848,14 @@ def main(argv=None):
args = parser.parse_args(argv)
- root_logger = logging.getLogger()
+ root_logger = logging.getLogger(__name__)
if args.verbose:
root_logger.setLevel(logging.DEBUG)
else:
root_logger.setLevel(logging.INFO)
- # if powerlog is used through main log to sys.stdout
+
+ # if powerlog is used through main, log to sys.stdout
+ if __name__ == "__main__":
stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.setFormatter(logging.Formatter('%(levelname)s: %(message)s'))
root_logger.addHandler(stdout_handler)
