LOG vs DLOG

1,202 views
Skip to first unread message

Daniel Cheng

unread,
Jun 29, 2017, 2:27:43 AM6/29/17
to cxx
I've noticed there's sometimes code that uses LOG when DLOG would (probably) have been more appropriate. For example:

Ryan Sleevi

unread,
Jun 29, 2017, 9:10:24 AM6/29/17
to Daniel Cheng, cxx
I had not heard that philosophy of the two approaches (e.g. can the user act on it versus not). My understanding had been "Is this something worth shipping to all users - that is, is this piece of information the critical difference in closing a feedback loop of debugging an issue". Perhaps that's the wrong way of thinking about it - but do you know of any guidance on when/where the appropriate time to use LOG is.

Note: I also say this as someone who routinely pushes back on LOG statements, despite being guilty for one of those examples above.

--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAF3XrKoaASF0goOtE%3DNAnHrv2mNtDtHuyrGHyik9jG-dHoirfg%40mail.gmail.com.

Primiano Tucci

unread,
Jun 29, 2017, 11:16:44 AM6/29/17
to rsl...@chromium.org, Daniel Cheng, cxx
There was some related discussion in the past 

And there is a presubmit that today shouts only for LOG(INFO). Maybe that should be promoted to LOG(<FATAL)

My $0.02:
If we really had to do something about logs my proposal would be:
1. Intern log strings, remove the actual strings from official builds and just keep their index/uuid (i.e. LOG << "whatever" becomes LOG << 0x42) in some automagic way (keep the strings for non-official).
2. Make those log to a ring buffer that breakpad/crashpad attaches to the minidump on crash (IIRC today only the last log line is preserved). Similarly dump them into the chrome://tracing when people are grabbing traces.

Not sure if there is any other scenario where LOG() statements have a useful value. 

(But yes, this is now a harder thing than just not logging)

Peter Kasting

unread,
Jun 29, 2017, 2:11:40 PM6/29/17
to Primiano Tucci, Ryan Sleevi, Daniel Cheng, cxx
These threads have some great history in them.  It looks like both talk about converting LOG(INFO) to VLOG(1), and the latter talks about making VLOG be DVLOG-by-default (I scanned quickly, so not sure of the details).

And both mention a fundamental principle, which is that not logging at all is even better when possible.  Basically, if we had a presubmit, it should probably just look for _any_ logging and try and say "we have major binary size problems and logs are usually not collected or actionable.  Only log if you absolutely know for sure what you're doing and know that you need this."

PK 

Antoine Labour

unread,
Jun 29, 2017, 2:18:12 PM6/29/17
to Peter Kasting, Primiano Tucci, Ryan Sleevi, Daniel Cheng, cxx
I strongly support removing LOGs in general. During reviews I almost always ask to change LOGs to DLOGs or even DVLOGs.
That said, some logs are definitely collected and actionable - for example they are uploaded to crash reports on Chrome OS, and that is often invaluable to provide context to understand those crashes.

Thanks,
Antoine
 

PK 

--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To post to this group, send email to c...@chromium.org.
Reply all
Reply to author
Forward
0 new messages