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

Issue 1519673002: Add helpers for logging mojom objects. (Closed)

Created:
5 years ago by jeffbrown
Modified:
5 years ago
CC:
mojo-reviews_chromium.org, gregsimon, qsr+mojo_chromium.org, viettrungluu+watch_chromium.org, abarth-chromium, Aaron Boodman, darin (slow to review), ben+mojo_chromium.org
Base URL:
git@github.com:domokit/mojo.git@master
Target Ref:
refs/heads/master
Project:
mojo
Visibility:
Public.

Description

Add output formatters for more mojom types. Add output formatters for printing the contents of Mojo arrays, maps, and structs. These are very useful for writing debug logs. Committed: https://chromium.googlesource.com/external/mojo/+/7a6f49a41fb7f7616397a497e072b09373617c79

Patch Set 1 #

Total comments: 5

Patch Set 2 : move output formatters where they belong #

Patch Set 3 : rebase #

Unified diffs Side-by-side diffs Delta from patch set Stats (+156 lines, -5 lines) Patch
M mojo/public/cpp/bindings/array.h View 1 2 chunks +22 lines, -0 lines 0 comments Download
M mojo/public/cpp/bindings/map.h View 1 2 chunks +21 lines, -0 lines 0 comments Download
M mojo/public/cpp/bindings/string.h View 1 2 chunks +3 lines, -0 lines 0 comments Download
M mojo/public/cpp/bindings/struct_ptr.h View 1 3 chunks +18 lines, -1 line 0 comments Download
M mojo/public/cpp/bindings/tests/array_unittest.cc View 1 2 1 chunk +24 lines, -0 lines 0 comments Download
M mojo/public/cpp/bindings/tests/map_unittest.cc View 1 2 chunks +28 lines, -4 lines 0 comments Download
M mojo/public/cpp/bindings/tests/string_unittest.cc View 1 2 chunks +11 lines, -0 lines 0 comments Download
M mojo/public/cpp/bindings/tests/struct_unittest.cc View 1 1 chunk +29 lines, -0 lines 0 comments Download

Messages

Total messages: 17 (8 generated)
jeffbrown
5 years ago (2015-12-10 22:17:05 UTC) #2
jeffbrown
5 years ago (2015-12-10 22:19:18 UTC) #4
vardhan
https://codereview.chromium.org/1519673002/diff/1/mojo/common/BUILD.gn File mojo/common/BUILD.gn (right): https://codereview.chromium.org/1519673002/diff/1/mojo/common/BUILD.gn#newcode12 mojo/common/BUILD.gn:12: "logging.h", After looking at https://github.com/domokit/mojo/issues/480 and talking to Trung.. ...
5 years ago (2015-12-11 00:12:20 UTC) #5
jeffbrown
Ok here we go. I moved the output formatters where they really belong. I expect ...
5 years ago (2015-12-12 01:34:53 UTC) #9
jeffbrown
Ok here we go. I moved the output formatters where they really belong. I expect ...
5 years ago (2015-12-12 01:35:15 UTC) #11
viettrungluu
Let me list some of my concerns: 1. This takes away an area of customization ...
5 years ago (2015-12-15 16:09:38 UTC) #13
jeffbrown
Committed patchset #3 (id:40001) manually as 7a6f49a41fb7f7616397a497e072b09373617c79.
5 years ago (2015-12-17 19:33:27 UTC) #15
jeffbrown
Blocked on this so submitting TBR. We can refactor in the new year.
5 years ago (2015-12-17 19:33:53 UTC) #16
jeffbrown
5 years ago (2015-12-17 19:34:48 UTC) #17
Message was sent while issue was closed.
Some good points however I feel we can be a little more opinionated about the
behavior of our framework.

1. Due to ADL, clients of Mojo would have difficulty defining operator overloads
for Mojo types in their own namespace anyhow.  If their formatting needs are
especially particular then I can easily envision them wanting to define their
own stream type rather than use std::ostream and being beholden to the standard
library's own behavior.

2. I can remove this phrase.  Really I just wanted something human readable
which is the general intent of the standard library output formatters anyhow. 
These formatters are consistent with that aim.

3. I tried this approach and it created some challenges.  a) There isn't a clear
place for the declarations to go.  b) Nearly everyone who defines output
formatters ends up wanting to include it.  c) Output formatters are easier to
find next to their related types for API usability.

4. I think we can cross that bridge when we get to it.  For now the Array, Map,
and String types belong to Mojo so it makes sense for us to specify how they are
formatted.  If we change the representation then there will be lots of other
things to fix at the same time and we can revisit our options then.

5. Mojo::ToDebugString is pretty clunky.  Moreover I really don't want to be
generating intermediate strings all over the place.  Output formatters already
neatly solve this problem and are compatible with our logging infrastructure.

All things considered I would very much like to proceed with the current
approach and see whether it causes any trouble down the road.

The big argument for me is API usability.  I don't think we lose anything by
defining these functions.

Thanks for your consideration.

Powered by Google App Engine
This is Rietveld 408576698