From patchwork Tue Sep 26 13:45:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D807: chg: show timestamp with debug messages From: phabricator X-Patchwork-Id: 24161 Message-Id: <080da3611a28cab9d937dfd6ed664217@localhost.localdomain> To: mercurial-devel@mercurial-scm.org Date: Tue, 26 Sep 2017 13:45:34 +0000 This revision was automatically updated to reflect the committed changes. Closed by commit rHGb94db1780365: chg: show timestamp with debug messages (authored by quark, committed by ). CHANGED PRIOR TO COMMIT https://phab.mercurial-scm.org/D807?vs=2069&id=2087#toc REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D807?vs=2069&id=2087 REVISION DETAIL https://phab.mercurial-scm.org/D807 AFFECTED FILES contrib/chg/util.c tests/test-chg.t CHANGE DETAILS To: quark, #hg-reviewers, indygreg, yuja Cc: yuja, mercurial-devel diff --git a/tests/test-chg.t b/tests/test-chg.t --- a/tests/test-chg.t +++ b/tests/test-chg.t @@ -48,7 +48,7 @@ $ touch foo $ CHGDEBUG= HGEDITOR=cat chg ci -Am channeled --edit 2>&1 \ > | egrep "HG:|run 'cat" - chg: debug: run 'cat "*"' at '$TESTTMP/editor' (glob) + chg: debug: * run 'cat "*"' at '$TESTTMP/editor' (glob) HG: Enter commit message. Lines beginning with 'HG:' are removed. HG: Leave message empty to abort commit. HG: -- @@ -165,16 +165,16 @@ warm up server: $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start' - chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) + chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) new server should be started if extension modified: $ sleep 1 $ touch dummyext.py $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start' - chg: debug: instruction: unlink $TESTTMP/extreload/chgsock/server-* (glob) - chg: debug: instruction: reconnect - chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) + chg: debug: * instruction: unlink $TESTTMP/extreload/chgsock/server-* (glob) + chg: debug: * instruction: reconnect (glob) + chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) old server will shut down, while new server should still be reachable: @@ -196,7 +196,7 @@ (this test makes sure that old server shut down automatically) $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start' - chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) + chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) shut down servers and restore environment: diff --git a/contrib/chg/util.c b/contrib/chg/util.c --- a/contrib/chg/util.c +++ b/contrib/chg/util.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -59,6 +60,13 @@ } static int debugmsgenabled = 0; +static double debugstart = 0; + +static double now() { + struct timeval t; + gettimeofday(&t, NULL); + return t.tv_usec / 1e6 + t.tv_sec; +} void enablecolor(void) { @@ -68,6 +76,7 @@ void enabledebugmsg(void) { debugmsgenabled = 1; + debugstart = now(); } void debugmsg(const char *fmt, ...) @@ -78,7 +87,7 @@ va_list args; va_start(args, fmt); fsetcolor(stderr, "1;30"); - fputs("chg: debug: ", stderr); + fprintf(stderr, "chg: debug: %4.6f ", now() - debugstart); vfprintf(stderr, fmt, args); fsetcolor(stderr, ""); fputc('\n', stderr);