Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(567)

Issue 11437019: Add logging system to pub and sprinkle some logging in. (Closed)

Created:
8 years ago by Bob Nystrom
Modified:
8 years ago
Reviewers:
nweiz
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Add logging system to pub and sprinkle some logging in. We'll have to tune which things we log over time, but this covers most IO operations which is where almost all of our problems come from. This patch also means that going forward you should no longer call print() or printError() (which is gone) directly. Instead: print() -> log.message() printError() -> log.error() That ensures all messages will correctly get added to the log's transcript. Committed: https://code.google.com/p/dart/source/detail?r=15827

Patch Set 1 #

Patch Set 2 : print() -> log.message(). #

Total comments: 87

Patch Set 3 : Revised! #

Patch Set 4 : Update to latest. #

Patch Set 5 : Tweak logging. #

Patch Set 6 : Tweak logging. #

Patch Set 7 : Tweak output. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+500 lines, -100 lines) Patch
M pkg/http/lib/src/base_request.dart View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M pkg/http/test/request_test.dart View 1 chunk +7 lines, -0 lines 0 comments Download
M utils/pub/command_help.dart View 2 chunks +3 lines, -2 lines 0 comments Download
M utils/pub/command_install.dart View 2 chunks +2 lines, -1 line 0 comments Download
M utils/pub/command_lish.dart View 1 2 3 4 chunks +13 lines, -5 lines 0 comments Download
M utils/pub/command_update.dart View 2 chunks +2 lines, -1 line 0 comments Download
M utils/pub/curl_client.dart View 1 2 4 chunks +7 lines, -0 lines 0 comments Download
M utils/pub/entrypoint.dart View 1 2 3 5 chunks +9 lines, -2 lines 0 comments Download
M utils/pub/git.dart View 2 chunks +2 lines, -0 lines 0 comments Download
M utils/pub/hosted_source.dart View 2 chunks +2 lines, -1 line 0 comments Download
M utils/pub/io.dart View 1 2 3 29 chunks +113 lines, -33 lines 0 comments Download
A utils/pub/log.dart View 1 2 3 4 1 chunk +217 lines, -0 lines 0 comments Download
M utils/pub/oauth2.dart View 1 2 3 6 chunks +27 lines, -15 lines 0 comments Download
M utils/pub/pub.dart View 1 2 3 4 10 chunks +63 lines, -28 lines 0 comments Download
M utils/pub/system_cache.dart View 1 2 3 2 chunks +2 lines, -0 lines 0 comments Download
M utils/pub/validator.dart View 1 2 3 2 chunks +7 lines, -6 lines 0 comments Download
M utils/pub/version_solver.dart View 1 2 3 6 chunks +10 lines, -1 line 0 comments Download
M utils/tests/pub/pub_test.dart View 1 chunk +10 lines, -3 lines 0 comments Download
M utils/tests/pub/test_pub.dart View 1 2 3 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
Bob Nystrom
8 years ago (2012-12-05 21:24:47 UTC) #1
nweiz
https://codereview.chromium.org/11437019/diff/2001/pkg/http/lib/src/base_request.dart File pkg/http/lib/src/base_request.dart (right): https://codereview.chromium.org/11437019/diff/2001/pkg/http/lib/src/base_request.dart#newcode130 pkg/http/lib/src/base_request.dart:130: // TODO(rnystrom): Include headers? I don't think we want ...
8 years ago (2012-12-05 23:56:54 UTC) #2
Bob Nystrom
Thanks! https://codereview.chromium.org/11437019/diff/2001/pkg/http/lib/src/base_request.dart File pkg/http/lib/src/base_request.dart (right): https://codereview.chromium.org/11437019/diff/2001/pkg/http/lib/src/base_request.dart#newcode130 pkg/http/lib/src/base_request.dart:130: // TODO(rnystrom): Include headers? On 2012/12/05 23:56:54, nweiz ...
8 years ago (2012-12-06 01:33:26 UTC) #3
nweiz
lgtm https://codereview.chromium.org/11437019/diff/2001/utils/pub/io.dart File utils/pub/io.dart (right): https://codereview.chromium.org/11437019/diff/2001/utils/pub/io.dart#newcode133 utils/pub/io.dart:133: log.fine("Read $path. Contents:\n$contents"); On 2012/12/06 01:33:26, Bob Nystrom ...
8 years ago (2012-12-06 19:40:02 UTC) #4
Bob Nystrom
8 years ago (2012-12-07 21:13:44 UTC) #5
Message was sent while issue was closed.
Forgot to publish these comments yesterday...

