I added a short summary as <https://wiki.documentfoundation.org/Development#Assertions_and_Logging>; feel free to expand. I also filed easy hack <https://bugs.freedesktop.org/show_bug.cgi?id=43157> "Clean up OSL_ASSERT, DBG_ASSERT, etc." As already discussed, if any uses of the obsolete functionality still remains after a while, I would initiate a mass-conversion OSL_ASSERT->SAL_WARN, OSL_TRACE->SAL_INFO, etc.
I made a few further changes to the proposed patches when I pushed them:- DBG_ASSERT etc. from tools/debug.hxx still are only enabled depending on DBG_UTIL. Trying an --enable-debug --disable-dbgutil build, it broke at many places that #ifdef DBG_UTIL some code that is later used within a DBG_ASSERT (e.g., an additional variable capturing some old value, modified later and checked afterwards, or a function parameter name that is only used within a DBG_ASSERT). This is a lot of work to clean up (see the easy hack above).
- I replaced the single SAL_LOG_LEVEL (with values 0, 1, 2) with individual defines SAL_LOG_INFO and SAL_LOG_WARN. This makes it easier to replace the code mentioned above, going from
#ifdef DBG_UTIL
int old = x;
#endif
... // modify x
DBG_ASSERT(x > old);
to
#if defined SAL_LOG_WARN // instead of: SAL_LOG_LEVEL >= 1
int old = x;
#endif
.. // modify x
SAL_WARN_IF(x <= old, "...");
(Where for such a cheap initialization like "int old = x;" it would also
work to have that variable included unconditionally, followed by a
"(void) old; // avoid warnings"; but there are also cases of more
expensive initialization, that you would likely want to keep excluded
from production builds.)
- The SAL_INFO/WARN messages are now defined to be always UTF-8, and rtl/oustringostreaminserter.hxx always converts to UTF-8. That minimizes information loss and would potentially enable use of SAL_STREAM for construction of UNO exception messages, see the recent thread about that. However, I do not bother to convert the data output to stderr from UTF-8 to any other encoding.
Stephan