<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Understood, we need to be able to log if "any" bits are set. <br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jan 20, 2022, at 2:18 PM, Jim Ingham <<a href="mailto:jingham@apple.com" class="">jingham@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">On Jan 20, 2022, at 11:26 AM, Pavel Labath <<a href="mailto:pavel@labath.sk" class="">pavel@labath.sk</a>> wrote:<br class=""><br class="">On 20/01/2022 00:30, Greg Clayton wrote:<br class=""><blockquote type="cite" class="">I also vote to remove and simplify.<br class=""></blockquote><br class="">Sounds like it's settled then. I'll fire up my sed scripts.<br class=""><br class="">On 20/01/2022 01:38, Greg Clayton wrote:<br class=""><blockquote type="cite" class="">On Jan 19, 2022, at 6:40 AM, Pavel Labath <<a href="mailto:pavel@labath.sk" class="">pavel@labath.sk</a>> wrote:<span class="Apple-converted-space"> </span><br class=""><blockquote type="cite" class="">If we got rid of this, we could simplify the logging calls even further and have something like:>> Log *log =<br class="">GetLog(LLDBLog::Process);<br class=""></blockquote>Can a template function deduce the log type from an argument? Wouldn't this have to be:<br class="">Log *log = GetLog<LLDBLog>(LLDBLog::Process);<br class="">That is why I was hinting if we want to just use the enum class itself:<br class="">Log *log = LLDBLog::GetLog(LLDBLog::Process);<br class="">The template class in your second patch seems cool, but I don't understand how it worked without going and reading up on templates<br class="">in C++ and spending 20 minutes trying to wrap my brain around it.<br class=""></blockquote>Template functions have always been able to deduce template arguments.<br class="">Pretty much the entire c++ standard library is made of template<br class="">functions, but you don't see <> spelled out everywhere. Class templates<br class="">have not been able to auto-deduce template arguments until c++17, and I<br class="">am still not really clear on how that works.<br class=""><br class="">The way that patch works is that you have one template function<br class="">`LogChannelFor<T>`, which ties the enum to a specific channel class, and<br class="">then another one (GetLogIfAny), which returns the actual log object (and<br class="">uses the first one to obtain the channel).<br class=""><br class="">But none of this is fundamentally tied to templates. One could achieve<br class="">the same thing by overloading the GetLogIfAny function (one overload for<br class="">each type). The template just saves a bit of repetition. This way, the<br class="">only thing you need to do when defining a new log channel, is to provide<br class="">the LogChannelFor function.<br class=""><br class=""><blockquote type="cite" class="">Or do we just switch to a dedicated log class with unique methods:<br class="">class LLDBLog: public Log { Log *Process() { return GetLog(1u << 0);<br class="">} Log *Thread() { return GetLog(1u << 1); } };<br class="">and avoid all the enums? Then we can't ever feed a bad enum or #define  into the wrong log class.<br class=""></blockquote><br class="">That could work too, and would definitely have some advantages -- for<br class="">instance we could prefix each message with the log channel it was going<br class="">to. The downside is that we would lose the ability to send one message to multiple log channels at once, and I believe that some (Jim?) value that functionality.<br class=""></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">I think I’m just quibbling about terminology, I don’t think it’s possible for one site to send its log message to two channels in a single go.  That would be like “lldb types” and “dwarf info” for a single log statement.</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Anyway, that’s not something I see as particularly useful.</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">What is useful is to say “this message goes out on the lldb channel if any of these categories (“step” and “expr” for instance) is set.”  I don’t really think of that as sending the message to multiple channels, since it’s only going to go out once, but the test is broader.</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">But, IIUC, Greg’s proposal would also make that impossible as well, so I’m still against it…</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Jim</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class="">pl</blockquote></div></blockquote></div><br class=""></body></html>