https://codereview.chromium.org/11437019/diff/2001/utils/pub/io.dart
File utils/pub/io.dart (right):

https://codereview.chromium.org/11437019/diff/2001/utils/pub/io.dart#newcode133
utils/pub/io.dart:133: log.fine("Read $path. Contents:\n$contents");
On 2012/12/06 19:40:02, nweiz wrote:
> On 2012/12/06 01:33:26, Bob Nystrom wrote:
> > On 2012/12/05 23:56:54, nweiz wrote:
> > > log.io? Seems like almost every log call in this file should be log.io.
> > 
> > My initial thought was that file contents and process stdout would make the
> logs
> > very verbose so I put those in fine. But fine also has all of the important
> > program flow stuff now, so that's probably useless. I've played around with
a
> > few different sets of log levels. Maybe I should have separate "trace" and
> > "fine" ones.
> > 
> > For now, just made it io like you suggest.
> > 
> > > 
> > > It would be nice to indent the contents so it's visually distinct from the
> > rest
> > > of the output. Maybe prefix "| "? Same goes for writeTextFile.
> > 
> > Since the log entries are prefixed by their level, it works OK now, I think.
> You
> > get:
> > 
> > IO: Read file "foo" Contents:
> > foo
> > bar
> > blah
> > IO: The next log entry
> 
> I think
> 
> IO: Read file "foo" Contents:
> | foo
> | bar
> | blah
> IO: The next log entry
> 
> would be easier to read. Also, what if the file happens to contain "IO:" or
> another log-like prefix? That could get pretty confusing.

Done.

https://codereview.chromium.org/11437019/diff/2001/utils/pub/io.dart#newcode787
utils/pub/io.dart:787: Future withTempDir(Future fn(String path)) {
On 2012/12/06 19:40:02, nweiz wrote:
> On 2012/12/06 01:33:26, Bob Nystrom wrote:
> > On 2012/12/05 23:56:54, nweiz wrote:
> > > It would probably help with debugging if this and createTempDir() could
make
> > > directories with reasonable names, like the "mktemp" command on Linux.
> > 
> > Agreed, but dart:io doesn't support that. :(
> 
> File a bug?

Eh, I don't care that much about it.

https://codereview.chromium.org/11437019/diff/2001/utils/pub/io.dart#newcode950
utils/pub/io.dart:950: log.fine('Clean up 7zip temp directory
${tempDir.path}.');
On 2012/12/06 19:40:02, nweiz wrote:
> On 2012/12/06 01:33:26, Bob Nystrom wrote:
> > On 2012/12/05 23:56:54, nweiz wrote:
> > > It seems more useful to log that tempDir is the 7zip temp directory as
soon
> as
> > > it's created.
> > 
> > You should see:
> > 
> > Extracting .tar.gz stream to $destination.
> > 
> > and then the next thing after that will be creating the temp directory for
it.
> > 
> > > Then you can rely on the underlying logging for the rest of the
> > > operations.
> > 
> 
> In that case, this log line is probably redundant with the deleteDir logging.

I don't think so. Since this is async, the delete can happen much later than the
create, so it may no longer be obvious what the delete is for. This log is
synchronous with the later delete.

https://codereview.chromium.org/11437019/diff/2001/utils/pub/oauth2.dart
File utils/pub/oauth2.dart (right):

https://codereview.chromium.org/11437019/diff/2001/utils/pub/oauth2.dart#newc...
utils/pub/oauth2.dart:181: log.message(
On 2012/12/06 19:40:02, nweiz wrote:
> On 2012/12/06 01:33:26, Bob Nystrom wrote:
> > On 2012/12/05 23:56:54, nweiz wrote:
> > > Unlike print(), passing multiline strings to log.message isn't equivalent
to
> > > calling it multiple times.
> > 
> > It's equivalent in normal verbosity, I think. In verbose mode, it isn't, but
> in
> > that case I think this is actually better because it makes it clear it's a
> > single message from a single place in code.
> 
> There are other places where multiple lines get printed in multiple messages.
At
> least we should be consistent.
> 
> > I think this might actually be slightly preferred?
> 
> I think the other way looks nicer, but that's just me.

Per our discussion, this way is the new hotness since it will appear as a single
log entry. Syntactically, I kind of like the other way a bit more too, but
utility wins.

Powered by Google App Engine
This is Rietveld 408576698