include/sal/log.hxx | 3 +++ sal/osl/all/log.cxx | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-)
New commits: commit 99ee4ebb0e934413bed881a02e4634e4d3f813ea Author: Tor Lillqvist <t...@collabora.com> Date: Thu Aug 18 16:55:11 2016 +0300 If no WARN in SAL_LOG, use the INFO selection for WARNs, too Often the choice whether some particular message is displayed with SAL_INFO or SAL_WARN has not necessarily been that well thought through. Many SAL_WARNs are not actually warnings but purely informative. If you want to see the INFOs for an area it makes sense to want to see also the WARNs for it. So make it so, unless a specific WARN selection is specified. Change-Id: I6286c5f856b29e68bedb7f20efadf56953f94b72 diff --git a/include/sal/log.hxx b/include/sal/log.hxx index e879a2f..8b4ef0a 100644 --- a/include/sal/log.hxx +++ b/include/sal/log.hxx @@ -262,6 +262,9 @@ inline char const * unwrapStream(SAL_UNUSED_PARAMETER StreamIgnore const &) { that has a sense of "+". (That is, if both +INFO.foo and -INFO.foo are present, +INFO.foo wins.) + If no WARN selection is specified, but an INFO selection is, the + INFO selection is used for WARN messages, too. + For example, if SAL_LOG is "+INFO-INFO.foo+INFO.foo.bar", then calls like SAL_INFO("foo.bar", ...), SAL_INFO("foo.bar.baz", ...), or SAL_INFO("other", ...) generate output, while calls like diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx index 7f865f6..c1608b1 100644 --- a/sal/osl/all/log.cxx +++ b/sal/osl/all/log.cxx @@ -202,14 +202,17 @@ bool report(sal_detail_LogLevel level, char const * area) { // no matching switches at all, the result will be negative (and // initializing with 1 is safe as the length of a valid switch, even // without the "+"/"-" prefix, will always be > 1) + bool seenWarn = false; for (char const * p = env;;) { Sense sense; switch (*p++) { case '\0': + // if a specific item is both positive and negative + // (senseLen[POSITIVE] == senseLen[NEGATIVE]), default to + // positive + if (level == SAL_DETAIL_LOG_LEVEL_WARN && !seenWarn) + return report(SAL_DETAIL_LOG_LEVEL_INFO, area); return senseLen[POSITIVE] >= senseLen[NEGATIVE]; - // if a specific item is both positive and negative - // (senseLen[POSITIVE] == senseLen[NEGATIVE]), default to - // positive case '+': sense = POSITIVE; break; @@ -229,6 +232,7 @@ bool report(sal_detail_LogLevel level, char const * area) { } else if (equalStrings(p, p1 - p, RTL_CONSTASCII_STRINGPARAM("WARN"))) { match = level == SAL_DETAIL_LOG_LEVEL_WARN; + seenWarn = true; } else if (equalStrings(p, p1 - p, RTL_CONSTASCII_STRINGPARAM("TIMESTAMP")) || equalStrings(p, p1 - p, RTL_CONSTASCII_STRINGPARAM("RELATIVETIMER"))) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits