diff --git a/mozci/scripts/alltalos.py b/mozci/scripts/alltalos.py index 9b5222d..2f6158c 100755 --- a/mozci/scripts/alltalos.py +++ b/mozci/scripts/alltalos.py @@ -76,9 +76,9 @@ def main(): options = parse_args() if options.debug: - LOG = setup_logging(logging.DEBUG) + setup_logging(logging.DEBUG) else: - LOG = setup_logging(logging.INFO) + setup_logging() pgo = False if options.repo_name in PGO_ONLY_BRANCHES or options.pgo: diff --git a/mozci/scripts/generate_triggercli.py b/mozci/scripts/generate_triggercli.py index a4f0dc0..4553c34 100644 --- a/mozci/scripts/generate_triggercli.py +++ b/mozci/scripts/generate_triggercli.py @@ -30,6 +30,7 @@ 3) Remove the --dry-run parameter and actually trigger intermittents via trigger.py script. """ +import logging import os from argparse import ArgumentParser @@ -40,9 +41,12 @@ from mozci.utils.misc import setup_logging bugzilla = bugsy.Bugsy() +LOG = setup_logging() def main(): + global LOG + options = parse_args() bugs = [] assert options.bug_no or options.test_name, \ @@ -50,8 +54,6 @@ def main(): if options.debug: LOG = setup_logging(logging.DEBUG) - else: - LOG = setup_logging(logging.INFO) if options.bug_no: bugs.append(options.bug_no) diff --git a/mozci/scripts/misc/taskcluster_retrigger.py b/mozci/scripts/misc/taskcluster_retrigger.py index 01c3b87..594e2af 100644 --- a/mozci/scripts/misc/taskcluster_retrigger.py +++ b/mozci/scripts/misc/taskcluster_retrigger.py @@ -1,11 +1,9 @@ ''' taskcluster_retrigger.py allows you to retrigger a task from TaskCluster past its deadline. - -The API used is: - * createTask [1] - ''' +import logging + from argparse import ArgumentParser from mozci.scheduling import TaskclusterSchedulingClient @@ -33,9 +31,9 @@ def main(): options = parser.parse_args() if options.debug: - LOG = setup_logging(logging.DEBUG) + setup_logging(logging.DEBUG) else: - LOG = setup_logging(logging.INFO) + setup_logging() if options.retrigger: sch = TaskclusterSchedulingClient() diff --git a/mozci/sources/taskcluster_.py b/mozci/sources/taskcluster_.py index dfcee9f..b6ae40f 100644 --- a/mozci/sources/taskcluster_.py +++ b/mozci/sources/taskcluster_.py @@ -52,7 +52,7 @@ def retrigger_task(task_id, dry_run=False): LOG.debug("Contents of new task:") LOG.debug(task) if not dry_run: - LOG.info("Submitting new task with task_id: {}".format(new_task_id)) + LOG.info("Attempting to schedule new task with task_id: {}".format(new_task_id)) result = queue.createTask(new_task_id, task) LOG.debug(result) LOG.info("/{}/task-inspector/#{}/".format( diff --git a/mozci/utils/misc.py b/mozci/utils/misc.py index 419e44e..4e6e911 100644 --- a/mozci/utils/misc.py +++ b/mozci/utils/misc.py @@ -44,7 +44,7 @@ def _all_urls_reachable(urls): return True -def setup_logging(level): +def setup_logging(level=logging.INFO): """ Save every message (including debug ones) to ~/.mozilla/mozci/mozci-debug.log. @@ -54,17 +54,20 @@ def setup_logging(level): https://docs.python.org/2/howto/logging-cookbook.html#logging-to-multiple-destinations """ LOG = logging.getLogger('mozci') + + # Handler 1 - Store all debug messages in a specific file logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s:\t %(message)s', datefmt='%m/%d/%Y %I:%M:%S', filename=path_to_file('mozci-debug.log'), filemode='w') + # Handler 2 - Console output console = logging.StreamHandler() console.setLevel(level) # console does not use the same formatter specified in basicConfig # we have to set it again - formatter = logging.Formatter('%(asctime)s %(levelname)s:\t %(message)s', + formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s:\t %(message)s', datefmt='%m/%d/%Y %I:%M:%S') console.setFormatter(formatter) LOG.addHandler(console)