In bug 1666802 [1] and dependencies, I removed LayersLogging.{cpp,h}.
These files had a bunch of serialization code that was used when
printf-debugging via various AppendToString functions (per-type) and
the templated Stringify function.
Instead of these functions, the preferred way is to define a <<
operator for the type (you can see some examples at [1]) and then use
mozilla::ToString the exact same way you would have used Stringify.
The << operator seems to be a more widely-used idiom, and is better
supported in things like gtests where the framework will try to
pretty-print structures when test assertions fail.
As part of this change I also made webrender FFI structs and enums
have the << operator auto-generated with cbindgen. It is turned on in
the WR cbindgen.toml for all structs, but can be disabled for
individual structs/enums [3].
Bug 1334042 [4] is also on file for having MOZ_LOG directly support
the << operator which would make things even nicer, so instead of
doing
MOZ_LOG(sModule, LogLevel::Debug, ("dump of myThing: %s",
ToString(myThing).c_str());
you would be able to do:
MOZ_LOG(sModule, LogLevel::Debug) << "dump of myThing: " << myThing;
If anybody feels like working on that, please do. I'll probably pick
it up at some point if nobody else does.
Cheers,
kats
[1]
https://bugzilla.mozilla.org/show_bug.cgi?id=1666802
[2]
https://searchfox.org/mozilla-central/search?q=operator%3C%3C&path=gfx%2Flayers&case=false®exp=false
[3]
https://searchfox.org/mozilla-central/search?q=derive.*ostream&path=&case=false®exp=true
[4]
https://bugzilla.mozilla.org/show_bug.cgi?id=1334042