-
Notifications
You must be signed in to change notification settings - Fork 125
Use the logging package for dartdoc output #1518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f5a92cb
to
e921101
Compare
Explicitly not using |
https://github.com/dart-lang/logging/blob/master/lib/logging.dart#L158 Why is this not sufficient? |
… On Tue, Oct 17, 2017 at 7:38 AM, jcollins-g ***@***.***> wrote:
https://github.com/dart-lang/logging/blob/master/lib/logging.dart#L158
Why is this not sufficient?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1518 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABCioOySiFu3H_PiZGJNyekoYU6D92Vks5stLvIgaJpZM4P7Z5S>
.
|
I'll need more of an explanation than that. Why do you need to be able to log non-string-convertible objects? |
The idea: push the "text or JSON" decision to the listener. When a component logs it either sends a String and/or something JSON-able. |
@jcollins-g – thoughts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I see where you're going, but the implementation is problematic as you're basically recreating a lot of the logging module inside Dartdoc. I would prefer if you extended the logging package's class through inheritance and override its 'log' method with one more suited to your needs, or alter the logging package if you can do that in a reasonably compatible manner. Both of these options are better for our ecosystem and since this isn't an urgent issue I'd prefer that.
Another alternative is to make use of the logging module's existing support for passing closures and when you want to pass something in, wrap it in a closure that knows what to do based on dartdoc's command line flags -- convert to JSON or use ordinary string logging. This could be done with a lightweight wrapper around the logging module. I'm guessing this would be more complex than the other options when implemented though.
I'm not familiar enough with the logging module to know for sure which of those alternatives look best when implemented, but I'm pretty sure one of them will work out better in the long run.
bin/dartdoc.dart
Outdated
|
||
var readme = args['sdk-readme']; | ||
var readme = args['sdk-readme'] as String; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer: String readme = args['sdk-readme']; (or leave original)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
@@ -1,6 +1,6 @@ | |||
name: dartdoc | |||
# Also update the `version` field in lib/dartdoc.dart. | |||
version: 0.14.1 | |||
version: 0.14.2-dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add entry to changelog if you like but I prefer to avoid updating the version number for non-breaking changes until release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think this is poor CM practice but if it is standard for Dart package development, we can do this. A better way might be to put this in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see future -dev changes made in separate PRs to make reverts easier.
But if we're going to keep this one, the version number in lib/dartdoc.dart should also change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to do a rebase cleanup...if you have no other comments
I'd have to write more code to extends pkg/logging classes (both Logger and LogRecord). We'd also end up with a leaky abstraction, since I'd also have to introduce my own stream of events that's separate from The todo here is to make pkg/logging more extensible. In the mean time, I think this is the cleanest solution. |
@jcollins-g – further thoughts? |
I still don't think this is urgent enough to develop an entirely new logging module here even as a stopgap -- and I don't see it taking "more code" to extend the logging module to enable JSON logging. Whether you have a json object or not, the warnings will get transformed to a string and written out, which is what the existing logging module does. If json objects do not have a "toString()" that does that it's easy enough to add as an extension to logger. I see no reason to introduce a second stream of events or to reimplement Logger in its entirety. |
@jcollins-g – I understand logging a bit better now. Trying again – with the logging package. PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is much better, thanks! Only one question of note.
@@ -1,6 +1,6 @@ | |||
name: dartdoc | |||
# Also update the `version` field in lib/dartdoc.dart. | |||
version: 0.14.1 | |||
version: 0.14.2-dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think this is poor CM practice but if it is standard for Dart package development, we can do this. A better way might be to put this in a separate PR.
test/compare_output_test.dart
Outdated
@@ -145,7 +145,7 @@ void main() { | |||
final sep = '.'; // We don't care what the path separator character is | |||
final firstUnfoundExample = new RegExp('warning: lib${sep}example.dart: ' | |||
'@example file not found.*test_package${sep}dog${sep}food.md'); | |||
if (!result.stderr.contains(firstUnfoundExample)) { | |||
if (!result.stdout.contains(firstUnfoundExample)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know why this is now stdout? Warning prints should go to stderr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disagree! if dartdoc has a error/crash that should go to stderr
See https://www.jstorimer.com/blogs/workingwithcode/7766119-when-to-use-stderr-instead-of-stdout
stderr should be for diagnostics.
If I pipe the output from dartdoc to a file, I want the hints and the warnings all together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, this interpretation doesn't follow from the intended purpose of dartdoc, which is not to generate warnings, but documentation. Given that, the warnings are diagnostic information, and should remain on stderr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
logging.Logger.root.onRecord.listen((record) { | ||
if (record.level == progressLevel) { | ||
if (showProgress && stopwatch.elapsed.inMilliseconds > 250) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This definitely makes the progress ticker less annoying.
It helps one understand if the package is in a "work in progress" state. |
@jcollins-g PTAL |
Fixed travis oops – I think |
test/compare_output_test.dart
Outdated
@@ -145,7 +145,7 @@ void main() { | |||
final sep = '.'; // We don't care what the path separator character is | |||
final firstUnfoundExample = new RegExp('warning: lib${sep}example.dart: ' | |||
'@example file not found.*test_package${sep}dog${sep}food.md'); | |||
if (!result.stdout.contains(firstUnfoundExample)) { | |||
if (!result.stderr.contains(firstUnfoundExample)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jcollins-g – see here – that change got reverted...
19c7813
to
4404f47
Compare
Look okay, @jcollins-g ? |
No description provided.