[PATCH 2 of 6] blackbox: log the commands that are run
martin at geisler.net
Sun Feb 10 08:26:22 CST 2013
Durham Goode <durham at fb.com> writes:
> # HG changeset patch
> # User Durham Goode <durham at fb.com>
> # Date 1360429454 28800
> # Node ID 54a25c702a6fface978fd1eeb0e6c7140bc9ab8b
> # Parent 30544b5277d09002d6cac8c363652f71bb807516
> blackbox: log the commands that are run
> Uses ui.log to log which commands are run, their exit code, the time taken,
> and any unhandled exceptions thrown.
> Example log lines:
> 2013/02/09 08:35:19 durham> add foo
> 2013/02/09 08:35:19 durham> add exited 0 after 0.02 seconds
> Updates the progress tests because they use a mocked time.time() which these
> changes affect.
> diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
> --- a/mercurial/dispatch.py
> +++ b/mercurial/dispatch.py
> @@ -247,6 +247,7 @@
> (_("** Mercurial Distributed SCM (version %s)\n") % myver) +
> (_("** Extensions loaded: %s\n") %
> ", ".join([x for x in extensions.extensions()])))
> + ui.log("commandexception", "%s\n%s" % (warning, traceback.format_exc()))
The idea is nice and I think we should have such an extension.
The standard logging library works by taking the format string and the
arguments separately: that way you can check if the message will be
logged first and then only spend time formatting it if so. It would be
cool if we could change the signature of ui.log to that standard too.
More information about the Mercurial-devel