Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hi all,

The current situation with assertions and logging of "interesting events" in the LO code base is not very satisfying.

For one, there are two sets of functionality that cater for the same needs. One is osl/diagnose.h, the other is tools/debug.hxx.

For another, the distinction between true assertions (that assert invariants of the program code, and that indicate programming errors when not met) and the warning about unusual program states (that still need to be handled properly by the code, like the occurrence of malformed input) is not clear-cut with the existing macros. Some code is careful to use OSL_ASSERT only for true assertions and OSL_TRACE for warnings about unusual program states, while other cdoee uses OSL_ASSERT for both cases.

The downside of that mixture is that the useful debugging technique of aborting upon detection of a violated invariant is not available.---If you make OSL_ASSERT (and OSL_ENSURE, OSL_FAIL, etc.) abort, it will abort far too often for mundane warnings for it to be useful.

And for a third, the combinatorial space of --enable-debug, --enable-dbgutil, OSL_DEBUG_LEVEL, DBG_UTIL, etc. is rather confusing. While --enable-debug (prepare the build for easy debugging, by letting the compiler emit extra debug information and disable optimizations, etc.) and --enable-dbgutil (enable additional checks in the code base) ought to be rather orthogonal, in some sense they ultimately converge on the same OSL_DEBUG_LEVEL macro, trying to control disparate needs with a mere three values, 0, 1, 2. (--enable-debug and --enable-dbgutil both set OSL_DEBUG_LEVEL to 1; setting it to 2 requires passing a dbglevel=2 switch to make; additionally, --enable-dbgutil defines the DBG_UTIL macro.) Also, confusion keeps arising as to whether enabling various debugging mechanisms may render the code for which they have been enabled incompatible (i.e., whether they have to be enabled for the complete build, or can be enabled selectively). The general idea is that --enable-debug does not cause incompatibility, while --enable-dbgutil potentially does (and even uses another $INPATH, removing the ".pro" extension).


That being the status quo, an analysis of what would actually be useful to have brings us to the following three points:

1 There is demand for "true" assertions (that identify errors in program logic and abort). I suggest to use standard <assert.h> for them. It is available everywhere (in every module, in C as well as C++), and no home-brown solution is needed. It might be considered a disadvantage that assert does not allow to supply an additional error message. However, as a failed assert promptly aborts program execution with an appropriate message (supplied by the compiler, containing file and line information), the missing message is not much of a nuisance---you will need to look at the specified program location right away anyway, to debug the problem. (On Unix-like OSs, assert generally outputs to stderr; for Windows GUI applications, it outputs to a message box and allows attaching a debugger, see the MSDN documentation for "assert" at <http://msdn.microsoft.com/en-us/library/9sb57dw4%28v=vs.71%29.aspx>.)

Whether assertions are enabled (and abort when not met) is ontrolled via the standard NDEBUG macro. It is already taken care of in our build environment, being left undefined (i.e., assertions are enabled) for --enable-dbgutil and for --enable-debug. (In the old build system, it is only left undefined for --enable-dbgutil, and always defined---thus disabling assertions---otherwise.) As enabling assertions should not affect compatibility, enabling them for booth --enable-dbgutil and --enable-debug appears appropriate. (But we can leave the behaviour of the old build system as it is, given that it is going away, anyway.)

2 There is also demand for logging of "interesting events" during code execution. For this, I propose new functionality below. Whether or not logging is enabled should not affect compatibility.

The rationale for replacing the current mechanisms for both (1) and (2) with something else each, is to allow for a smooth transition. Existing occurrences of OSL_ASSERT etc. can be inspected individually, replacing them either with assert (see above) or SAL_WARN (see below). If we would instead keep OSL_ASSERT for one of those two cases, it would be unclear for an occurrences of OSL_ASSERT in the code whether it has already been visited and reclassified or not.

3 Furthermore, there is sometimes demand for additional, debug-only code. In general, that would be safety-check additions that are considered too expensive to be included in production builds (e.g., code that iterates over a data structure to check invariants, or additional, redundant fields within data structures). Enabling such additional code potentially affects compatibility.

Such additional code is currently controlled via OSL_DEBUG_LEVEL et al. OSL_DEBUG_LEVEL==1 is generally used for additions that do not affect compatibility (as it is enabled by both --enable-debug and --enable-dbgutil). OSL_DEBUG_LEVEL==2, DBG_UTIL (defined upon --enable-dbguitl) and privately invented defines in certain parts of the code (to be set manually by knowledgeable developers) are used for additions that affect compatibility or that are considered too specific for general inclusion. Either because they are too expensive even for every --enable-dbgutil build, or because they produce excessive log information (for which case the below new log functionality offers a better solution).

This can probably be reduced to three cases:

#if OSL_DEBUG_LEVEL != 0 for additional code that does not cause incompatibilities (if there is still demand for such code; the new log functionality will remove the need for such code in many cases). This effectively reduces OSL_DEBUG_LEVEL to a binary switch (so the make dbglevel=x feature can be removed; and OSL_DEBUG_LEVEL could potentially be renamed---but that would probably not be worth it).

#if defined DBG_UTIL  for additional code that causes incompatibilities.

#if defined MY_SPECIAL_DEBUG (replaced with actual defines, varying across the different code modules) for those special cases where always enabling the additional code is deemed to expensive in general. (However, for those special cases where the additional code produces excess log information, see below.)


Which brings us to the new log functionality.

Attached is a patch against current (towards LO 3.5) master (actually two patches, an extra one for binfilter). It introduces sal/log.h and makes osl/diagnose.h and tools/debug.h divert to it internally. It also replaces a few example occurrences of the old osl/diagnoes.h and tools/debug.h macros with their new counterparts (and I encourage you to take a look at those replacements, to get a feel for what is possible with the new functionality).

For easy reference, I copy the relevant documentation from sal/log.h here:

    SAL_INFO(char const * area, char const * format, ...),
    SAL_INFO_IF(bool condition, char const * area, char const * format, ...),
    SAL_WARN(char const * area, char const * format, ...), and
    SAL_WARN_IF(bool condition, char const * area, char const * format, ...)
    produce an info resp. warning log entry with a printf-style message.  The
    given format argument and any following arguments must be so that that
    sequence of arguments would be appropriate for a call to printf.

    SAL_INFO_S(char const * area, expr),
    SAL_INFO_IF_S(bool condition, char const * area, expr),
    SAL_WARN_S(char const * area, expr), and
    SAL_WARN_IF_S(bool condition, char const * area, expr) produce an info resp.
    warning log entry with a message produced by piping items into a C++
    std::ostringstream (and are only available in C++).  The given expr must be
    so that the full expression "stream << expr" is valid, where stream is a
    variable of type std::ostringstream.

      SAL_INFO_S("foo", "string " << s << " of length " << n)

    would be an example of such a call; if the given s is of type rtl::OUString,

      #include "rtl/oustringostreaminserter.hxx"

    would make sure that an appropriate operator << is available.

    For the _IF variants, log output is only generated if the given condition is
    true (in addition to the other conditions that have to be met).

    For all these macros, the given area argument must be non-null and must
    match the regular expression

      <area> ::= <subarea>("."<subarea>)*

    with

      <subarea> ::= [0-9a-z]+

    Whether these macros generate any log output is controlled in a two-stage
    process.

    First, at compile time the macro SAL_LOG_LEVEL controls whether these macros
    expand to actual code, or to no-ops.  SAL_LOG_LEVEL must expand to an
    integral value 0, 1, or 2.

    If SAL_LOG_LEVEL is 0, neither the INFO nor the WARN macros produce code.
    If SAL_LOG_LEVEL is 1, only the WARN macros produce code.  If SAL_LOG_LEVEL
    is 2, both the INFO and the WARN macros produce code.

    Second, at runtime the environment variable SAL_LOG further limits which
    macro calls actually generate log output.  The environment varialbe SAL_LOG
    must either be unset or must match the regular expression

      <env> ::= <switch>*

    with

      <switch> ::= <sense><level><area>?
      <sense> ::= "+"|"-"
      <level> ::= "INFO"|"WARN"

    If the environment variable is unset, "+WARN" is used instead (which results
    in all warnings being output but no infos).  If the given value does not
    match the regular expression, "+INFO+WARN" is used instead (which in turn
    results in everything being output).

    A given macro call's level (INFO or WARN) and area is matched against the
    given switches as follows:  Only those switches for which the level matches
    the given level and for which the area is a prefix (including both empty and
    full prefixes) of the given area are considered.  Log output is generated if
    and only if among the longest such switches (if any), there is at least one
    that has a sense of "+".  (That is, if both +WARN.foo and -WARN.foo are
    present, +WARN.foo wins.)

    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
    SAL_INFO("foo", ...) or SAL_INFO("foo.barzzz", ...) do not.

    The generated log output consists of the given level ("info" or "warn"), the
    given area, the process ID, the thread ID, the source file, and the source
    line number, each followed by a colon, followed by a space, the given
    message, and a newline.  The given message should contain no vertical
    formatting characters and no null characters.  The precise format of the log
    output is subject to change.  The log output is printed to stderr.

Some further points:

- Whether or not both SAL_INFO and SAL_WARN produce actual code is currently effectively controlled via OSL_DEBUG_LEVEL: With either --enable-dbgutil or --enable-debug, the full log functionality is enabled. Whether or not a more fine-grained control (producing code for only SAL_WARN) is necessary needs to be seen. (If not, SAL_LOG_LEVEL can be folded into OSL_DEBUG_LEVEL.) Having SAL_INFO compiled into each --enable-dbgutil build makes it possible to selectively enable interesting log information via SAL_LOG=+INFO.foo without having to recompile code.

- Assigning area codes to the macro invocations, I have mostly stuck to single-segment area codes that match the names of the code modules ("sal", "binfilter", "sfx2"). For the replacements within osl/diangose.h and tools/debug.hxx (that will in turn be called from various places, so it would not make much sense to attribute them to "sal" or "tools", respectively) I used "legacy.osl" and "legacy.tools", respectively. For a few cases where old code was OSL_DEBUG_LEVEL>=2 conditional, I used two-segment area codes "canvas.level2", "jfw.level2" (and "jfw.level1"), "sw.level2".

- Replacing all existing calls to deprecated osl/diagnose.h and tools/debug.hxx macros will need to happen over time (an easy hack).

- There is further functionality in tools/debug.hxx (DBG_MEMTEST, DBG_CTOR, etc.) that has not yet been addressed.

- The recently introduced OSL_FORMAT is superseded by SAL_STREAM (which uses C++-stream-style composition instead of C-printf-format-style). OSL_FORMAT and all its uses have been removed.

- The implementation is somewhat careful to produce as little code as possible at the call-site of the new macros, and to keep the code path for suppressed logs as short as possible. However, the C++-stream-style macros will potentially always be more expensive than the C-printf-format-style ones. But the former are more useful, so I would encourage you to nevertheless use them where appropriate.

- unotest/oustringostreaminserter.hxx is moved to rtl/oustringostreaminserter.hxx (and duplications of it below unotest are removed); it is often needed in combination with sal/log.h.

- In a few places, the patches replace occurrences of tools String with rtl::OUString, so that streaming works. Otherwise, it is necessary to wrap the tools String in an OUString ctor.

- sal/log.h contains a TODO to enable a GCC __attribute__((format)) on the C funtion underneath the C-printf-format-style macros. Enabling it would produce tons of -Werror=format from old OSL_TRACE uses. These need to be cleaned up first (an easy hack).

One open question is which set of macros (the C-printf-format-style ones or the C++-stream-style ones) to give the "natural" names without additional suffix. For now, I reserve the natural names for the C-style ones, as they are more universal (not only available in C++) and produce smaller call-side code, especially for the simple, common case where the message consists of just a string literal, as in SAL_INFO("foo", "message"). However, reserving the natural names for the C++-style macros (and giving the other ones an _F suffix, say) would be justified by their better usability (and thus more frequent usage) and the fact that they avoid the pitfall of having to escape any literal "%" within the format string of a C-style macro usage---although enabling GCC's __attribute__((format)) check would also help detect misuses like SAL_INFO("foo", "100%").

If there is no objection, I will push the patches to master next week. Due to removing OSL_FORMAT and osl_detail_formatString again, I would prefer to get this still into LO 3.5.

Stephan
diff --git a/avmedia/source/viewer/mediawindowbase_impl.cxx 
b/avmedia/source/viewer/mediawindowbase_impl.cxx
index 77ec02b..3c883a1 100644
--- a/avmedia/source/viewer/mediawindowbase_impl.cxx
+++ b/avmedia/source/viewer/mediawindowbase_impl.cxx
@@ -30,6 +30,8 @@
 #include <avmedia/mediaitem.hxx>
 #include "mediamisc.hxx"
 #include "mediawindow.hrc"
+#include <rtl/oustringostreaminserter.hxx>
+#include <sal/log.h>
 #include <tools/urlobj.hxx>
 #include <comphelper/processfactory.hxx>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -81,14 +83,18 @@ uno::Reference< media::XPlayer > MediaWindowBaseImpl::createPlayer( const ::rtl:
                     xManager->createPlayer( rURL ), uno::UNO_QUERY );
             }
             else
-                OSL_FAIL( "failed to create media player service " AVMEDIA_MANAGER_SERVICE_NAME );
+                SAL_WARN_S(
+                    "avmedia",
+                    ("failed to create media player service "
+                     AVMEDIA_MANAGER_SERVICE_NAME));
         }
         catch( const uno::Exception &e )
         {
             (void)e;
-            OSL_FAIL( OSL_FORMAT( "couldn't create media player '%s', exception '%s'",
-                                  AVMEDIA_MANAGER_SERVICE_NAME,
-                                  rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 
).getStr() ) );
+            SAL_WARN_S(
+                "avmedia",
+                "couldn't create media player " AVMEDIA_MANAGER_SERVICE_NAME
+                    ", exception '" << e.Message << '\'');
         }
     }
 
diff --git a/basic/inc/basic/sbxcore.hxx b/basic/inc/basic/sbxcore.hxx
index a4abca6..1969adf 100644
--- a/basic/inc/basic/sbxcore.hxx
+++ b/basic/inc/basic/sbxcore.hxx
@@ -39,6 +39,7 @@
 class SvStream;
 class String;
 class UniString;
+namespace rtl { class OUString; }
 
 // The following Macro defines four (five) necessary methods within a
 // SBX object. LoadPrivateData() and StorePrivateData() must be implemented.
@@ -133,7 +134,7 @@ public:
     static void RemoveFactory( SbxFactory* );
 
     static SbxBase* Create( sal_uInt16, sal_uInt32=SBXCR_SBX );
-    static SbxObject* CreateObject( const String& );
+    static SbxObject* CreateObject( const rtl::OUString& );
 };
 
 #ifndef SBX_BASE_DECL_DEFINED
diff --git a/basic/source/app/app.cxx b/basic/source/app/app.cxx
index 9eb83c8..95dadc0 100644
--- a/basic/source/app/app.cxx
+++ b/basic/source/app/app.cxx
@@ -70,7 +70,9 @@
 #include <ucbhelper/content.hxx>
 #include <unotools/syslocale.hxx>
 
+#include <rtl/oustringostreaminserter.hxx>
 #include <rtl/strbuf.hxx>
+#include <sal/log.h>
 
 using namespace comphelper;
 using namespace cppu;
@@ -241,8 +243,9 @@ int BasicApp::Main( )
     DbgSetPrintTestTool( DBG_TestToolDebugMessageFilter );
     DBG_INSTOUTERROR( DBG_OUT_TESTTOOL );
 
-    if ( osl_setDebugMessageFunc( osl_TestToolDebugMessageFilter ) )
-        OSL_FAIL("osl_setDebugMessageFunc returns non NULL pointer");
+    SAL_WARN_IF(
+        osl_setDebugMessageFunc(osl_TestToolDebugMessageFilter), "basic",
+        "osl_setDebugMessageFunc returns non NULL pointer");
 #endif
 
     ResMgr::SetReadStringHook( ReplaceStringHookProc );
@@ -1848,12 +1851,10 @@ String BasicFrame::GenRealString( const String &aResString )
         }
         else
         {
-            OSL_FAIL(
-                OSL_FORMAT(
-                    "Unknown replacement in String: %s",
-                    rtl::OUStringToOString(
-                        aResult.Copy(nStart, nEnd - nStart),
-                        RTL_TEXTENCODING_UTF8).getStr()));
+            SAL_WARN_S(
+                "basic",
+                "Unknown replacement in String: "
+                    << rtl::OUString(aResult.Copy(nStart, nEnd - nStart)));
             nStartPos = nStartPos + StartKenn.Len();
         }
     }
diff --git a/basic/source/sbx/sbxbase.cxx b/basic/source/sbx/sbxbase.cxx
index 1520c43..fa831ab 100644
--- a/basic/source/sbx/sbxbase.cxx
+++ b/basic/source/sbx/sbxbase.cxx
@@ -38,7 +38,8 @@
 #include <basic/sbxbase.hxx>
 
 #include <rtl/instance.hxx>
-#include <rtl/strbuf.hxx>
+#include <rtl/oustringostreaminserter.hxx>
+#include <sal/log.h>
 
 // AppData-Structure for SBX:
 
@@ -212,19 +213,11 @@ SbxBase* SbxBase::Create( sal_uInt16 nSbxId, sal_uInt32 nCreator )
         if( pNew )
             break;
     }
-#ifdef DBG_UTIL
-    if( !pNew )
-    {
-        rtl::OStringBuffer aMsg(
-            RTL_CONSTASCII_STRINGPARAM("SBX: Keine Factory fuer SBX-ID "));
-        aMsg.append(static_cast<sal_Int32>(nSbxId));
-        DbgError(aMsg.getStr());
-    }
-#endif
+    SAL_WARN_IF_S(!pNew, "basic", "No factory for SBX ID " << nSbxId);
     return pNew;
 }
 
-SbxObject* SbxBase::CreateObject( const XubString& rClass )
+SbxObject* SbxBase::CreateObject( const rtl::OUString& rClass )
 {
     SbxAppData& r = GetSbxData_Impl();
     SbxObject* pNew = NULL;
@@ -234,15 +227,7 @@ SbxObject* SbxBase::CreateObject( const XubString& rClass )
         if( pNew )
             break;
     }
-#ifdef DBG_UTIL
-    if( !pNew )
-    {
-        ByteString aMsg( "SBX: Keine Factory fuer Objektklasse " );
-        ByteString aClassStr( (const UniString&)rClass, RTL_TEXTENCODING_ASCII_US );
-        aMsg += aClassStr;
-        DbgError( (const char*)aMsg.GetBuffer() );
-    }
-#endif
+    SAL_WARN_IF_S(!pNew, "basic", "No factory for object class " << rClass);
     return pNew;
 }
 
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index 988c5c9..f7abc39 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -37,9 +37,10 @@
 #include <osl/mutex.hxx>
 #include <tools/errinf.hxx>
 #include <osl/mutex.hxx>
-#include <osl/diagnose.h>
+#include <rtl/oustringostreaminserter.hxx>
 #include <rtl/uri.hxx>
 #include <rtl/strbuf.hxx>
+#include <sal/log.h>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/anytostring.hxx>
 
@@ -382,24 +383,18 @@ SfxLibraryContainer::SfxLibraryContainer( void )
     DBG_CTOR( SfxLibraryContainer, NULL );
 
     mxMSF = comphelper::getProcessServiceFactory();
-    if( !mxMSF.is() )
-    {
-        OSL_FAIL( "couldn't get ProcessServiceFactory" );
-    }
+    SAL_WARN_IF(!mxMSF.is(), "basic", "couldn't get ProcessServiceFactory");
 
     mxSFI = Reference< XSimpleFileAccess >( mxMSF->createInstance
         ( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess")) ), UNO_QUERY 
);
-    if( !mxSFI.is() )
-    {
-        OSL_FAIL( "couldn't create SimpleFileAccess component" );
-    }
+    SAL_WARN_IF(
+        !mxSFI.is(), "basic", "couldn't create SimpleFileAccess component");
 
     mxStringSubstitution = Reference< XStringSubstitution >( mxMSF->createInstance
         ( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.PathSubstitution")) ), UNO_QUERY 
);
-    if( !mxStringSubstitution.is() )
-    {
-        OSL_FAIL( "couldn't create PathSubstitution component" );
-    }
+    SAL_WARN_IF(
+        !mxStringSubstitution.is(), "basic",
+        "couldn't create PathSubstitution component");
 }
 
 SfxLibraryContainer::~SfxLibraryContainer()
@@ -432,7 +427,10 @@ BasicManager* SfxLibraryContainer::getBasicManager( void )
         return mpBasMgr;
 
     Reference< XModel > xDocument( mxOwnerDocument.get(), UNO_QUERY );
-    OSL_ENSURE( xDocument.is(), "SfxLibraryContainer::getBasicManager: cannot obtain a 
BasicManager without document!" );
+    SAL_WARN_IF(
+        !xDocument.is(), "basic",
+        ("SfxLibraryContainer::getBasicManager: cannot obtain a BasicManager"
+         " without document!"));
     if ( xDocument.is() )
         mpBasMgr = BasicManagerRepository::getDocumentBasicManager( xDocument );
 
@@ -673,7 +671,7 @@ sal_Bool SfxLibraryContainer::init_Impl(
         OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Parser") ) ), UNO_QUERY );
     if( !xParser.is() )
     {
-        OSL_FAIL( "couldn't create sax parser component" );
+        SAL_WARN("basic", "couldn't create sax parser component");
         return sal_False;
     }
 
@@ -697,8 +695,9 @@ sal_Bool SfxLibraryContainer::init_Impl(
     {
         if( bStorage )
         {
-            OSL_ENSURE( meInitMode == DEFAULT || meInitMode == OFFICE_DOCUMENT,
-                "### Wrong InitMode for document\n" );
+            SAL_WARN_IF(
+                meInitMode != DEFAULT && meInitMode != OFFICE_DOCUMENT, "basic",
+                "Wrong InitMode for document");
             try
             {
                 uno::Reference< io::XStream > xStream;
@@ -824,13 +823,13 @@ sal_Bool SfxLibraryContainer::init_Impl(
             catch ( xml::sax::SAXException& e )
             {
                 (void) e; // avoid warning
-                OSL_FAIL( OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
+                SAL_WARN_S("basic", e.Message);
                 return sal_False;
             }
             catch ( io::IOException& e )
             {
                 (void) e; // avoid warning
-                OSL_FAIL( OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
+                SAL_WARN_S("basic", e.Message);
                 return sal_False;
             }
 
@@ -918,16 +917,11 @@ sal_Bool SfxLibraryContainer::init_Impl(
                         {
                         #if OSL_DEBUG_LEVEL > 0
                             Any aError( ::cppu::getCaughtException() );
-                            OSL_FAIL(
-                                OSL_FORMAT(
-                                    ("couldn't open sub storage for library"
-                                     " \"%s\". Exception: %s"),
-                                    (rtl::OUStringToOString(
-                                        rLib.aName, RTL_TEXTENCODING_UTF8).
-                                     getStr()),
-                                    rtl::OUStringToOString(
-                                        comphelper::anyToString(aError),
-                                        RTL_TEXTENCODING_UTF8).getStr()));
+                            SAL_WARN_S(
+                                "basic",
+                                "couldn't open sub storage for library \""
+                                    << rLib.aName << "\". Exception: "
+                                    << comphelper::anyToString(aError));
                         #endif
                         }
                     }
@@ -937,11 +931,10 @@ sal_Bool SfxLibraryContainer::init_Impl(
                     {
                         OUString aIndexFileName;
                         sal_Bool bLoaded = implLoadLibraryIndexFile( pImplLib, rLib, xLibraryStor, 
aIndexFileName );
-                        if( bLoaded && aLibName != rLib.aName )
-                        {
-                            OSL_FAIL( "Different library names in library"
-                                " container and library info files!" );
-                        }
+                        SAL_WARN_IF(
+                            bLoaded && aLibName != rLib.aName, "basic",
+                            ("Different library names in library container and"
+                             " library info files!"));
                         if( GbMigrationSuppressErrors && !bLoaded )
                             removeLibrary( aLibName );
                     }
@@ -989,7 +982,7 @@ sal_Bool SfxLibraryContainer::init_Impl(
         catch(const uno::Exception& )
         {
             // TODO: error handling?
-            OSL_FAIL( "Cannot access extensions!" );
+            SAL_WARN("basic", "Cannot access extensions!");
         }
     }
 
@@ -1204,7 +1197,7 @@ sal_Bool SfxLibraryContainer::init_Impl(
         // #i93163
         if( bCleanUp )
         {
-            OSL_FAIL( "Upgrade of Basic installation failed somehow" );
+            SAL_WARN("basic", "Upgrade of Basic installation failed somehow");
 
             static char strErrorSavFolderName[] = "__basic_80_err";
             INetURLObject aPrevUserBasicInetObj_Err( aUserBasicInetObj );
@@ -1414,11 +1407,9 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
 
             if( !isLibraryElementValid( pLib->getByName( aElementName ) ) )
             {
-                OSL_FAIL(
-                    OSL_FORMAT(
-                        "invalid library element \"%s\"",
-                        rtl::OUStringToOString(
-                            aElementName, RTL_TEXTENCODING_UTF8).getStr()));
+                SAL_WARN_S(
+                    "basic",
+                    "invalid library element \"" << aElementName << '"');
                 continue;
             }
             try {
@@ -1431,7 +1422,9 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
                 OUString aMime( RTL_CONSTASCII_USTRINGPARAM("text/xml") );
 
                 uno::Reference< beans::XPropertySet > xProps( xElementStream, uno::UNO_QUERY );
-                OSL_ENSURE( xProps.is(), "The StorageStream must implement XPropertySet 
interface!\n" );
+                SAL_WARN_IF(
+                    !xProps.is(), "basic",
+                    "The StorageStream must implement XPropertySet interface!");
                 //if ( !xProps.is() ) //TODO
 
                 if ( xProps.is() )
@@ -1449,7 +1442,7 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
             }
             catch(const uno::Exception& )
             {
-                OSL_FAIL( "Problem during storing of library!" );
+                SAL_WARN("basic", "Problem during storing of library!");
                 // TODO: error handling?
             }
         }
@@ -1496,11 +1489,9 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
 
                 if( !isLibraryElementValid( pLib->getByName( aElementName ) ) )
                 {
-                    OSL_FAIL(
-                        OSL_FORMAT(
-                            "invalid library element \"%s\"",
-                            rtl::OUStringToOString(
-                                aElementName, RTL_TEXTENCODING_UTF8).getStr()));
+                    SAL_WARN_S(
+                        "basic",
+                        "invalid library element \"" << aElementName << '"');
                     continue;
                 }
 
@@ -1552,7 +1543,7 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
             OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer") ) ), UNO_QUERY );
     if( !xHandler.is() )
     {
-        OSL_FAIL( "couldn't create sax-writer component" );
+        SAL_WARN("basic", "couldn't create sax-writer component");
         return;
     }
 
@@ -1569,7 +1560,7 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
 
         try {
             xInfoStream = xStorage->openStreamElement( aStreamName, embed::ElementModes::READWRITE 
);
-            OSL_ENSURE( xInfoStream.is(), "No stream!\n" );
+            SAL_WARN_IF(!xInfoStream.is(), "basic", "No stream!");
             uno::Reference< beans::XPropertySet > xProps( xInfoStream, uno::UNO_QUERY );
             //    throw uno::RuntimeException(); // TODO
 
@@ -1588,7 +1579,7 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
         }
         catch(const uno::Exception& )
         {
-            OSL_FAIL( "Problem during storing of library index file!" );
+            SAL_WARN("basic", "Problem during storing of library index file!");
             // TODO: error handling?
         }
     }
@@ -1637,7 +1628,7 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
     }
     if( !xOut.is() )
     {
-        OSL_FAIL( "couldn't open output stream" );
+        SAL_WARN("basic", "couldn't open output stream");
         return;
     }
 
@@ -1655,7 +1646,7 @@ sal_Bool SfxLibraryContainer::implLoadLibraryIndexFile(  SfxLibrary* pLib,
         OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Parser") ) ), UNO_QUERY );
     if( !xParser.is() )
     {
-        OSL_FAIL( "couldn't create sax parser component" );
+        SAL_WARN("basic", "couldn't create sax parser component");
         return sal_False;
     }
 
@@ -1727,7 +1718,7 @@ sal_Bool SfxLibraryContainer::implLoadLibraryIndexFile(  SfxLibrary* pLib,
     }
     catch(const Exception& )
     {
-        OSL_FAIL( "Parsing error" );
+        SAL_WARN("basic", "Parsing error");
         SfxErrorContext aEc( ERRCTX_SFX_LOADBASIC, aLibInfoPath );
         sal_uIntPtr nErrorCode = ERRCODE_IO_GENERAL;
         ErrorHandler::HandleError( nErrorCode );
@@ -1915,15 +1906,11 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< 
embed::XSto
                     {
                     #if OSL_DEBUG_LEVEL > 0
                         Any aError( ::cppu::getCaughtException() );
-                        OSL_FAIL(
-                            OSL_FORMAT(
-                                ("couldn't create sub storage for library"
-                                 " \"%s\". Exception: %s"),
-                                rtl::OUStringToOString(
-                                    rLib.aName, RTL_TEXTENCODING_UTF8).getStr(),
-                                rtl::OUStringToOString(
-                                    comphelper::anyToString(aError),
-                                    RTL_TEXTENCODING_UTF8).getStr()));
+                        SAL_WARN_S(
+                            "basic",
+                            "couldn't create sub storage for library \""
+                                << rLib.aName << "\". Exception: "
+                                << comphelper::anyToString(aError));
                     #endif
                         return;
                     }
@@ -1967,7 +1954,10 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< 
embed::XSto
     // then we need to clean up the temporary storage we used for this
     if ( bInplaceStorage && sTempTargetStorName.getLength() )
     {
-        OSL_ENSURE( xSourceLibrariesStor.is(), "SfxLibrariesContainer::storeLibraries_impl: 
unexpected: we should have a source storage here!" );
+        SAL_WARN_IF(
+            !xSourceLibrariesStor.is(), "basic",
+            ("SfxLibrariesContainer::storeLibraries_impl: unexpected: we should"
+             " have a source storage here!"));
         try
         {
             // for this, we first remove everything from the source storage, then copy the 
complete content
@@ -2028,7 +2018,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< 
embed::XSto
             OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer") ) ), UNO_QUERY );
     if( !xHandler.is() )
     {
-        OSL_FAIL( "couldn't create sax-writer component" );
+        SAL_WARN("basic", "couldn't create sax-writer component");
         return;
     }
 
@@ -2043,7 +2033,9 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< 
embed::XSto
         try {
             xInfoStream = xTargetLibrariesStor->openStreamElement( aStreamName, 
embed::ElementModes::READWRITE );
             uno::Reference< beans::XPropertySet > xProps( xInfoStream, uno::UNO_QUERY );
-            OSL_ENSURE ( xProps.is(), "The stream must implement XPropertySet!\n" );
+            SAL_WARN_IF(
+                !xProps.is(), "basic",
+                "The stream must implement XPropertySet!");
             if ( !xProps.is() )
                 throw uno::RuntimeException();
 
@@ -2088,7 +2080,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< 
embed::XSto
     }
     if( !xOut.is() )
     {
-        OSL_FAIL( "couldn't open output stream" );
+        SAL_WARN("basic", "couldn't open output stream");
         return;
     }
 
@@ -2101,7 +2093,9 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< 
embed::XSto
         if ( bStorage )
         {
             uno::Reference< embed::XTransactedObject > xTransact( xTargetLibrariesStor, 
uno::UNO_QUERY );
-            OSL_ENSURE( xTransact.is(), "The storage must implement XTransactedObject!\n" );
+            SAL_WARN_IF(
+                !xTransact.is(), "basic",
+                "The storage must implement XTransactedObject!");
             if ( !xTransact.is() )
                 throw uno::RuntimeException();
 
@@ -2110,7 +2104,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< 
embed::XSto
     }
     catch(const uno::Exception& )
     {
-        OSL_FAIL( "Problem during storing of libraries!" );
+        SAL_WARN("basic", "Problem during storing of libraries!");
         sal_uIntPtr nErrorCode = ERRCODE_IO_GENERAL;
         ErrorHandler::HandleError( nErrorCode );
     }
@@ -2326,12 +2320,18 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
         {
             try {
                 xLibrariesStor = mxStorage->openStorageElement( maLibrariesDir, 
embed::ElementModes::READ );
-                OSL_ENSURE( xLibrariesStor.is(), "The method must either throw exception or return 
a storage!\n" );
+                SAL_WARN_IF(
+                    !xLibrariesStor.is(), "basic",
+                    ("The method must either throw exception or return a"
+                     " storage!"));
                 if ( !xLibrariesStor.is() )
                     throw uno::RuntimeException();
 
                 xLibraryStor = xLibrariesStor->openStorageElement( Name, embed::ElementModes::READ 
);
-                OSL_ENSURE( xLibraryStor.is(), "The method must either throw exception or return a 
storage!\n" );
+                SAL_WARN_IF(
+                    !xLibraryStor.is(), "basic",
+                    ("The method must either throw exception or return a"
+                     " storage!"));
                 if ( !xLibrariesStor.is() )
                     throw uno::RuntimeException();
             }
@@ -2339,15 +2339,11 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
             {
             #if OSL_DEBUG_LEVEL > 0
                 Any aError( ::cppu::getCaughtException() );
-                OSL_FAIL(
-                    OSL_FORMAT(
-                        ("couldn't open sub storage for library \"%s\"."
-                         " Exception: %s"),
-                        (rtl::OUStringToOString(Name, RTL_TEXTENCODING_UTF8).
-                         getStr()),
-                        rtl::OUStringToOString(
-                            comphelper::anyToString(aError),
-                            RTL_TEXTENCODING_UTF8).getStr()));
+                SAL_WARN_S(
+                    "basic",
+                    "couldn't open sub storage for library \"" << Name
+                        << "\". Exception: "
+                        << comphelper::anyToString(aError));
             #endif
                 return;
             }
@@ -2392,12 +2388,10 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
 
                 if ( !xInStream.is() )
                 {
-                    OSL_FAIL(
-                        OSL_FORMAT(
-                            ("couldn't open library element stream - attempted"
-                             " to open library \"%s\""),
-                            rtl::OUStringToOString(
-                                Name, RTL_TEXTENCODING_UTF8).getStr()));
+                    SAL_WARN_S(
+                        "basic",
+                        "couldn't open library element stream - attempted to"
+                            " open library \"" << Name << '"');
                     return;
                 }
             }
@@ -2664,7 +2658,9 @@ void SfxLibraryContainer::_disposing( const EventObject& _rSource )
 {
 #if OSL_DEBUG_LEVEL > 0
     Reference< XModel > xDocument( mxOwnerDocument.get(), UNO_QUERY );
-    OSL_ENSURE( ( xDocument == _rSource.Source ) && xDocument.is(), 
"SfxLibraryContainer::_disposing: where does this come from?" );
+    SAL_WARN_IF(
+        xDocument != _rSource.Source || !xDocument.is(), "basic",
+        "SfxLibraryContainer::_disposing: where does this come from?");
 #else
     (void)_rSource;
 #endif
@@ -2772,14 +2768,13 @@ OUString SfxLibraryContainer::expand_url( const OUString& url )
     {
         if( !mxMacroExpander.is() )
         {
-            Reference< XPropertySet > xProps( mxMSF, UNO_QUERY );
-            OSL_ASSERT( xProps.is() );
+            Reference< XPropertySet > xProps( mxMSF, UNO_QUERY_THROW );
             if( xProps.is() )
             {
                 Reference< XComponentContext > xContext;
                 xProps->getPropertyValue(
                     OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xContext;
-                OSL_ASSERT( xContext.is() );
+                SAL_WARN_IF(!xContext.is(), "basic", "no DefaultContext");
                 if( xContext.is() )
                 {
                     Reference< util::XMacroExpander > xExpander;
@@ -3085,7 +3080,9 @@ void SfxLibrary::replaceByName( const OUString& aName, const Any& aElement )
     impl_checkReadOnly();
     impl_checkLoaded();
 
-    OSL_ENSURE( isLibraryElementValid( aElement ), "SfxLibrary::replaceByName: replacing element 
is invalid!" );
+    SAL_WARN_IF(
+        !isLibraryElementValid(aElement), "basic",
+        "SfxLibrary::replaceByName: replacing element is invalid!");
 
     maNameContainer.replaceByName( aName, aElement );
     implSetModified( sal_True );
@@ -3099,7 +3096,9 @@ void SfxLibrary::insertByName( const OUString& aName, const Any& aElement )
     impl_checkReadOnly();
     impl_checkLoaded();
 
-    OSL_ENSURE( isLibraryElementValid( aElement ), "SfxLibrary::insertByName: to-be-inserted 
element is invalid!" );
+    SAL_WARN_IF(
+        !isLibraryElementValid(aElement), "basic",
+        "SfxLibrary::insertByName: to-be-inserted element is invalid!");
 
     maNameContainer.insertByName( aName, aElement );
     implSetModified( sal_True );
@@ -3226,13 +3225,12 @@ ScriptExtensionIterator::ScriptExtensionIterator( void )
     , m_pScriptSubPackageIterator( NULL )
 {
     Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
-    Reference< XPropertySet > xProps( xFactory, UNO_QUERY );
-    OSL_ASSERT( xProps.is() );
+    Reference< XPropertySet > xProps( xFactory, UNO_QUERY_THROW );
     if (xProps.is())
     {
         xProps->getPropertyValue(
             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= m_xContext;
-        OSL_ASSERT( m_xContext.is() );
+        SAL_WARN_IF(!m_xContext.is(), "basic", "no DefaultContext");
     }
     if( !m_xContext.is() )
     {
@@ -3282,7 +3280,10 @@ rtl::OUString ScriptExtensionIterator::nextBasicOrDialogLibrary( bool& 
rbPureDia
                 break;
             }
             case END_REACHED:
-                OSL_FAIL( "ScriptExtensionIterator::nextBasicOrDialogLibrary(): Invalid case 
END_REACHED" );
+                SAL_WARN(
+                    "basic",
+                    ("ScriptExtensionIterator::nextBasicOrDialogLibrary():"
+                     " Invalid case END_REACHED"));
                 break;
         }
     }
@@ -3477,7 +3478,10 @@ Reference< deployment::XPackage > 
ScriptExtensionIterator::implGetNextUserScript
         {
             const Reference< deployment::XPackage >* pUserPackages = 
m_aUserPackagesSeq.getConstArray();
             Reference< deployment::XPackage > xPackage = pUserPackages[ m_iUserPackage ];
-            OSL_ENSURE( xPackage.is(), "ScriptExtensionIterator::implGetNextUserScriptPackage(): 
Invalid package" );
+            SAL_WARN_IF(
+                !xPackage.is(), "basic",
+                ("ScriptExtensionIterator::implGetNextUserScriptPackage():"
+                 " Invalid package"));
             m_pScriptSubPackageIterator = new ScriptSubPackageIterator( xPackage );
         }
 
@@ -3530,7 +3534,10 @@ Reference< deployment::XPackage > 
ScriptExtensionIterator::implGetNextSharedScri
         {
             const Reference< deployment::XPackage >* pSharedPackages = 
m_aSharedPackagesSeq.getConstArray();
             Reference< deployment::XPackage > xPackage = pSharedPackages[ m_iSharedPackage ];
-            OSL_ENSURE( xPackage.is(), "ScriptExtensionIterator::implGetNextSharedScriptPackage(): 
Invalid package" );
+            SAL_WARN_IF(
+                !xPackage.is(), "basic",
+                ("ScriptExtensionIterator::implGetNextSharedScriptPackage():"
+                 " Invalid package"));
             m_pScriptSubPackageIterator = new ScriptSubPackageIterator( xPackage );
         }
 
@@ -3583,7 +3590,10 @@ Reference< deployment::XPackage > 
ScriptExtensionIterator::implGetNextBundledScr
         {
             const Reference< deployment::XPackage >* pBundledPackages = 
m_aBundledPackagesSeq.getConstArray();
             Reference< deployment::XPackage > xPackage = pBundledPackages[ m_iBundledPackage ];
-            OSL_ENSURE( xPackage.is(), 
"ScriptExtensionIterator::implGetNextBundledScriptPackage(): Invalid package" );
+            SAL_WARN_IF(
+                !xPackage.is(), "basic",
+                ("ScriptExtensionIterator::implGetNextBundledScriptPackage():"
+                 " Invalid package"));
             m_pScriptSubPackageIterator = new ScriptSubPackageIterator( xPackage );
         }
 
diff --git a/canvas/inc/canvas/verbosetrace.hxx b/canvas/inc/canvas/verbosetrace.hxx
index 0e83082..96e12de 100644
--- a/canvas/inc/canvas/verbosetrace.hxx
+++ b/canvas/inc/canvas/verbosetrace.hxx
@@ -29,12 +29,11 @@
 #ifndef INCLUDED_CANVAS_VERBOSETRACE_HXX
 #define INCLUDED_CANVAS_VERBOSETRACE_HXX
 
-#if OSL_DEBUG_LEVEL > 2
-/// Wrap OSL_TRACE with a verbosity switch
-#define VERBOSE_TRACE     OSL_TRACE
-#else
-#define VERBOSE_TRACE     1 ? ((void)0) : OSL_TRACE
-#endif
+#include "sal/config.h"
+
+#include "sal/log.h"
+
+#define VERBOSE_TRACE(...) SAL_INFO("canvas.level2", __VA_ARGS__)
 
 #endif /* INCLUDED_CANVAS_VERBOSETRACE_HXX */
 
diff --git a/cppu/qa/cppumaker/test_cppumaker.cxx b/cppu/qa/cppumaker/test_cppumaker.cxx
index 11435e5..bac4b16 100644
--- a/cppu/qa/cppumaker/test_cppumaker.cxx
+++ b/cppu/qa/cppumaker/test_cppumaker.cxx
@@ -372,26 +372,13 @@
 #include <cppunit/TestFixture.h>
 #include <cppunit/extensions/HelperMacros.h>
 #include <cppunit/plugin/TestPlugIn.h>
+#include "rtl/oustringostreaminserter.hxx"
 #include "rtl/ustring.h"
 #include "rtl/ustring.hxx"
 
 #include <cstddef>
 #include <iostream>
 
-//TODO, copied here from test/oustringostreaminserter.hxx, make DRY again:
-#include "osl/thread.h"
-namespace rtl {
-template< typename charT, typename traits > std::basic_ostream<charT, traits> &
-operator <<(
-    std::basic_ostream<charT, traits> & stream, rtl::OUString const & string)
-{
-    return stream <<
-        rtl::OUStringToOString(string, osl_getThreadTextEncoding()).getStr();
-        // best effort; potentially loses data due to conversion failures and
-        // embedded null characters
-}
-}
-
 namespace com { namespace sun { namespace star { namespace uno {
 
 std::ostream & operator <<(
diff --git a/cppu/qa/test_unotype.cxx b/cppu/qa/test_unotype.cxx
index dbb13d6..fa2995b 100644
--- a/cppu/qa/test_unotype.cxx
+++ b/cppu/qa/test_unotype.cxx
@@ -55,24 +55,11 @@
 #include "com/sun/star/uno/XComponentContext.hpp"
 #include "com/sun/star/uno/XInterface.hpp"
 #include "cppu/unotype.hxx"
+#include "rtl/oustringostreaminserter.hxx"
 #include "rtl/ustring.h"
 #include "rtl/ustring.hxx"
 #include "sal/types.h"
 
-//TODO, copied here from test/oustringostreaminserter.hxx, make DRY again:
-#include "osl/thread.h"
-namespace rtl {
-template< typename charT, typename traits > std::basic_ostream<charT, traits> &
-operator <<(
-    std::basic_ostream<charT, traits> & stream, rtl::OUString const & string)
-{
-    return stream <<
-        rtl::OUStringToOString(string, osl_getThreadTextEncoding()).getStr();
-        // best effort; potentially loses data due to conversion failures and
-        // embedded null characters
-}
-}
-
 namespace com { namespace sun { namespace star { namespace uno {
     class Any;
 } } } }
diff --git a/desktop/source/deployment/registry/dp_backend.cxx 
b/desktop/source/deployment/registry/dp_backend.cxx
index 672364d..e847c3c 100644
--- a/desktop/source/deployment/registry/dp_backend.cxx
+++ b/desktop/source/deployment/registry/dp_backend.cxx
@@ -31,8 +31,10 @@
 
 #include "dp_backend.h"
 #include "dp_ucb.h"
+#include "rtl/oustringostreaminserter.hxx"
 #include "rtl/uri.hxx"
 #include "rtl/bootstrap.hxx"
+#include "sal/log.h"
 #include "osl/file.hxx"
 #include "cppuhelper/exc_hlp.hxx"
 #include "comphelper/servicedecl.hxx"
@@ -73,7 +75,7 @@ void PackageRegistryBackend::disposing( lang::EventObject const & event )
     ::osl::MutexGuard guard( getMutex() );
     if ( m_bound.erase( url ) != 1 )
     {
-        OSL_ASSERT( false );
+        SAL_WARN_S("basic", "erase(" << url << ") != 1");
     }
 }
 
@@ -207,8 +209,9 @@ Reference<deployment::XPackage> PackageRegistryBackend::bindPackage(
         m_bound.insert( t_string2ref::value_type( url, xNewPackage ) ) );
     if (insertion.second)
     { // first insertion
-        OSL_ASSERT( Reference<XInterface>(insertion.first->second)
-                    == xNewPackage );
+        SAL_WARN_IF(
+            Reference<XInterface>(insertion.first->second) != xNewPackage,
+            "desktop", "mismatch");
     }
     else
     { // found existing entry
@@ -339,7 +342,7 @@ Package::Package( ::rtl::Reference<PackageRegistryBackend> const & myBackend,
     if (m_bRemoved)
     {
         //We use the last segment of the URL
-        OSL_ASSERT(m_name.getLength() == 0);
+        SAL_WARN_IF(!m_name.isEmpty(), "basic", "non-empty m_name");
         OUString name = m_url;
         rtl::Bootstrap::expandMacros(name);
         sal_Int32 index = name.lastIndexOf('/');
@@ -679,11 +682,8 @@ void Package::processPackage_impl(
         }
         catch (RuntimeException &e) {
             (void) e; // avoid warnings
-            OSL_FAIL(
-                OSL_FORMAT(
-                    "unexpected RuntimeException \"%s\"",
-                    (rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).
-                     getStr())));
+            SAL_WARN_S(
+                "basic", "unexpected RuntimeException \"" << e.Message << '"');
             throw;
         }
         catch (CommandFailedException &) {
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/diagnostics.h 
b/jvmfwk/plugins/sunmajor/pluginlib/diagnostics.h
index 6a8ef32..eb1cd03 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/diagnostics.h
+++ b/jvmfwk/plugins/sunmajor/pluginlib/diagnostics.h
@@ -25,98 +25,20 @@
  * for a copy of the LGPLv3 License.
  *
  ************************************************************************/
-#if !defined INCLUDED_JFW_PLUGIN_DIAGNOSTICS_HXX
-#define INCLUDED_JFW_PLUGIN_DIAGNOSTICS_HXX
-#include "osl/diagnose.h"
-#include "rtl/ustring.hxx"
-#include <stdio.h>
-
-#if OSL_DEBUG_LEVEL >= 1
-#define JFW_ENSURE(c, m)  _JFW_ENSURE(c, OSL_THIS_FILE, __LINE__,  m)
-#else
-#define JFW_ENSURE(c, m)  ((void) 0)
-#endif
-
-#if OSL_DEBUG_LEVEL >= 2
-#define JFW_WARNING2(c, m)  _JFW_WARNING2(c, OSL_THIS_FILE, __LINE__, m)
-#else
-#define JFW_WARNING2(c, m)  ((void) 0)
-#endif
-
-
-#if OSL_DEBUG_LEVEL >= 0
-#define JFW_TRACE0(m)  jfw_trace(m)
-#else
-#define JFW_TRACE0(m)  ((void) 0)
-#endif
-
-#if OSL_DEBUG_LEVEL >= 1
-#define JFW_TRACE1(m)  jfw_trace(m)
-#else
-#define JFW_TRACE1(m)  ((void) 0)
-#endif
-
-#if OSL_DEBUG_LEVEL >= 2
-#define JFW_TRACE2(m)  jfw_trace(m)
-#else
-#define JFW_TRACE2(m)  ((void) 0)
-#endif
-
-
 
-#define _JFW_ENSURE(c, f, l, m)  jfw_ensure(c, f, l, m)
-#define _JFW_WARNING(c, f, l, m)  jfw_warning2(c, f, l, m);
-
-
-namespace jfw_plugin
-{
-
-inline void jfw_ensure(bool
-                       #if OSL_DEBUG_LEVEL > 0 /* prevent warning in pro version */
-                       condition
-                       #endif
-                       , const sal_Char *
-                       #if OSL_DEBUG_LEVEL > 0 /* prevent warning in pro version */
-                       pzFile
-                       #endif
-                       , sal_Int32
-                       #if OSL_DEBUG_LEVEL > 0 /* prevent warning in pro version */
-                       line
-                       #endif
-                       , const rtl::OUString& message )
-{
-    rtl::OString oMsg = rtl::OUStringToOString(message, osl_getThreadTextEncoding());
-    _OSL_ENSURE(condition, pzFile, line, oMsg.getStr());
-}
+#ifndef INCLUDED_JFW_PLUGIN_DIAGNOSTICS_HXX
+#define INCLUDED_JFW_PLUGIN_DIAGNOSTICS_HXX
 
-inline void jfw_warning2(bool condition, const sal_Char * pzFile, sal_Int32 line,
-                         sal_Char * pzMessage)
-{
-    if (! condition)
-        fprintf(
-            stderr, "%s\n File: %s\n Line: %ld", pzMessage, pzFile,
-            sal::static_int_cast< unsigned long >(line));
-}
+#include "sal/config.h"
 
-inline void jfw_trace(rtl::OUString message)
-{
-    rtl::OString oMsg = rtl::OUStringToOString(message, osl_getThreadTextEncoding());
-    fprintf(stderr,"%s", oMsg.getStr());
-}
+#include "rtl/oustringostreaminserter.hxx"
+#include "sal/log.h"
 
-inline void jfw_trace(const sal_Char * pzMessage)
-{
-    if (pzMessage)
-        fprintf(stderr,"%s", pzMessage);
-}
+#define JFW_ENSURE(c, m) SAL_WARN_IF_S(!(c), "jfw", m)
 
-inline void jfw_trace(const rtl::OString& message)
-{
-    if (message.getLength() > 0)
-        fprintf(stderr,"%s", message.getStr());
-}
+#define JFW_TRACE0(m) SAL_INFO_S("jfw.level1", m)
 
-}
+#define JFW_TRACE2(m) SAL_INFO_S("jfw.level2", m);
 
 #endif
 
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
index 00843ec..1b2dd23 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
@@ -70,7 +70,6 @@ using ::rtl::OString;
 using ::rtl::OUStringBuffer;
 using ::rtl::OUStringToOString;
 
-#define CHAR_POINTER(oustr) ::rtl::OUStringToOString(oustr,RTL_TEXTENCODING_UTF8).pData->buffer
 #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
 #ifdef WNT
 #define HKEY_SUN_JRE L"Software\\JavaSoft\\Java Runtime Environment"
@@ -310,14 +309,13 @@ class AsynchReader: public Thread
 public:
 
     AsynchReader(oslFileHandle & rHandle);
-#if OSL_DEBUG_LEVEL >= 2
+
     /** only call this function after this thread has finished.
 
         That is, call join on this instance and then call getData.
 
      */
     OString getData();
-#endif
 };
 
 AsynchReader::AsynchReader(oslFileHandle & rHandle):
@@ -325,13 +323,11 @@ AsynchReader::AsynchReader(oslFileHandle & rHandle):
 {
 }
 
-#if OSL_DEBUG_LEVEL >= 2
 OString AsynchReader::getData()
 {
     OSL_ASSERT(isRunning() == sal_False );
     return OString(m_arData.get(), m_nDataSize);
 }
-#endif
 
 void AsynchReader::run()
 {
@@ -469,8 +465,7 @@ bool getJavaProps(const OUString & exePath,
         OUString sLine;
         if (!decodeOutput(aLine, &sLine))
             continue;
-        JFW_TRACE2(OString("[Java framework]:\" ")
-               + OString( CHAR_POINTER(sLine)) + OString(" \".\n"));
+        JFW_TRACE2("[Java framework]:\" " << sLine << " \".\n");
         sLine = sLine.trim();
         if (sLine.getLength() == 0)
             continue;
@@ -497,8 +492,8 @@ bool getJavaProps(const OUString & exePath,
 
     //process error stream data
     stderrReader.join();
-    JFW_TRACE2(OString("[Java framework]  Java wrote to stderr:\" ")
-               + stderrReader.getData() + OString(" \".\n"));
+    JFW_TRACE2("[Java framework]  Java wrote to stderr:\" "
+               << stderrReader.getData().getStr() << " \".\n");
 
     TimeValue waitMax= {5 ,0};
     procErr = osl_joinProcessWithTimeout(javaProcess, &waitMax);
diff --git a/sal/inc/osl/diagnose.h b/sal/inc/osl/diagnose.h
index aab76b3..09aab4d 100644
--- a/sal/inc/osl/diagnose.h
+++ b/sal/inc/osl/diagnose.h
@@ -30,10 +30,25 @@
 #ifndef _OSL_DIAGNOSE_H_
 #define _OSL_DIAGNOSE_H_
 
+#include "sal/config.h"
+
+#include <sal/log.h>
 #include <sal/types.h>
 
 /** provides simple diagnostic support
 
+    The facilities provided by this header are deprecated.  True assertions
+    (that detect broken program logic) should use standard assert (which aborts
+    if an assertion fails, and is controlled by the standard NDEBUG macro).
+    Logging of warnings (e.g., about malformed input) and traces (e.g., about
+    steps taken while executing some protocol) should use the facilities
+    provided by sal/log.h.
+
+    Because the assertion macros (OSL_ASSERT, OSL_ENSURE, OSL_FAIL, OSL_PRECOND,
+    and OSL_POSTCOND) have been used for true assertions as well as for logged
+    warnings, they map to SAL_WARN instead of standard assert.  OSL_TRACE maps
+    to SAL_INFO.
+
     The functions defined in this header are not intended to be used directly,
     but through defined macros. The macros can be divided into three categories:
     assertions, traces and other stuff .-) Their usability depends on the value
@@ -122,14 +137,17 @@ pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc( 
pf
 
 #define OSL_THIS_FILE       __FILE__
 
-/* the macro OSL_LOG_PREFIX is intended to be an office internal macro for now */
-#define OSL_LOG_PREFIX OSL_THIS_FILE ":" SAL_STRINGIFY( __LINE__ ) "; "
+/* the macro OSL_LOG_PREFIX is intended to be an office internal macro for now
+
+   it is deprecated and superseded by SAL_WHERE
+*/
+#define OSL_LOG_PREFIX SAL_WHERE
 
 #define OSL_DEBUG_ONLY(s)   _OSL_DEBUG_ONLY(s)
-#define OSL_TRACE           _OSL_TRACE
-#define OSL_ASSERT(c)       _OSL_ENSURE(c, OSL_THIS_FILE, __LINE__, 0)
-#define OSL_ENSURE(c, m)   _OSL_ENSURE(c, OSL_THIS_FILE, __LINE__, m)
-#define OSL_FAIL(m)        _OSL_ENSURE(0, OSL_THIS_FILE, __LINE__, m)
+#define OSL_TRACE(...) SAL_INFO("legacy.osl", __VA_ARGS__)
+#define OSL_ASSERT(c) SAL_WARN_IF(!(c), "legacy.osl", "OSL_ASSERT")
+#define OSL_ENSURE(c, m) SAL_WARN_IF(!(c), "legacy.osl", "%s", m)
+#define OSL_FAIL(m) SAL_WARN_IF(sal_True, "legacy.osl", "%s", m)
 
 #define OSL_VERIFY(c) do { if (!(c)) OSL_ASSERT(0); } while (0)
 #define OSL_PRECOND(c, m)   OSL_ENSURE(c, m)
@@ -145,27 +163,10 @@ pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc( 
pf
 #if OSL_DEBUG_LEVEL > 0
 
 #define _OSL_DEBUG_ONLY(f)  (f)
-#define _OSL_ENSURE(c, f, l, m) \
-    do \
-    {  \
-        if (!(c) && _OSL_GLOBAL osl_assertFailedLine(f, l, m)) \
-            _OSL_GLOBAL osl_breakDebug(); \
-    } while (0)
 
 #else
 
 #define _OSL_DEBUG_ONLY(f)          ((void)0)
-#define _OSL_ENSURE(c, f, l, m)     ((void)0)
-
-#endif /* OSL_DEBUG_LEVEL */
-
-#if OSL_DEBUG_LEVEL > 1
-
-#define _OSL_TRACE                  _OSL_GLOBAL osl_trace
-
-#else
-
-#define _OSL_TRACE                  1 ? ((void)0) : _OSL_GLOBAL osl_trace
 
 #endif /* OSL_DEBUG_LEVEL */
 
@@ -192,30 +193,6 @@ pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc( 
pf
 #define OSL_THIS_FUNC ""
 #endif
 
-#if defined __cplusplus
-
-#include "rtl/string.hxx"
-
-/** @internal */
-extern "C" struct _rtl_String * SAL_CALL osl_detail_formatString(
-    char const * format, ...) SAL_THROW_EXTERN_C();
-    // "struct _rtl_String" instead of "rtl_String" for the case where
-    // osl/diagnose.h is included in rtl/string.hxx
-
-/** A facility for printf-style messages in OSL_ENSURE, OSL_FAIL, etc.
-
-    Use like: OSL_ENSURE(i == 5, OSL_FORMAT("i should be 5 but is %d", i));
-*/
-#define OSL_FORMAT(format, ...) \
-    (::rtl::OString( \
-        ::osl_detail_formatString(format, __VA_ARGS__), \
-        ::SAL_NO_ACQUIRE).getStr())
-    // it appears that all relevant compilers (esp. GCC 4.0 and MS VS 2008
-    // Express) already support variadic macros in C++; see also
-    // <http://wiki.apache.org/stdcxx/C++0xCompilerSupport>
-
-#endif
-
 #endif /* _OSL_DIAGNOSE_H_ */
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/inc/osl/diagnose.hxx b/sal/inc/osl/diagnose.hxx
index a9aba13..42e4b8d 100644
--- a/sal/inc/osl/diagnose.hxx
+++ b/sal/inc/osl/diagnose.hxx
@@ -25,27 +25,22 @@
  * for a copy of the LGPLv3 License.
  *
  ************************************************************************/
-#if ! defined(OSL_DIAGNOSE_HXX_INCLUDED)
+#ifndef OSL_DIAGNOSE_HXX_INCLUDED
 #define OSL_DIAGNOSE_HXX_INCLUDED
 
-#if ! defined(_OSL_DIAGNOSE_H_)
+#include "sal/config.h"
+
+#include <functional>
+#include <typeinfo>
+
+#include "boost/unordered_set.hpp"
 #include "osl/diagnose.h"
-#endif
-#if ! defined(_OSL_INTERLOCK_H_)
 #include "osl/interlck.h"
-#endif
-#if ! defined(_OSL_MUTEX_HXX_)
 #include "osl/mutex.hxx"
-#endif
-#if ! defined(INCLUDED_RTL_ALLOCATOR_HXX)
 #include "rtl/allocator.hxx"
-#endif
-#if ! defined(_RTL_INSTANCE_HXX_)
 #include "rtl/instance.hxx"
-#endif
-#include <boost/unordered_set.hpp>
-#include <functional>
-#include <typeinfo>
+#include "sal/log.h"
+#include "sal/types.h"
 
 namespace osl {
 /// @internal
@@ -126,7 +121,7 @@ public:
             VoidPointerSet::const_iterator iPos(m_data.m_addresses.begin());
             VoidPointerSet::const_iterator const iEnd(m_data.m_addresses.end());
             for ( ; iPos != iEnd; ++iPos ) {
-                OSL_ASSERT( *iPos != 0 );
+                SAL_WARN_IF( *iPos == 0, "sal.debug", "null pointer" );
             }
         }
         return bRet;
@@ -179,7 +174,7 @@ public:
     static bool checkObjectCount( ::std::size_t = 0 ) { return true; }
 #else // OSL_DEBUG_LEVEL > 0
     /** @return whether the expected number of objects is alive,
-                else this function OSL_ASSERTs
+                else this function SAL_WARNs
     */
     static bool checkObjectCount( ::std::size_t nExpected = 0 ) {
         return StaticObjectRegistry::get().checkObjectCount(nExpected);
diff --git a/sal/inc/osl/thread.hxx b/sal/inc/osl/thread.hxx
index 2bcc82f..2916ff7 100644
--- a/sal/inc/osl/thread.hxx
+++ b/sal/inc/osl/thread.hxx
@@ -29,7 +29,9 @@
 #ifndef _THREAD_HXX_
 #define _THREAD_HXX_
 
-#ifdef __cplusplus
+#include "sal/config.h"
+
+#include <cassert>
 
 #include <osl/time.h>
 
@@ -71,7 +73,7 @@ public:
 
     sal_Bool SAL_CALL create()
     {
-        OSL_ASSERT(m_hThread == 0); // only one running thread per instance
+        assert(m_hThread == 0); // only one running thread per instance
            if (m_hThread)
             return sal_False;
 
@@ -84,7 +86,7 @@ public:
 
     sal_Bool SAL_CALL createSuspended()
     {
-        OSL_ASSERT(m_hThread == 0); // only one running thread per instance
+        assert(m_hThread == 0); // only one running thread per instance
         if( m_hThread)
             return sal_False;
         m_hThread= osl_createSuspendedThread( threadFunc,
@@ -233,7 +235,7 @@ private:
 };
 
 } // end namespace osl
-#endif
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/inc/rtl/oustringostreaminserter.hxx b/sal/inc/rtl/oustringostreaminserter.hxx
new file mode 100644
index 0000000..991d6a0
--- /dev/null
+++ b/sal/inc/rtl/oustringostreaminserter.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org.  If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#ifndef INCLUDED_RTL_OUSTRINGOSTREAMINSERTER_HXX
+#define INCLUDED_RTL_OUSTRINGOSTREAMINSERTER_HXX
+
+#include "sal/config.h"
+
+#include <ostream>
+
+#include "osl/thread.h"
+#include "rtl/ustring.hxx"
+
+/** Include this header to support rtl::OUString in std::ostream (and thus in
+    CPPUNIT_ASSERT macros, for example)
+
+    @since LibreOffice 3.5.
+*/
+
+namespace rtl {
+
+template< typename charT, typename traits > std::basic_ostream<charT, traits> &
+operator <<(
+    std::basic_ostream<charT, traits> & stream, rtl::OUString const & string)
+{
+    return stream <<
+        rtl::OUStringToOString(string, osl_getThreadTextEncoding()).getStr();
+        // best effort; potentially loses data due to conversion failures and
+        // embedded null characters
+}
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/inc/rtl/strbuf.hxx b/sal/inc/rtl/strbuf.hxx
index 962d3df..5f0b9b3 100644
--- a/sal/inc/rtl/strbuf.hxx
+++ b/sal/inc/rtl/strbuf.hxx
@@ -29,7 +29,10 @@
 #ifndef _RTL_STRBUF_HXX_
 #define _RTL_STRBUF_HXX_
 
-#include "osl/diagnose.h"
+#include "sal/config.h"
+
+#include <cassert>
+
 #include <rtl/strbuf.h>
 #include <rtl/string.hxx>
 
@@ -253,7 +256,7 @@ public:
      */
     void setLength(sal_Int32 newLength)
     {
-        OSL_ASSERT(newLength >= 0);
+        assert(newLength >= 0);
         // Avoid modifications if pData points to const empty string:
         if( newLength != pData->length )
         {
@@ -280,7 +283,7 @@ public:
      */
     sal_Char charAt( sal_Int32 index )
     {
-        OSL_ASSERT(index >= 0 && index < pData->length);
+        assert(index >= 0 && index < pData->length);
         return pData->buffer[ index ];
     }
 
@@ -321,7 +324,7 @@ public:
      */
     OStringBuffer & setCharAt(sal_Int32 index, sal_Char ch)
     {
-        OSL_ASSERT(index >= 0 && index < pData->length);
+        assert(index >= 0 && index < pData->length);
         pData->buffer[ index ] = ch;
         return *this;
     }
diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx
index ee41011..007129a 100644
--- a/sal/inc/rtl/string.hxx
+++ b/sal/inc/rtl/string.hxx
@@ -29,12 +29,15 @@
 #ifndef _RTL_STRING_HXX_
 #define _RTL_STRING_HXX_
 
-#ifdef __cplusplus
+#include "sal/config.h"
+
+#include <cassert>
 
 #include <osl/diagnose.h>
 #include <rtl/memory.h>
 #include <rtl/textenc.h>
 #include <rtl/string.h>
+#include "sal/log.h"
 
 #if !defined EXCEPTIONS_OFF
 #include <new>
@@ -183,13 +186,13 @@ public:
     {
         pData = 0;
         rtl_uString2String( &pData, value, length, encoding, convertFlags );
+        if (pData == 0) {
 #if defined EXCEPTIONS_OFF
-        OSL_ASSERT(pData != NULL);
+            SAL_WARN("sal", "std::bad_alloc but EXCEPTIONS_OFF");
 #else
-        if (pData == 0) {
             throw std::bad_alloc();
-        }
 #endif
+        }
     }
 
     /**
@@ -655,7 +658,7 @@ public:
     */
     OString copy( sal_Int32 beginIndex ) const SAL_THROW(())
     {
-        OSL_ASSERT(beginIndex >= 0 && beginIndex <= getLength());
+        assert(beginIndex >= 0 && beginIndex <= getLength());
         if ( beginIndex == 0 )
             return *this;
         else
@@ -679,8 +682,8 @@ public:
     */
     OString copy( sal_Int32 beginIndex, sal_Int32 count ) const SAL_THROW(())
     {
-        OSL_ASSERT(beginIndex >= 0 && beginIndex <= getLength()
-                   && count >= 0 && count <= getLength() - beginIndex);
+        assert(beginIndex >= 0 && beginIndex <= getLength()
+               && count >= 0 && count <= getLength() - beginIndex);
         if ( (beginIndex == 0) && (count == getLength()) )
             return *this;
         else
@@ -1034,8 +1037,6 @@ struct OStringHash
 
 } /* Namespace */
 
-#endif /* __cplusplus */
-
 #endif /* _RTL_STRING_HXX_ */
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx
index 60bb750..2456316 100644
--- a/sal/inc/rtl/ustrbuf.hxx
+++ b/sal/inc/rtl/ustrbuf.hxx
@@ -29,12 +29,14 @@
 #ifndef _RTL_USTRBUF_HXX_
 #define _RTL_USTRBUF_HXX_
 
+#include "sal/config.h"
+
+#include <cassert>
+
 #include <osl/diagnose.h>
 #include <rtl/ustrbuf.h>
 #include <rtl/ustring.hxx>
 
-#ifdef __cplusplus
-
 namespace rtl
 {
 
@@ -233,7 +235,7 @@ public:
      */
     void setLength(sal_Int32 newLength)
     {
-        OSL_ASSERT(newLength >= 0);
+        assert(newLength >= 0);
         // Avoid modifications if pData points to const empty string:
         if( newLength != pData->length )
         {
@@ -260,7 +262,7 @@ public:
      */
     sal_Unicode charAt( sal_Int32 index ) const
     {
-        OSL_ASSERT(index >= 0 && index < pData->length);
+        assert(index >= 0 && index < pData->length);
         return pData->buffer[ index ];
     }
 
@@ -301,7 +303,7 @@ public:
      */
     OUStringBuffer & setCharAt(sal_Int32 index, sal_Unicode ch)
     {
-        OSL_ASSERT(index >= 0 && index < pData->length);
+        assert(index >= 0 && index < pData->length);
         pData->buffer[ index ] = ch;
         return *this;
     }
@@ -434,7 +436,7 @@ public:
      */
     OUStringBuffer & append(char c)
     {
-        OSL_ASSERT(static_cast< unsigned char >(c) <= 0x7F);
+        assert(static_cast< unsigned char >(c) <= 0x7F);
         return append(sal_Unicode(c));
     }
 
@@ -819,7 +821,6 @@ private:
 
 }
 
-#endif  /* __cplusplus */
 #endif  /* _RTL_USTRBUF_HXX_ */
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx
index edf7c97..ef13dd1 100644
--- a/sal/inc/rtl/ustring.hxx
+++ b/sal/inc/rtl/ustring.hxx
@@ -29,12 +29,15 @@
 #ifndef _RTL_USTRING_HXX_
 #define _RTL_USTRING_HXX_
 
-#ifdef __cplusplus
+#include "sal/config.h"
+
+#include <cassert>
 
 #include "osl/diagnose.h"
 #include <rtl/ustring.h>
 #include <rtl/string.hxx>
 #include <rtl/memory.h>
+#include "sal/log.h"
 
 #if defined EXCEPTIONS_OFF
 #include <stdlib.h>
@@ -184,13 +187,13 @@ public:
     {
         pData = 0;
         rtl_string2UString( &pData, value, length, encoding, convertFlags );
+        if (pData == 0) {
 #if defined EXCEPTIONS_OFF
-        OSL_ASSERT(pData != NULL);
+            SAL_WARN("sal", "std::bad_alloc but EXCEPTIONS_OFF");
 #else
-        if (pData == 0) {
             throw std::bad_alloc();
-        }
 #endif
+        }
     }
 
     /** Create a new string from an array of Unicode code points.
@@ -967,7 +970,7 @@ public:
     */
     OUString copy( sal_Int32 beginIndex ) const SAL_THROW(())
     {
-        OSL_ASSERT(beginIndex >= 0 && beginIndex <= getLength());
+        assert(beginIndex >= 0 && beginIndex <= getLength());
         if ( beginIndex == 0 )
             return *this;
         else
@@ -991,7 +994,7 @@ public:
     */
     OUString copy( sal_Int32 beginIndex, sal_Int32 count ) const SAL_THROW(())
     {
-        OSL_ASSERT(beginIndex >= 0 && beginIndex <= getLength() && count >= 0);
+        assert(beginIndex >= 0 && beginIndex <= getLength() && count >= 0);
         if ( (beginIndex == 0) && (count == getLength()) )
             return *this;
         else
@@ -1243,13 +1246,13 @@ public:
     {
         rtl_uString * pNew = 0;
         rtl_uString_intern( &pNew, pData );
+        if (pNew == 0) {
 #if defined EXCEPTIONS_OFF
-        OSL_ASSERT(pNew != NULL);
+            SAL_WARN("sal", "std::bad_alloc but EXCEPTIONS_OFF");
 #else
-        if (pNew == 0) {
             throw std::bad_alloc();
-        }
 #endif
+        }
         return OUString( pNew, (DO_NOT_ACQUIRE *)0 );
     }
 
@@ -1286,13 +1289,13 @@ public:
         rtl_uString * pNew = 0;
         rtl_uString_internConvert( &pNew, value, length, encoding,
                                    convertFlags, pInfo );
+        if (pNew == 0) {
 #if defined EXCEPTIONS_OFF
-        OSL_ASSERT(pNew != NULL);
+            SAL_WARN("sal", "std::bad_alloc but EXCEPTIONS_OFF");
 #else
-        if (pNew == 0) {
             throw std::bad_alloc();
-        }
 #endif
+        }
         return OUString( pNew, (DO_NOT_ACQUIRE *)0 );
     }
 
@@ -1576,8 +1579,6 @@ inline OString OUStringToOString( const OUString & rUnicode,
 
 } /* Namespace */
 
-#endif /* __cplusplus */
-
 #endif /* _RTL_USTRING_HXX */
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/inc/sal/log.h b/sal/inc/sal/log.h
new file mode 100644
index 0000000..51378ab
--- /dev/null
+++ b/sal/inc/sal/log.h
@@ -0,0 +1,304 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * [ Copyright (C) 2011 Stephan Bergmann, Red Hat <sbergman@redhat.com> (initial
+ *   developer) ]
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef INCLUDED_SAL_LOG_H
+#define INCLUDED_SAL_LOG_H
+
+#include "sal/config.h"
+
+#if defined __cplusplus
+#include <sstream>
+#include <string>
+#endif
+
+#include "sal/types.h"
+
+/* This header uses variadic macros in both C (where they are officially only
+   supported since C99) and C++ (where they are officially only supported since
+   C++11).  It appears that all relevant compilers (esp. GCC 4.0 and MS VS 2008
+   Express) already support them in their C and C++ dialects.  See also
+   <http://wiki.apache.org/stdcxx/C++0xCompilerSupport>.
+
+   Avoid the use of other sal code in this header as much as possible, so that
+   this code can be called from other sal code without causing endless
+   recursion.
+*/
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+/** @internal */
+enum sal_detail_LogLevel {
+    SAL_DETAIL_LOG_LEVEL_INFO, SAL_DETAIL_LOG_LEVEL_WARN,
+    SAL_DETAIL_MAKE_FIXED_SIZE = SAL_MAX_ENUM
+};
+
+/** @internal */
+void SAL_CALL sal_detail_log(
+    enum sal_detail_LogLevel level, char const * area, char const * where,
+    char const * message);
+
+/** @internal */
+void SAL_CALL sal_detail_logFormat(
+    enum sal_detail_LogLevel level, char const * area, char const * where,
+    char const * format, ...)
+/* TODO: enabling this will produce a huge amount of -Werror=format errors: */
+#if defined GCC && 0
+    __attribute__((format(printf, 4, 5)))
+#endif
+    ;
+
+#if defined __cplusplus
+}
+#endif
+
+/** @internal */
+#define SAL_DETAIL_LOG_FORMAT(condition, level, area, where, ...) \
+    do { \
+        if (condition) { \
+            sal_detail_logFormat((level), (area), (where), __VA_ARGS__); \
+        } \
+    } while (sal_False)
+
+#if defined __cplusplus
+
+namespace sal { namespace detail {
+
+/// @internal
+inline void SAL_CALL log(
+    sal_detail_LogLevel level, char const * area, char const * where,
+    std::ostringstream const & stream)
+{
+    // An alternative would be to have sal_detail_log take a std::ostringstream
+    // pointer (via a C void pointer); the advantage would be smaller client
+    // code (the ".str().c_str()" part would move into the implementation of
+    // sal_detail_log) and potential for proper support of embedded null
+    // characters within the message, but the disadvantage would be dependence
+    // on the C++ ABI; as a compromise, the ".str().c_str()" part has been moved
+    // to this inline function so that it is potentially only emitted once per
+    // dynamic library:
+    sal_detail_log(level, area, where, stream.str().c_str());
+}
+
+} }
+
+/// @internal
+#define SAL_DETAIL_LOG_STREAM(condition, level, area, where, stream) \
+    do { \
+        if (condition) { \
+            ::std::ostringstream sal_detail_stream; \
+            sal_detail_stream << stream; \
+            ::sal::detail::log((level), (area), (where), sal_detail_stream); \
+        } \
+    } while (false)
+
+#endif
+
+/** A simple macro to create a "file and line number" string.
+
+    Potentially not only useful within the log framework (where it is used
+    automatically), but also when creating exception messages.
+
+    @since LibreOffice 3.5
+*/
+#define SAL_WHERE __FILE__ ":" SAL_STRINGIFY(__LINE__) ": "
+
+#if defined __cplusplus
+
+/** A facility for generating temporary string messages by piping items into a
+    C++ std::ostringstream.
+
+    This can be useful for example in a call to SAL_INFO_S when depending on
+    some boolean condition data of incompatible types shall be streamed into the
+    message, as in:
+
+      SAL_INFO_S(
+        "foo", "object: " << (hasName ? obj->name : SAL_STREAM(obj)));
+
+    @since LibreOffice 3.5
+*/
+#define SAL_STREAM(stream) \
+    (dynamic_cast< ::std::ostringstream & >(::std::ostringstream() << stream). \
+     str())
+#endif
+
+/** Basic logging functionality.
+
+    SAL_INFO(char const * area, char const * format, ...),
+    SAL_INFO_IF(bool condition, char const * area, char const * format, ...),
+    SAL_WARN(char const * area, char const * format, ...), and
+    SAL_WARN_IF(bool condition, char const * area, char const * format, ...)
+    produce an info resp. warning log entry with a printf-style message.  The
+    given format argument and any following arguments must be so that that
+    sequence of arguments would be appropriate for a call to printf.
+
+    SAL_INFO_S(char const * area, expr),
+    SAL_INFO_IF_S(bool condition, char const * area, expr),
+    SAL_WARN_S(char const * area, expr), and
+    SAL_WARN_IF_S(bool condition, char const * area, expr) produce an info resp.
+    warning log entry with a message produced by piping items into a C++
+    std::ostringstream (and are only available in C++).  The given expr must be
+    so that the full expression "stream << expr" is valid, where stream is a
+    variable of type std::ostringstream.
+
+      SAL_INFO_S("foo", "string " << s << " of length " << n)
+
+    would be an example of such a call; if the given s is of type rtl::OUString,
+
+      #include "rtl/oustringostreaminserter.hxx"
+
+    would make sure that an appropriate operator << is available.
+
+    For the _IF variants, log output is only generated if the given condition is
+    true (in addition to the other conditions that have to be met).
+
+    For all these macros, the given area argument must be non-null and must
+    match the regular expression
+
+      <area> ::= <subarea>("."<subarea>)*
+
+    with
+
+      <subarea> ::= [0-9a-z]+
+
+    Whether these macros generate any log output is controlled in a two-stage
+    process.
+
+    First, at compile time the macro SAL_LOG_LEVEL controls whether these macros
+    expand to actual code, or to no-ops.  SAL_LOG_LEVEL must expand to an
+    integral value 0, 1, or 2.
+
+    If SAL_LOG_LEVEL is 0, neither the INFO nor the WARN macros produce code.
+    If SAL_LOG_LEVEL is 1, only the WARN macros produce code.  If SAL_LOG_LEVEL
+    is 2, both the INFO and the WARN macros produce code.
+
+    Second, at runtime the environment variable SAL_LOG further limits which
+    macro calls actually generate log output.  The environment varialbe SAL_LOG
+    must either be unset or must match the regular expression
+
+      <env> ::= <switch>*
+
+    with
+
+      <switch> ::= <sense><level><area>?
+      <sense> ::= "+"|"-"
+      <level> ::= "INFO"|"WARN"
+
+    If the environment variable is unset, "+WARN" is used instead (which results
+    in all warnings being output but no infos).  If the given value does not
+    match the regular expression, "+INFO+WARN" is used instead (which in turn
+    results in everything being output).
+
+    A given macro call's level (INFO or WARN) and area is matched against the
+    given switches as follows:  Only those switches for which the level matches
+    the given level and for which the area is a prefix (including both empty and
+    full prefixes) of the given area are considered.  Log output is generated if
+    and only if among the longest such switches (if any), there is at least one
+    that has a sense of "+".  (That is, if both +WARN.foo and -WARN.foo are
+    present, +WARN.foo wins.)
+
+    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
+    SAL_INFO("foo", ...) or SAL_INFO("foo.barzzz", ...) do not.
+
+    The generated log output consists of the given level ("info" or "warn"), the
+    given area, the process ID, the thread ID, the source file, and the source
+    line number, each followed by a colon, followed by a space, the given
+    message, and a newline.  The given message should contain no vertical
+    formatting characters and no null characters.  The precise format of the log
+    output is subject to change.  The log output is printed to stderr.
+
+    @since LibreOffice 3.5
+*/
+
+#if SAL_LOG_LEVEL >= 2
+
+#define SAL_INFO(area, ...) \
+    SAL_DETAIL_LOG_FORMAT( \
+        sal_True, SAL_DETAIL_LOG_LEVEL_INFO, area, SAL_WHERE, __VA_ARGS__)
+#define SAL_INFO_IF(condition, area, ...) \
+    SAL_DETAIL_LOG_FORMAT( \
+        condition, SAL_DETAIL_LOG_LEVEL_INFO, area, SAL_WHERE, __VA_ARGS__)
+
+#if defined __cplusplus
+#define SAL_INFO_S(area, stream) \
+    SAL_DETAIL_LOG_STREAM( \
+        true, ::SAL_DETAIL_LOG_LEVEL_INFO, area, SAL_WHERE, stream)
+#define SAL_INFO_IF_S(condition, area, stream)  \
+    SAL_DETAIL_LOG_STREAM( \
+        condition, ::SAL_DETAIL_LOG_LEVEL_INFO, area, SAL_WHERE, stream)
+#endif
+
+#else
+
+#define SAL_INFO(area, format, ...) ((void) 0)
+#define SAL_INFO_IF(condition, area, format, ...) ((void) 0)
+
+#if defined __cplusplus
+#define SAL_INFO_S(area, stream) ((void) 0)
+#define SAL_INFO_IF_S(condition, area, stream) ((void) 0)
+#endif
+
+#endif
+
+#if SAL_LOG_LEVEL >= 1
+
+#define SAL_WARN(area, ...) \
+    SAL_DETAIL_LOG_FORMAT( \
+        sal_True, SAL_DETAIL_LOG_LEVEL_WARN, area, SAL_WHERE, __VA_ARGS__)
+#define SAL_WARN_IF(condition, area, ...) \
+    SAL_DETAIL_LOG_FORMAT( \
+        condition, SAL_DETAIL_LOG_LEVEL_WARN, area, SAL_WHERE, __VA_ARGS__)
+
+#if defined __cplusplus
+#define SAL_WARN_S(area, stream) \
+    SAL_DETAIL_LOG_STREAM( \
+        true, ::SAL_DETAIL_LOG_LEVEL_WARN, area, SAL_WHERE, stream)
+#define SAL_WARN_IF_S(condition, area, stream)   \
+    SAL_DETAIL_LOG_STREAM( \
+        condition, ::SAL_DETAIL_LOG_LEVEL_WARN, area, SAL_WHERE, stream)
+#endif
+
+#else
+
+#define SAL_WARN(area, format, ...) ((void) 0)
+#define SAL_WARN_IF(condition, area, format, ...) ((void) 0)
+
+#if defined __cplusplus
+#define SAL_WARN_S(area, stream) ((void) 0)
+#define SAL_WARN_IF_S(condition, area, stream) ((void) 0)
+#endif
+
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/all/formatstring.cxx b/sal/osl/all/formatstring.cxx
deleted file mode 100644
index 9fefa2f..0000000
--- a/sal/osl/all/formatstring.cxx
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * [ Copyright (C) 2011 Stephan Bergmann, Red Hat Inc. <sbergman@redhat.com>
- *   (initial developer) ]
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include "precompiled_sal.hxx"
-#include "sal/config.h"
-
-#include <cstdarg>
-#include <cstring>
-#include <stdio.h> // vsnprintf not in C++03 <cstdio>, only C99 <stdio.h>
-
-#include "osl/diagnose.h"
-#include "rtl/string.h"
-#include "rtl/string.hxx"
-
-rtl_String * osl_detail_formatString(char const * format, ...)
-    SAL_THROW_EXTERN_C()
-{
-    // Avoid the use of other sal code as much as possible, so that this code
-    // can be called from other sal code without causing endless recursion:
-    char buf[1024];
-    int n1 = sizeof buf - RTL_CONSTASCII_LENGTH("...");
-    std::va_list args;
-    va_start(args, format);
-    int n2 = vsnprintf(buf, n1, format, args);
-    va_end(args);
-    if (n2 < 0) {
-        std::strcpy(buf, "???");
-        n2 = RTL_CONSTASCII_LENGTH("???");
-    } else if (n2 >= n1) {
-        std::strcpy(buf + n1 - 1, "...");
-        n2 = sizeof buf - 1;
-    }
-    rtl::OString s(buf, n2);
-    rtl_string_acquire(s.pData);
-    return s.pData;
-}
diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
new file mode 100644
index 0000000..be45cf6
--- /dev/null
+++ b/sal/osl/all/log.cxx
@@ -0,0 +1,199 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * [ Copyright (C) 2011 Stephan Bergmann, Red Hat <sbergman@redhat.com> (initial
+ *   developer) ]
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "precompiled_sal.hxx"
+#include "sal/config.h"
+
+#include <cassert>
+#include <cstdarg>
+#include <cstddef>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <sstream>
+
+#include <stdio.h> // vsnprintf
+
+#include "osl/thread.hxx"
+#include "rtl/string.h"
+#include "sal/log.h"
+#include "sal/types.h"
+
+#include "logformat.hxx"
+
+#if defined WNT
+#include <process.h>
+#define OSL_DETAIL_GETPID _getpid()
+#else
+#include <unistd.h>
+#define OSL_DETAIL_GETPID getpid()
+#endif
+
+// Avoid the use of other sal code in this file as much as possible, so that
+// this code can be called from other sal code without causing endless
+// recursion.
+
+namespace {
+
+bool equalStrings(
+    char const * string1, std::size_t length1, char const * string2,
+    std::size_t length2)
+{
+    return length1 == length2 && std::memcmp(string1, string2, length1) == 0;
+}
+
+char const * toString(sal_detail_LogLevel level) {
+    switch (level) {
+    default:
+        assert(false); // this cannot happen
+        // fall through
+    case SAL_DETAIL_LOG_LEVEL_INFO:
+        return "info";
+    case SAL_DETAIL_LOG_LEVEL_WARN:
+        return "warn";
+    }
+}
+
+bool report(sal_detail_LogLevel level, char const * area) {
+    assert(area != 0);
+    char const * env = std::getenv("SAL_LOG");
+    if (env == 0) {
+        env = "+WARN";
+    }
+    std::size_t areaLen = std::strlen(area);
+    enum Sense { POSITIVE = 0, NEGATIVE = 1 };
+    std::size_t senseLen[2] = { 0, 1 };
+        // initial senseLen[POSITIVE] < senseLen[NEGATIVE], so that if there are
+        // 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)
+    for (char const * p = env;;) {
+        Sense sense;
+        switch (*p++) {
+        case '\0':
+            return senseLen[POSITIVE] >= senseLen[NEGATIVE];
+                // if a specific item is both postiive and negative
+                // (senseLen[POSITIVE] == senseLen[NEGATIVE]), default to
+                // positive
+        case '+':
+            sense = POSITIVE;
+            break;
+        case '-':
+            sense = NEGATIVE;
+            break;
+        default:
+            return true; // upon an illegal SAL_LOG value, enable everything
+        }
+        char const * p1 = p;
+        while (*p1 != '.' && *p1 != '+' && *p1 != '-' && *p1 != '\0') {
+            ++p1;
+        }
+        bool match;
+        if (equalStrings(p, p1 - p, RTL_CONSTASCII_STRINGPARAM("INFO"))) {
+            match = level == SAL_DETAIL_LOG_LEVEL_INFO;
+        } else if (equalStrings(p, p1 - p, RTL_CONSTASCII_STRINGPARAM("WARN")))
+        {
+            match = level == SAL_DETAIL_LOG_LEVEL_WARN;
+        } else {
+            return true;
+                // upon an illegal SAL_LOG value, everything is considered
+                // positive
+        }
+        char const * p2 = p1;
+        while (*p2 != '+' && *p2 != '-' && *p2 != '\0') {
+            ++p2;
+        }
+        if (match) {
+            if (*p1 == '.') {
+                ++p1;
+                std::size_t n = p2 - p1;
+                if ((n == areaLen && equalStrings(p1, n, area, areaLen))
+                    || (n < areaLen && area[n] == '.'
+                        && equalStrings(p1, n, area, n)))
+                {
+                    senseLen[sense] = p2 - p;
+                }
+            } else {
+                senseLen[sense] = p1 - p;
+            }
+        }
+        p = p2;
+    }
+}
+
+void log(
+    sal_detail_LogLevel level, char const * area, char const * where,
+    char const * message)
+{
+    std::ostringstream s;
+    s << toString(level) << ':' << area << ':' << OSL_DETAIL_GETPID << ':'
+        << osl::Thread::getCurrentIdentifier() << ':' << where << message
+        << '\n';
+    std::fputs(s.str().c_str(), stderr);
+}
+
+}
+
+void sal_detail_log(
+    sal_detail_LogLevel level, char const * area, char const * where,
+    char const * message)
+{
+    if (report(level, area)) {
+        log(level, area, where, message);
+    }
+}
+
+void sal_detail_logFormat(
+    sal_detail_LogLevel level, char const * area, char const * where,
+    char const * format, ...)
+{
+    if (report(level, area)) {
+        std::va_list args;
+        va_start(args, format);
+        osl::detail::logFormat(level, area, where, format, args);
+        va_end(args);
+    }
+}
+
+void osl::detail::logFormat(
+    sal_detail_LogLevel level, char const * area, char const * where,
+    char const * format, std::va_list arguments)
+{
+    char buf[1024];
+    int const len = sizeof buf - RTL_CONSTASCII_LENGTH("...");
+    int n = vsnprintf(buf, len, format, arguments);
+    if (n < 0) {
+        std::strcpy(buf, "???");
+    } else if (n >= len) {
+        std::strcpy(buf + len - 1, "...");
+    }
+    log(level, area, where, buf);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/all/logformat.hxx b/sal/osl/all/logformat.hxx
new file mode 100644
index 0000000..f4589a7
--- /dev/null
+++ b/sal/osl/all/logformat.hxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * [ Copyright (C) 2011 Stephan Bergmann, Red Hat <sbergman@redhat.com> (initial
+ *   developer) ]
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef INCLUDED_SAL_OSL_ALL_LOGFORMAT_HXX
+#define INCLUDED_SAL_OSL_ALL_LOGFORMAT_HXX
+
+#include "sal/config.h"
+
+#include <cstdarg>
+
+#include "sal/log.h"
+
+namespace osl { namespace detail {
+
+void logFormat(
+    sal_detail_LogLevel level, char const * area, char const * where,
+    char const * format, std::va_list arguments);
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/all/makefile.mk b/sal/osl/all/makefile.mk
index d9db5b7..e76388a 100644
--- a/sal/osl/all/makefile.mk
+++ b/sal/osl/all/makefile.mk
@@ -50,18 +50,18 @@ CXXFLAGS+= $(LFS_CFLAGS)
 SLOFILES=      \
             $(SLO)$/utility.obj\
             $(SLO)$/filepath.obj\
-            $(SLO)$/formatstring.obj\
             $(SLO)$/debugbase.obj\
             $(SLO)$/loadmodulerelative.obj \
-            $(SLO)/printtrace.obj
+            $(SLO)/log.obj\
+            $(SLO)/trace.obj
 
 OBJFILES=      \
             $(OBJ)$/utility.obj\
             $(OBJ)$/filepath.obj\
-            $(OBJ)$/formatstring.obj\
             $(OBJ)$/debugbase.obj\
             $(OBJ)$/loadmodulerelative.obj \
-            $(OBJ)/printtrace.obj
+            $(OBJ)/log.obj\
+            $(OBJ)/trace.obj
 
 # --- Targets ------------------------------------------------------
 
diff --git a/sal/osl/all/printtrace.cxx b/sal/osl/all/printtrace.cxx
deleted file mode 100644
index 0ecd6f4..0000000
--- a/sal/osl/all/printtrace.cxx
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
-*
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* Copyright 2000, 2010 Oracle and/or its affiliates.
-*
-* OpenOffice.org - a multi-platform office productivity suite
-*
-* This file is part of OpenOffice.org.
-*
-* OpenOffice.org is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Lesser General Public License version 3
-* only, as published by the Free Software Foundation.
-*
-* OpenOffice.org is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU Lesser General Public License version 3 for more details
-* (a copy is included in the LICENSE file that accompanied this code).
-*
-* You should have received a copy of the GNU Lesser General Public License
-* version 3 along with OpenOffice.org.  If not, see
-* <http://www.openoffice.org/license.html>
-* for a copy of the LGPLv3 License.
-*
-************************************************************************/
-
-#include "precompiled_sal.hxx"
-
-#include "sal/config.h"
-
-#include <cstdarg>
-#include <cstdio>
-#include <cstring>
-
-#include <stdio.h> // snprintf, vsnprintf
-
-#include "osl/diagnose.h"
-#include "osl/thread.hxx"
-#include "rtl/string.h"
-#include "sal/types.h"
-
-#include "printtrace.h"
-
-void printTrace(unsigned long pid, char const * format, std::va_list arguments)
-{
-    char buf[1024];
-    int n1 = snprintf(
-        buf, sizeof buf, "Trace %lu/%" SAL_PRIuUINT32 ": \"", pid,
-        osl::Thread::getCurrentIdentifier());
-    OSL_ASSERT(
-        n1 >= 0 &&
-        (static_cast< unsigned int >(n1) <
-         sizeof buf - RTL_CONSTASCII_LENGTH("\"...\n")));
-    int n2 = sizeof buf - n1 - RTL_CONSTASCII_LENGTH("\"...\n");
-    int n3 = vsnprintf(buf + n1, n2, format, arguments);
-    if (n3 < 0) {
-        std::strcpy(buf + n1, "\"???\n");
-    } else if (n3 < n2) {
-        std::strcpy(buf + n1 + n3, "\"\n");
-    } else {
-        std::strcpy(buf + n1 + n2 - 1, "\"...\n");
-    }
-    std::fputs(buf, stderr);
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/all/trace.cxx b/sal/osl/all/trace.cxx
new file mode 100644
index 0000000..8357047
--- /dev/null
+++ b/sal/osl/all/trace.cxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * [ Copyright (C) 2011 Stephan Bergmann, Red Hat <sbergman@redhat.com> (initial
+ *   developer) ]
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "precompiled_sal.hxx"
+#include "sal/config.h"
+
+#include <cstdarg>
+
+#include "osl/diagnose.h"
+#include "sal/log.h"
+
+#include "logformat.hxx"
+
+void osl_trace(char const * pszFormat, ...) {
+    std::va_list args;
+    va_start(args, pszFormat);
+    osl::detail::logFormat(
+        SAL_DETAIL_LOG_LEVEL_INFO, "legacy.osl", SAL_WHERE, pszFormat, args);
+    va_end(args);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/inc/printtrace.h b/sal/osl/inc/printtrace.h
deleted file mode 100644
index a2bca91..0000000
--- a/sal/osl/inc/printtrace.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
-*
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* Copyright 2000, 2010 Oracle and/or its affiliates.
-*
-* OpenOffice.org - a multi-platform office productivity suite
-*
-* This file is part of OpenOffice.org.
-*
-* OpenOffice.org is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Lesser General Public License version 3
-* only, as published by the Free Software Foundation.
-*
-* OpenOffice.org is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU Lesser General Public License version 3 for more details
-* (a copy is included in the LICENSE file that accompanied this code).
-*
-* You should have received a copy of the GNU Lesser General Public License
-* version 3 along with OpenOffice.org.  If not, see
-* <http://www.openoffice.org/license.html>
-* for a copy of the LGPLv3 License.
-*
-************************************************************************/
-
-#ifndef INCLUDED_SAL_OSL_INC_PRINTTRACE_H
-#define INCLUDED_SAL_OSL_INC_PRINTTRACE_H
-
-#include "sal/config.h"
-
-#include <stdarg.h>
-
-#if defined __cplusplus
-extern "C" {
-#endif
-
-/* called internally by osl_trace */
-void printTrace(unsigned long pid, char const * format, va_list arguments);
-
-#if defined __cplusplus
-}
-#endif
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/unx/conditn.c b/sal/osl/unx/conditn.c
index ac6c926..d7ab713 100644
--- a/sal/osl/unx/conditn.c
+++ b/sal/osl/unx/conditn.c
@@ -26,12 +26,15 @@
  *
  ************************************************************************/
 
+#include "sal/config.h"
+
+#include <assert.h>
 
 #include "system.h"
+#include <sal/log.h>
 #include <sal/types.h>
 
 #include <osl/conditn.h>
-#include <osl/diagnose.h>
 #include <osl/time.h>
 
 
@@ -53,10 +56,9 @@ oslCondition SAL_CALL osl_createCondition()
 
     pCond = (oslConditionImpl*) malloc(sizeof(oslConditionImpl));
 
-    OSL_ASSERT(pCond);
-
     if ( pCond == 0 )
     {
+        SAL_WARN("sal", "std::bad_alloc in C");
         return 0;
     }
 
@@ -66,8 +68,9 @@ oslCondition SAL_CALL osl_createCondition()
     nRet =  pthread_cond_init(&pCond->m_Condition, PTHREAD_CONDATTR_DEFAULT);
     if ( nRet != 0 )
     {
-        OSL_TRACE("osl_createCondition : condition init failed. Errno: %d; '%s'\n",
-                  nRet, strerror(nRet));
+        SAL_WARN(
+            "sal", "pthread_cond_init failed, errno %d, \"%s\"", nRet,
+            strerror(nRet));
 
         free(pCond);
         return 0;
@@ -76,15 +79,14 @@ oslCondition SAL_CALL osl_createCondition()
     nRet = pthread_mutex_init(&pCond->m_Lock, PTHREAD_MUTEXATTR_DEFAULT);
     if ( nRet != 0 )
     {
-        OSL_TRACE("osl_createCondition : mutex init failed. Errno: %d; %s\n",
-                  nRet, strerror(nRet));
+        SAL_WARN(
+            "sal", "pthread_mutex_init failed, errno %d, \"%s\"", nRet,
+            strerror(nRet));
 
         nRet = pthread_cond_destroy(&pCond->m_Condition);
-        if ( nRet != 0 )
-        {
-            OSL_TRACE("osl_createCondition : destroy condition failed. Errno: %d; '%s'\n",
-                      nRet, strerror(nRet));
-        }
+        SAL_WARN_IF(
+            nRet != 0, "sal", "pthread_cond_destroy failed, errno %d, \"%s\"",
+            nRet, strerror(nRet));
 
         free(pCond);
         pCond = 0;
@@ -106,17 +108,13 @@ void SAL_CALL osl_destroyCondition(oslCondition Condition)
         pCond = (oslConditionImpl*)Condition;
 
         nRet = pthread_cond_destroy(&pCond->m_Condition);
-        if ( nRet != 0 )
-        {
-            OSL_TRACE("osl_destroyCondition : destroy condition failed. Errno: %d; '%s'\n",
-                      nRet, strerror(nRet));
-        }
+        SAL_WARN_IF(
+            nRet != 0, "sal", "pthread_cond_destroy failed, errno %d, \"%s\"",
+            nRet, strerror(nRet));
         nRet = pthread_mutex_destroy(&pCond->m_Lock);
-        if ( nRet != 0 )
-        {
-            OSL_TRACE("osl_destroyCondition : destroy mutex failed. Errno: %d; '%s'\n",
-                      nRet, strerror(nRet));
-        }
+        SAL_WARN_IF(
+            nRet != 0, "sal", "pthread_mutex_destroy failed, errno %d, \"%s\"",
+            nRet, strerror(nRet));
 
         free(Condition);
     }
@@ -132,7 +130,7 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition)
    oslConditionImpl* pCond;
    int nRet=0;
 
-   OSL_ASSERT(Condition);
+   assert(Condition);
    pCond = (oslConditionImpl*)Condition;
 
    if ( pCond == 0 )
@@ -143,8 +141,9 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition)
    nRet = pthread_mutex_lock(&pCond->m_Lock);
    if ( nRet != 0 )
    {
-       OSL_TRACE("osl_setCondition : mutex lock failed. Errno: %d; %s\n",
-                  nRet, strerror(nRet));
+       SAL_WARN(
+           "sal", "pthread_mutex_lock failed, errno %d, \"%s\"", nRet,
+           strerror(nRet));
        return sal_False;
    }
 
@@ -152,16 +151,18 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition)
    nRet = pthread_cond_broadcast(&pCond->m_Condition);
    if ( nRet != 0 )
    {
-       OSL_TRACE("osl_setCondition : condition broadcast failed. Errno: %d; %s\n",
-                  nRet, strerror(nRet));
+       SAL_WARN(
+           "sal", "pthread_cond_broadcast failed, errno %d, \"%s\"", nRet,
+           strerror(nRet));
        return sal_False;
    }
 
    nRet = pthread_mutex_unlock(&pCond->m_Lock);
    if ( nRet != 0 )
    {
-       OSL_TRACE("osl_setCondition : mutex unlock failed. Errno: %d; %s\n",
-                  nRet, strerror(nRet));
+       SAL_WARN(
+           "sal", "pthread_mutex_unlock failed, errno %d, \"%s\"", nRet,
+           strerror(nRet));
        return sal_False;
    }
 
@@ -177,7 +178,7 @@ sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition)
     oslConditionImpl* pCond;
     int nRet=0;
 
-    OSL_ASSERT(Condition);
+    assert(Condition);
 
     pCond = (oslConditionImpl*)Condition;
 
@@ -189,8 +190,9 @@ sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition)
     nRet = pthread_mutex_lock(&pCond->m_Lock);
     if ( nRet != 0 )
     {
-       OSL_TRACE("osl_resetCondition : mutex lock failed. Errno: %d; %s\n",
-                  nRet, strerror(nRet));
+        SAL_WARN(
+            "sal", "pthread_mutex_lock failed, errno %d, \"%s\"", nRet,
+            strerror(nRet));
         return sal_False;
     }
 
@@ -199,8 +201,9 @@ sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition)
     nRet = pthread_mutex_unlock(&pCond->m_Lock);
     if ( nRet != 0 )
     {
-       OSL_TRACE("osl_resetCondition : mutex unlock failed. Errno: %d; %s\n",
-                  nRet, strerror(nRet));
+       SAL_WARN(
+           "sal", "pthread_mutex_unlock failed, errno %d, \"%s\"", nRet,
+           strerror(nRet));
         return sal_False;
     }
 
@@ -216,7 +219,7 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
     int nRet=0;
     oslConditionResult Result = osl_cond_result_ok;
 
-    OSL_ASSERT(Condition);
+    assert(Condition);
     pCond = (oslConditionImpl*)Condition;
 
     if ( pCond == 0 )
@@ -227,8 +230,9 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
     nRet = pthread_mutex_lock(&pCond->m_Lock);
     if ( nRet != 0 )
     {
-       OSL_TRACE("osl_waitCondition : mutex lock failed. Errno: %d; %s\n",
-                  nRet, strerror(nRet));
+        SAL_WARN(
+            "sal", "pthread_mutex_lock failed, errno %d, \"%s\"", nRet,
+            strerror(nRet));
         return osl_cond_result_error;
     }
 
@@ -255,11 +259,10 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const 
Time
                     {
                         Result = osl_cond_result_timeout;
                         nRet = pthread_mutex_unlock(&pCond->m_Lock);
-                        if (nRet != 0)
-                        {
-                            OSL_TRACE("osl_waitCondition : mutex unlock failed. Errno: %d; %s\n",
-                                      nRet, strerror(nRet));
-                        }
+                        SAL_WARN_IF(
+                            nRet != 0, "sal",
+                            "pthread_mutex_unlock failed, errno %d, \"%s\"",
+                            nRet, strerror(nRet));
 
                         return Result;
                     }
@@ -267,14 +270,12 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const 
Time
                     {
                         Result = osl_cond_result_error;
                         nRet = pthread_mutex_unlock(&pCond->m_Lock);
-                        if ( nRet != 0 )
-                        {
-                            OSL_TRACE("osl_waitCondition : mutex unlock failed. Errno: %d; %s\n",
-                                      nRet, strerror(nRet));
-                        }
+                        SAL_WARN_IF(
+                            nRet != 0, "sal",
+                            "pthread_mutex_unlock failed, errno %d, \"%s\"",
+                            nRet, strerror(nRet));
                         return Result;
                     }
-/*                    OSL_TRACE("EINTR\n");*/
                 }
             }
             while ( !pCond->m_State );
@@ -287,15 +288,15 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const 
Time
             nRet = pthread_cond_wait(&pCond->m_Condition, &pCond->m_Lock);
             if ( nRet != 0 )
             {
-                OSL_TRACE("osl_waitCondition : condition wait failed. Errno: %d; %s\n",
-                          nRet, strerror(nRet));
+                SAL_WARN(
+                    "sal", "pthread_cond_wait failed, errno %d, \"%s\"", nRet,
+                    strerror(nRet));
                 Result = osl_cond_result_error;
                 nRet = pthread_mutex_unlock(&pCond->m_Lock);
-                if ( nRet != 0 )
-                {
-                    OSL_TRACE("osl_waitCondition : mutex unlock failed. Errno: %d; %s\n",
-                              nRet, strerror(nRet));
-                }
+                SAL_WARN_IF(
+                    nRet != 0, "sal",
+                    "pthread_mutex_unlock failed, errno %d, \"%s\"", nRet,
+                    strerror(nRet));
 
                 return Result;
             }
@@ -303,11 +304,9 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const 
Time
     }
 
     nRet = pthread_mutex_unlock(&pCond->m_Lock);
-    if ( nRet != 0 )
-    {
-        OSL_TRACE("osl_waitCondition : mutex unlock failed. Errno: %d; %s\n",
-                  nRet, strerror(nRet));
-    }
+    SAL_WARN_IF(
+        nRet != 0, "sal", "pthread_mutex_unlock failed, errno %d, \"%s\"", nRet,
+        strerror(nRet));
 
     return Result;
 }
@@ -321,7 +320,7 @@ sal_Bool SAL_CALL osl_checkCondition(oslCondition Condition)
     oslConditionImpl* pCond;
     int nRet=0;
 
-    OSL_ASSERT(Condition);
+    assert(Condition);
     pCond = (oslConditionImpl*)Condition;
 
     if ( pCond == 0 )
@@ -330,20 +329,16 @@ sal_Bool SAL_CALL osl_checkCondition(oslCondition Condition)
     }
 
     nRet = pthread_mutex_lock(&pCond->m_Lock);
-    if ( nRet != 0 )
-    {
-        OSL_TRACE("osl_checkCondition : mutex unlock failed. Errno: %d; %s\n",
-                  nRet, strerror(nRet));
-    }
+    SAL_WARN_IF(
+        nRet != 0, "sal", "pthread_mutex_lock failed, errno %d, \"%s\"", nRet,
+        strerror(nRet));
 
     State = pCond->m_State;
 
     nRet = pthread_mutex_unlock(&pCond->m_Lock);
-    if ( nRet != 0 )
-    {
-        OSL_TRACE("osl_checkCondition : mutex unlock failed. Errno: %d; %s\n",
-                  nRet, strerror(nRet));
-    }
+    SAL_WARN_IF(
+        nRet != 0, "sal", "pthread_mutex_unlock failed, errno %d, \"%s\"", nRet,
+        strerror(nRet));
 
     return State;
 }
diff --git a/sal/osl/unx/diagnose.c b/sal/osl/unx/diagnose.c
index 7832b16..5b46a61 100644
--- a/sal/osl/unx/diagnose.c
+++ b/sal/osl/unx/diagnose.c
@@ -46,7 +46,6 @@
 #endif
 
 #endif  /* HAVE_DLFCN_H */
-#include "osl/thread.h"
 
 #ifndef INCLUDED_PTHREAD_H
 #include <pthread.h>
@@ -58,8 +57,6 @@
 #define INCLUDED_STDDEF_H
 #endif
 
-#include "printtrace.h"
-
 /************************************************************************/
 /* Internal data structures and functions */
 /************************************************************************/
@@ -309,14 +306,4 @@ pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc (
     return pOldFunc;
 }
 
-/************************************************************************/
-/* osl_trace */
-/************************************************************************/
-void osl_trace(char const * pszFormat, ...) {
-    va_list args;
-    va_start(args, pszFormat);
-    printTrace((unsigned long) getpid(), pszFormat, args);
-    va_end(args);
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/w32/diagnose.c b/sal/osl/w32/diagnose.c
index f8fc997..6e793c3 100644
--- a/sal/osl/w32/diagnose.c
+++ b/sal/osl/w32/diagnose.c
@@ -29,9 +29,6 @@
 #include "system.h"
 
 #include <osl/diagnose.h>
-#include <osl/thread.h>
-
-#include "printtrace.h"
 
 static pfunc_osl_printDebugMessage  _pPrintDebugMessage = NULL;
 static pfunc_osl_printDetailedDebugMessage  _pPrintDetailedDebugMessage = NULL;
@@ -63,24 +60,6 @@ void SAL_CALL osl_breakDebug(void)
         abort ();
 }
 
-void osl_trace(char const * pszFormat, ...) {
-    va_list args;
-    va_start(args, pszFormat);
-    if ( IsDebuggerPresent() )
-    {
-        sal_Char    szMessage[512];
-        int written = _vsnprintf(
-            szMessage, sizeof(szMessage) - 2, pszFormat, args );
-        if ( written == -1 )
-            written = sizeof(szMessage) - 2;
-        szMessage[ written++ ] = '\n';
-        szMessage[ written ] = 0;
-        OutputDebugString( szMessage );
-    }
-    printTrace((unsigned long) _getpid(), pszFormat, args);
-    va_end(args);
-}
-
 sal_Bool SAL_CALL osl_assertFailedLine(const sal_Char* pszFileName, sal_Int32 nLine, const 
sal_Char* pszMessage)
 {
     char const * env = getenv( "SAL_DIAGNOSE_ABORT" );
diff --git a/sal/rtl/source/logfile.cxx b/sal/rtl/source/logfile.cxx
index f71d8f5..c5858c1 100644
--- a/sal/rtl/source/logfile.cxx
+++ b/sal/rtl/source/logfile.cxx
@@ -39,10 +39,12 @@
 #include <osl/time.h>
 #include <osl/mutex.hxx>
 #include <rtl/bootstrap.h>
+#include <rtl/oustringostreaminserter.hxx>
 #include <rtl/ustring.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <rtl/alloc.h>
 #include <rtl/instance.hxx>
+#include <sal/log.h>
 #include "osl/thread.h"
 
 #include <algorithm>
@@ -107,7 +109,8 @@ OUString getFileUrl( const OUString &name )
     if ( osl_getFileURLFromSystemPath( name.pData, &aRet.pData )
          != osl_File_E_None )
     {
-        OSL_ASSERT( false );
+        SAL_WARN_S(
+            "sal", "osl_getFileURLFromSystemPath failed for \"" << name << '"');
     }
 
     OUString aWorkingDirectory;
@@ -182,7 +185,9 @@ void init() {
                 }
                 else
                 {
-                    OSL_TRACE( "Couldn't open logfile %s(%d)" , o.getStr(), e );
+                    SAL_WARN_S(
+                        "sal",
+                        "Couldn't open logfile " << o << '(' << e << ')');
                 }
             }
             g_bHasBeenCalled = sal_True;
diff --git a/sal/util/sal.map b/sal/util/sal.map
index b67e313..797c1a2 100755
--- a/sal/util/sal.map
+++ b/sal/util/sal.map
@@ -626,5 +626,6 @@ PRIVATE_1.1 {
 
 PRIVATE_1.2 { # LibreOffice 3.5
     global:
-        osl_detail_formatString;
+        sal_detail_log;
+        sal_detail_logFormat;
 } PRIVATE_1.1;
diff --git a/sfx2/inc/sfx2/objface.hxx b/sfx2/inc/sfx2/objface.hxx
index d867bd0..7e43c19 100644
--- a/sfx2/inc/sfx2/objface.hxx
+++ b/sfx2/inc/sfx2/objface.hxx
@@ -29,6 +29,8 @@
 #define _SFXOBJFACE_HXX
 
 #include "sal/config.h"
+
+#include "rtl/ustring.hxx"
 #include "sfx2/dllapi.h"
 #include "sal/types.h"
 #include <tools/string.hxx>
@@ -79,7 +81,7 @@ public:
 
     const char*             GetClassName() const { return pName; }
     int                     HasName() const { return 0 != aNameResId.GetId(); }
-    String                  GetName() const
+    rtl::OUString           GetName() const
                             { return String(aNameResId); }
     ResMgr*                 GetResMgr() const
                             { return aNameResId.GetResMgr(); }
diff --git a/sfx2/source/appl/module.cxx b/sfx2/source/appl/module.cxx
index 6883e90..a4fc06d 100644
--- a/sfx2/source/appl/module.cxx
+++ b/sfx2/source/appl/module.cxx
@@ -50,6 +50,7 @@
 #include "sfx2/taskpane.hxx"
 #include <tools/diagnose_ex.h>
 #include <rtl/strbuf.hxx>
+#include <sal/log.h>
 
 #define SfxModule
 #include "sfxslots.hxx"
@@ -208,7 +209,7 @@ void SfxModule::RegisterChildWindow(SfxChildWinFactory *pFact)
         if (pFact->nId ==  (*pImpl->pFactArr)[nFactory]->nId)
         {
             pImpl->pFactArr->Remove( nFactory );
-            OSL_FAIL("ChildWindow registered multiple times!");
+            SAL_WARN("sfx2", "ChildWindow registered multiple times!");
             return;
         }
     }
@@ -391,11 +392,10 @@ FieldUnit SfxModule::GetModuleFieldUnit( ::com::sun::star::uno::Reference< 
::com
     SfxPoolItem const * pItem = pModule->GetItem( SID_ATTR_METRIC );
     if ( pItem == NULL )
     {
-        OSL_FAIL(
-            OSL_FORMAT(
-                ("SfxModule::GetFieldUnit: no metric item in the module"
-                 " implemented by '%s'!"),
-                typeid(*pModule).name()));
+        SAL_WARN_S(
+            "sfx2",
+            "SfxModule::GetFieldUnit: no metric item in the module implemented"
+                " by '" << typeid(*pModule).name() << "'!");
         return FUNIT_100TH_MM;
     }
     return (FieldUnit)( (SfxUInt16Item*)pItem )->GetValue();
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index 9d176c4..671f79f 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -28,8 +28,12 @@
 
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sfx2.hxx"
+#include "sal/config.h"
+
+#include <iomanip>
 
 #include <boost/unordered_map.hpp>
+#include <sal/log.h>
 #include <svl/itempool.hxx>
 #include <svl/itemiter.hxx>
 #include <svl/eitem.hxx>
@@ -1741,26 +1745,12 @@ sal_uInt16 SfxBindings::EnterRegistrations(const char *pFile, int nLine)
     (void)pFile;
     (void)nLine;
     DBG_MEMTEST();
-#ifdef DBG_UTIL
-    rtl::OStringBuffer aMsg;
-    sal_uInt16 nSpaces = Min(nRegLevel, sal_uInt16(8));
-    while (nSpaces--)
-        aMsg.append(' ');
-    aMsg.append(RTL_CONSTASCII_STRINGPARAM("this = "));
-    aMsg.append(reinterpret_cast<sal_Int64>(this));
-    aMsg.append(RTL_CONSTASCII_STRINGPARAM(" Level = "));
-    aMsg.append(static_cast<sal_Int32>(nRegLevel));
-    aMsg.append(RTL_CONSTASCII_STRINGPARAM(
-        " SfxBindings::EnterRegistrations "));
-    if (pFile)
-    {
-        aMsg.append(RTL_CONSTASCII_STRINGPARAM("File: "));
-        aMsg.append(pFile);
-        aMsg.append(RTL_CONSTASCII_STRINGPARAM(" Line: "));
-        aMsg.append(static_cast<sal_Int32>(nLine));
-    }
-    DbgTrace(aMsg.getStr());
-#endif
+    SAL_INFO_S(
+        "sfx2",
+        std::setw(Min(nRegLevel, sal_uInt16(8))) << ' ' << "this = " << this
+            << " Level = " << nRegLevel << " SfxBindings::EnterRegistrations "
+            << (pFile
+                ? SAL_STREAM("File: " << pFile << " Line: " << nLine) : ""));
 
     // When bindings are locked, also lock sub bindings.
     if ( pImp->pSubBindings )
@@ -1858,26 +1848,12 @@ void SfxBindings::LeaveRegistrations( sal_uInt16 nLevel, const char *pFile, 
int
         }
     }
 
-#ifdef DBG_UTIL
-    rtl::OStringBuffer aMsg;
-    sal_uInt16 nSpaces = Min(nRegLevel, sal_uInt16(8));
-    while (nSpaces--)
-        aMsg.append(' ');
-    aMsg.append(RTL_CONSTASCII_STRINGPARAM("this = "));
-    aMsg.append(reinterpret_cast<sal_Int64>(this));
-    aMsg.append(RTL_CONSTASCII_STRINGPARAM(" Level = "));
-    aMsg.append(static_cast<sal_Int32>(nRegLevel));
-    aMsg.append(RTL_CONSTASCII_STRINGPARAM(
-        " SfxBindings::LeaveRegistrations "));
-    if (pFile)
-    {
-        aMsg.append(RTL_CONSTASCII_STRINGPARAM("File: "));
-        aMsg.append(pFile);
-        aMsg.append(RTL_CONSTASCII_STRINGPARAM(" Line: "));
-        aMsg.append(static_cast<sal_Int32>(nLine));
-    }
-    DbgTrace(aMsg.getStr());
-#endif
+    SAL_INFO_S(
+        "sfx2",
+        std::setw(Min(nRegLevel, sal_uInt16(8))) << ' ' << "this = " << this
+            << " Level = " << nRegLevel << " SfxBindings::LeaveRegistrations "
+            << "File: " << (pFile ? pFile : "--") << " Line: "
+            << (pFile ? nLine : 0));
 }
 
 //--------------------------------------------------------------------
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index 8df3b4a..c262291 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -476,25 +476,13 @@ void SfxDispatcher::Pop
 
     SfxApplication *pSfxApp = SFX_APP();
 
-#ifdef DBG_UTIL
-    rtl::OStringBuffer aMsg(RTL_CONSTASCII_STRINGPARAM("-SfxDispatcher("));
-    aMsg.append(reinterpret_cast<sal_Int64>(this));
-    if (bPush)
-        aMsg.append(RTL_CONSTASCII_STRINGPARAM(")::Push("));
-    else
-        aMsg.append(RTL_CONSTASCII_STRINGPARAM(")::Pop("));
-    if (rShell.GetInterface())
-        aMsg.append(rShell.GetInterface()->GetClassName());
-    else
-        aMsg.append(reinterpret_cast<sal_Int64>(&rShell));
-    if (bDelete)
-        aMsg.append(RTL_CONSTASCII_STRINGPARAM(") with delete"));
-    else
-        aMsg.append(')');
-    if (bUntil)
-        aMsg.append(RTL_CONSTASCII_STRINGPARAM(" (up to)"));
-    DbgTrace(aMsg.getStr());
-#endif
+    SAL_INFO_S(
+        "sfx2",
+        "-SfxDispatcher(" << this << (bPush ? ")::Push(" : ")::Pop(")
+            << (rShell.GetInterface()
+                ? rShell.GetInterface()->GetClassName() : SAL_STREAM(&rShell))
+            << (bDelete ? ") with delete" : ")")
+            << (bUntil ? " (up to)" : ""));
 
     // same shell as on top of the to-do stack?
     if ( pImp->aToDoStack.Count() && pImp->aToDoStack.Top().pCluster == &rShell )
@@ -1705,12 +1693,6 @@ void SfxDispatcher::FlushImpl()
 
     OSL_TRACE("Flushing dispatcher!");
 
-#ifdef DBG_UTIL
-    rtl::OStringBuffer aMsg(RTL_CONSTASCII_STRINGPARAM("SfxDispatcher("));
-    aMsg.append(reinterpret_cast<sal_Int64>(this));
-    aMsg.append(RTL_CONSTASCII_STRINGPARAM(")::Flush()"));
-#endif
-
     pImp->aTimer.Stop();
 
     if ( pImp->pParent )
@@ -1821,10 +1803,7 @@ void SfxDispatcher::FlushImpl()
     for (sal_uInt16 n=0; n<SFX_OBJECTBAR_MAX; n++)
         pImp->aFixedObjBars[n].nResId = 0;
 
-#ifdef DBG_UTIL
-    aMsg.append(RTL_CONSTASCII_STRINGPARAM("done"));
-    DbgTrace(aMsg.getStr());
-#endif
+    SAL_INFO_S("sfx2", "SfxDispatcher(" << this << ")::Flush() done");
 }
 
 //--------------------------------------------------------------------
diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx
index 7a32326..33a6f47 100644
--- a/sfx2/source/control/shell.cxx
+++ b/sfx2/source/control/shell.cxx
@@ -31,6 +31,8 @@
 #include <com/sun/star/embed/VerbDescriptor.hpp>
 #include <com/sun/star/embed/VerbAttributes.hpp>
 #include <basic/sbstar.hxx>
+#include <rtl/oustringostreaminserter.hxx>
+#include <sal/log.h>
 #include <svl/itempool.hxx>
 #include <svl/undo.hxx>
 #include <svtools/itemdel.hxx>
@@ -623,15 +625,10 @@ void SfxShell::DoActivate_Impl( SfxViewFrame *pFrame, sal_Bool bMDI )
     if ( !p_IF )
         return;
 #endif
-#ifdef DBG_UTIL_VB
-        String aMsg("SfxShell::DoActivate() ");
-        aMsg += (long)this;
-        aMsg += "  ";
-        aMsg += GetInterface()->GetName();
-        aMsg += " bMDI ";
-        if ( bMDI ) aMsg += "MDI";
-        DbgTrace( aMsg.GetBuffer() );
-#endif
+    SAL_INFO_S(
+        "sfx2.vb",
+        "SfxShell::DoActivate() " << this << "  " << GetInterface()->GetName()
+            << " bMDI " << (bMDI ? "MDI" : ""));
 
     if ( bMDI )
     {
@@ -664,15 +661,10 @@ void SfxShell::DoDeactivate_Impl( SfxViewFrame *pFrame, sal_Bool bMDI )
     if ( !p_IF )
         return;
 #endif
-#ifdef DBG_UTIL_VB
-        String aMsg("SfxShell::DoDeactivate()");
-        aMsg += (long)this;
-        aMsg += "  ";
-        aMsg += GetInterface()->GetName();
-        aMsg += " bMDI ";
-        if ( bMDI ) aMsg += "MDI";
-        DbgTrace( aMsg.GetBuffer() );
-#endif
+    SAL_INFO_S(
+        "sfx2.vb",
+        "SfxShell::DoDeactivate()" << this << "  " << GetInterface()->GetName()
+            << " bMDI " << (bMDI ? "MDI" : ""));
 
     // Only when it comes from a Frame
     // (not when for instance by poping BASIC-IDE from AppDisp)
diff --git a/smoketestoo_native/smoketest.cxx b/smoketestoo_native/smoketest.cxx
index f59e03a..b0a7097 100644
--- a/smoketestoo_native/smoketest.cxx
+++ b/smoketestoo_native/smoketest.cxx
@@ -57,11 +57,11 @@
 #include "osl/conditn.hxx"
 #include "osl/diagnose.h"
 #include "osl/time.h"
+#include "rtl/oustringostreaminserter.hxx"
 #include "rtl/ustring.h"
 #include "rtl/ustring.hxx"
 #include "unotest/gettestargument.hxx"
 #include "unotest/officeconnection.hxx"
-#include "unotest/oustringostreaminserter.hxx"
 #include "unotest/toabsolutefileurl.hxx"
 
 namespace {
diff --git a/solenv/bin/addsym.awk b/solenv/bin/addsym.awk
index de0b579..4c18bdc 100644
--- a/solenv/bin/addsym.awk
+++ b/solenv/bin/addsym.awk
@@ -36,9 +36,14 @@ END {
         print "# Weak RTTI symbols for C++ exceptions:"
         print "UDK_3_0_0 {"
         print "global:"
-        print "_ZTI*; _ZTS*; # weak RTTI symbols for C++ exceptions"
+        print "_ZTI*; _ZTS*;"
         print "};"
     }
+    print "# Unique libstdc++ symbols:"
+    print "GLIBCXX_3.4 {"
+    print "global:"
+    print "_ZGVNSt7num_put*; _ZNSt7num_put*;"
+    print "};"
 }
 state == 2 {
     print "_ZTI*; _ZTS*; # weak RTTI symbols for C++ exceptions"
diff --git a/solenv/gbuild/gbuild.mk b/solenv/gbuild/gbuild.mk
index 4634333..9d871c1 100644
--- a/solenv/gbuild/gbuild.mk
+++ b/solenv/gbuild/gbuild.mk
@@ -211,12 +211,18 @@ ifeq ($(gb_DEBUGLEVEL),0)
 gb_GLOBALDEFS += \
        -DOPTIMIZE \
        -DNDEBUG \
+    -DSAL_LOG_LEVEL=0 \
 
-else ifneq ($(gb_DEBUGLEVEL),1) # 2 or more
+else
+gb_GLOBALDEFS += \
+    -DSAL_LOG_LEVEL=2 \
+
+ifneq ($(gb_DEBUGLEVEL),1) # 2 or more
 gb_GLOBALDEFS += \
        -DDEBUG \
 
 endif
+endif
 
 ifneq ($(strip $(ENABLE_GTK)),)
 gb_GLOBALDEFS += -DENABLE_GTK
diff --git a/solenv/inc/settings.mk b/solenv/inc/settings.mk
index 5c6f6cc..8dce816 100644
--- a/solenv/inc/settings.mk
+++ b/solenv/inc/settings.mk
@@ -1138,6 +1138,11 @@ RSCDEFS+= -DNDEBUG
 .IF "$(DBG_LEVEL)"!=""
 CDEFS+=-DOSL_DEBUG_LEVEL=$(DBG_LEVEL)
 RSCDEFS+=-DOSL_DEBUG_LEVEL=$(DBG_LEVEL)
+.IF "$(DBG_LEVEL)"=="0"
+CDEFS+=-DSAL_LOG_LEVEL=0
+.ELSE
+CDEFS+=-DSAL_LOG_LEVEL=2
+.ENDIF
 .ENDIF
 
 .IF "$(optimize)"!=""
diff --git a/svl/source/inc/poolio.hxx b/svl/source/inc/poolio.hxx
index 1515779..15f55ee 100644
--- a/svl/source/inc/poolio.hxx
+++ b/svl/source/inc/poolio.hxx
@@ -154,17 +154,8 @@ struct SfxItemPool_Impl
 #endif
 
 #if defined(DBG_UTIL) && defined(MSC)
-#define SFX_TRACE(s,p) \
-        { \
-            ByteString aPtr(RTL_CONSTASCII_STRINGPARAM("0x0000:0x0000")); \
-            _snprintf(const_cast< sal_Char *>(aPtr.GetBuffer()), aPtr.Len(), \
-                       "%lp", p ); \
-            aPtr.Insert(s, 0); \
-            DbgTrace( aPtr.GetBuffer() ); \
-        }
 #define DBG(x) x
 #else
-#define SFX_TRACE(s,p)
 #define DBG(x)
 #endif
 
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index 2bcef79..cdcf217 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -836,7 +836,6 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem )
             else
             {
                 SFX_ASSERT( 0, rItem.Which(), "removing Item without ref" );
-                SFX_TRACE( "to be removed, but not no refs: ", p );
             }
 
             // ggf. kleinstmoegliche freie Position merken
@@ -854,7 +853,6 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem )
 
     // nicht vorhanden
     SFX_ASSERT( 0, rItem.Which(), "removing Item not in Pool" );
-    SFX_TRACE( "to be removed, but not in pool: ", &rItem );
 }
 
 // -----------------------------------------------------------------------
diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx
index eb84af5..ce5bb32 100644
--- a/svl/source/items/poolio.cxx
+++ b/svl/source/items/poolio.cxx
@@ -32,6 +32,7 @@
 #include <string.h>
 #include <stdio.h>
 
+#include <sal/log.h>
 #include <tools/solar.h>
 #include <svl/itempool.hxx>
 #include "whassert.hxx"
@@ -955,14 +956,12 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
                                 delete rpNewItem;
                                 rpNewItem = pOldItem;
                                 bFound = true;
-                                SFX_TRACE( "reusing item", pOldItem );
+                                SAL_INFO_S("svl", "reusing item" << pOldItem);
                                 break;
                             }
                         }
-                        if ( !bFound )
-                        {
-                            SFX_TRACE( "item not found: ", pOldItem );
-                        }
+                        SAL_INFO_IF_S(
+                            !bFound, "svl", "item not found: " << pOldItem);
                     }
                 }
             }
diff --git a/svl/source/items/whassert.hxx b/svl/source/items/whassert.hxx
index 379d479..d994f0d 100644
--- a/svl/source/items/whassert.hxx
+++ b/svl/source/items/whassert.hxx
@@ -28,29 +28,12 @@
 #ifndef _SFX_WHASSERT_HXX
 #define _SFX_WHASSERT_HXX
 
-#include <tools/debug.hxx>
-#include <rtl/strbuf.hxx>
+#include "sal/config.h"
 
-//------------------------------------------------------------------------
-
-#ifdef DBG_UTIL
-#define SFX_ASSERT( bCondition, nId, sMessage )                             \
-{                                                                           \
-    if ( DbgIsAssert() )                                                    \
-    {                                                                       \
-        if ( !(bCondition) )                                                \
-        {                                                                   \
-            rtl::OStringBuffer aMsg(sMessage);                              \
-            aMsg.append(RTL_CONSTASCII_STRINGPARAM("\nwith Id/Pos: "));     \
-            aMsg.append(static_cast<sal_Int32>(nId));                       \
-            DbgError(aMsg.getStr(), __FILE__, __LINE__);                    \
-        }                                                                   \
-    }                                                                       \
-}
-#else
-#define SFX_ASSERT( bCondition, nId, sMessage )
-#endif
+#include "sal/log.h"
 
+#define SFX_ASSERT( bCondition, nId, sMessage ) SAL_WARN_IF_S( \
+    !(bCondition), "svl", (sMessage) << ", with ID/pos " << (nId));
 
 #endif
 
diff --git a/sw/source/ui/docvw/srcedtw.cxx b/sw/source/ui/docvw/srcedtw.cxx
index b80904f..04adab9 100644
--- a/sw/source/ui/docvw/srcedtw.cxx
+++ b/sw/source/ui/docvw/srcedtw.cxx
@@ -33,7 +33,9 @@
 #include <hintids.hxx>
 #include <cmdid.h>
 
-
+#include <rtl/oustringostreaminserter.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/log.h>
 #include <svtools/textview.hxx>
 #include <svx/svxids.hrc>
 #include <vcl/scrbar.hxx>
@@ -161,10 +163,10 @@ static void lcl_Highlight(const String& rSource, SwTextPortions& aPortionList)
                     else
                     {
                         // what was that?
-#if OSL_DEBUG_LEVEL > 1
-                        OSL_FAIL(OSL_FORMAT("Token %s not recognised!",
-                            rtl::OUStringToOString(sToken, osl_getThreadTextEncoding()).getStr()));
-#endif
+                        SAL_WARN_S(
+                            "sw.level2",
+                            "Token " << rtl::OUString(sToken)
+                                << " not recognised!");
                     }
 
                 }
@@ -539,7 +541,7 @@ IMPL_LINK(SwSrcEditWindow, ScrollHdl, ScrollBar*, pScroll)
 IMPL_LINK( SwSrcEditWindow, SyntaxTimerHdl, Timer *, pTimer )
 {
     Time aSyntaxCheckStart;
-    OSL_ENSURE( pTextView, "Noch keine View, aber Syntax-Highlight ?!" );
+    SAL_WARN_IF(pTextView == 0, "sw", "No View yet, but syntax highlighting?!");
 
     bHighlighting = sal_True;
     sal_uInt16 nLine;
@@ -665,10 +667,9 @@ void SwSrcEditWindow::ImpDoHighlight( const String& rSource, sal_uInt16 
nLineOff
         for ( size_t i = 0; i < nCount; i++ )
         {
             SwTextPortion& r = aPortionList[i];
-#if OSL_DEBUG_LEVEL > 1
-            sal_uInt16 nLine = aPortionList[0].nLine;
-            OSL_ENSURE( r.nLine == nLine, "doch mehrere Zeilen ?" );
-#endif
+            SAL_WARN_IF(
+                r.nLine != aPortionList[0].nLine, "sw.level2",
+                "multiple lines after all?");
             if ( r.nStart > r.nEnd )    // only until Bug from MD is resolved
                 continue;
 
diff --git a/tools/inc/tools/debug.hxx b/tools/inc/tools/debug.hxx
index 3d75f94..b60496e 100644
--- a/tools/inc/tools/debug.hxx
+++ b/tools/inc/tools/debug.hxx
@@ -31,9 +31,54 @@
 
 #include "tools/toolsdllapi.h"
 
+#include <sal/log.h>
 #include <sal/types.h>
 #include <tools/solar.h>
 
+/** The facilities provided by this header are deprecated.  True assertions
+    (that detect broken program logic) should use standard assert (which aborts
+    if an assertion fails, and is controlled by the standard NDEBUG macro).
+    Logging of warnings (e.g., about malformed input) and traces (e.g., about
+    steps taken while executing some protocol) should use the facilities
+    provided by sal/log.h.
+
+    Because the assertion macros (DBG_ASSERTWARNING, DBG_ASSERT, DBG_BF_ASSERT)
+    have been used for true assertions as well as for logged warnings, they map
+    to SAL_WARN instead of standard assert.  The warning and error macros
+    (DBG_WARNING, DBG_WARNING1, ..., DBG_WARNING5, DBG_WARNINGFILE,
+    DBG_ERRORFILE) all map to SAL_WARN, too.
+*/
+
+#define DBG_ASSERTWARNING( sCon, aWarning ) \
+    SAL_WARN_IF(!(sCon), "legacy.tools", aWarning)
+
+#define DBG_ASSERT( sCon, aError ) \
+    SAL_WARN_IF(!(sCon), "legacy.tools", aError)
+
+#ifdef DBG_BINFILTER
+#define DBG_BF_ASSERT( sCon, aError ) \
+    SAL_WARN_IF(!(sCon), "legacy.binfilter", aError)
+#else
+#define DBG_BF_ASSERT( sCon, aError ) ((void)0)
+#endif
+
+#define DBG_WARNING( aWarning ) SAL_WARN("legacy.tools", aWarning)
+#define DBG_WARNING1( aWarning, x1 ) SAL_WARN("legacy.tools", aWarning, x1)
+#define DBG_WARNING2( aWarning, x1, x2 ) \
+    SAL_WARN("legacy.tools", aWarning, x1, x2)
+#define DBG_WARNING3( aWarning, x1, x2, x3 ) \
+    SAL_WARN("legacy.tools", aWarning, x1, x2, x3)
+#define DBG_WARNING4( aWarning, x1, x2, x3, x4 ) \
+    SAL_WARN("legacy.tools", aWarning, x1, x2, x3, x4)
+#define DBG_WARNING5( aWarning, x1, x2, x3, x4, x5 ) \
+    SAL_WARN("legacy.tools", aWarning, x1, x2, x3, x4, x5)
+
+#define DBG_WARNINGFILE( aWarning ) \
+    SAL_WARN("legacy.tools", aWarning, __FILE__, __LINE__)
+
+#define DBG_ERRORFILE( aError ) \
+    SAL_WARN("legacy.tools", aError, __FILE__, __LINE__)
+
 // ------------
 // - DBG_UITL -
 // ------------
@@ -348,24 +393,6 @@ TOOLS_DLLPUBLIC void DbgOutTypef( sal_uInt16 nOutType, const sal_Char* pFStr, 
..
 TOOLS_DLLPUBLIC void DbgOutf( const sal_Char* pFStr, ... );
 TOOLS_DLLPUBLIC void ImpDbgOutfBuf( sal_Char* pBuf, const sal_Char* pFStr, ... );
 
-inline void DbgTrace( const sal_Char* pMsg,
-                      const sal_Char* pFile = NULL, sal_uInt16 nLine = 0 )
-{
-    DbgOut( pMsg, DBG_OUT_TRACE, pFile, nLine );
-}
-
-inline void DbgWarning( const sal_Char* pMsg,
-                        const sal_Char* pFile = NULL, sal_uInt16 nLine = 0 )
-{
-    DbgOut( pMsg, DBG_OUT_WARNING, pFile, nLine );
-}
-
-inline void DbgError( const sal_Char* pMsg,
-                      const sal_Char* pFile = NULL, sal_uInt16 nLine = 0 )
-{
-    DbgOut( pMsg, DBG_OUT_ERROR, pFile, nLine );
-}
-
 // --- Dbg-Test-Functions ---
 
 inline void DbgMemTest( void* p = NULL )
@@ -469,111 +496,6 @@ public:
     DbgXtor( DBG_FUNC( aName ), DBG_XTOR_CHKOBJ,    \
              (const void*)pObj, (DbgUsr)fTest )
 
-#define DBG_ASSERTWARNING( sCon, aWarning )         \
-do                                                  \
-{                                                   \
-    if ( DbgIsAssertWarning() )                     \
-    {                                               \
-        if ( !( sCon ) )                            \
-        {                                           \
-            DbgWarning( aWarning, __FILE__,         \
-                        __LINE__ );                 \
-        }                                           \
-    }                                               \
-} while(0)
-
-#define DBG_ASSERT( sCon, aError )                  \
-do                                                  \
-{                                                   \
-    if ( DbgIsAssert() )                            \
-    {                                               \
-        if ( !( sCon ) )                            \
-        {                                           \
-            DbgError( aError,                       \
-                      __FILE__, __LINE__ );         \
-        }                                           \
-    }                                               \
-} while(0)
-
-#ifdef DBG_BINFILTER
-#define DBG_BF_ASSERT( sCon, aError )           \
-do                                              \
-{                                               \
-    if ( !( sCon ) )                            \
-    {                                           \
-        DbgError( aError,                       \
-                  __FILE__, __LINE__ );         \
-    }                                           \
-} while(0)
-#else
-#define DBG_BF_ASSERT( sCon, aError ) ((void)0)
-#endif
-
-#define DBG_WARNING( aWarning )                     \
-do                                                  \
-{                                                   \
-    if ( DbgIsWarningOut() )                        \
-        DbgWarning( aWarning );                     \
-} while(0)
-#define DBG_WARNING1( aWarning, x1 )                \
-do                                                  \
-{                                                   \
-    if ( DbgIsWarningOut() )                        \
-    {                                               \
-        DbgOutTypef( DBG_OUT_WARNING, aWarning,     \
-                     x1 );                          \
-    }                                               \
-} while(0)
-#define DBG_WARNING2( aWarning, x1, x2 )            \
-do                                                  \
-{                                                   \
-    if ( DbgIsWarningOut() )                        \
-    {                                               \
-        DbgOutTypef( DBG_OUT_WARNING, aWarning,     \
-                     x1, x2 );                      \
-    }                                               \
-} while(0)
-#define DBG_WARNING3( aWarning, x1, x2, x3 )        \
-do                                                  \
-{                                                   \
-    if ( DbgIsWarningOut() )                        \
-    {                                               \
-        DbgOutTypef( DBG_OUT_WARNING, aWarning,     \
-                     x1, x2, x3 );                  \
-    }                                               \
-} while(0)
-#define DBG_WARNING4( aWarning, x1, x2, x3, x4 )    \
-do                                                  \
-{                                                   \
-    if ( DbgIsWarningOut() )                        \
-    {                                               \
-        DbgOutTypef( DBG_OUT_WARNING, aWarning,     \
-                     x1, x2, x3, x4 );              \
-    }                                               \
-} while(0)
-#define DBG_WARNING5( aWarning, x1, x2, x3, x4, x5 )\
-do                                                  \
-{                                                   \
-    if ( DbgIsWarningOut() )                        \
-    {                                               \
-        DbgOutTypef( DBG_OUT_WARNING, aWarning,     \
-                     x1, x2, x3, x4, x5 );          \
-    }                                               \
-} while(0)
-#define DBG_WARNINGFILE( aWarning )                 \
-do                                                  \
-{                                                   \
-    if ( DbgIsWarningOut() )                        \
-        DbgWarning( aWarning, __FILE__, __LINE__ ); \
-} while(0)
-
-#define DBG_ERRORFILE( aError )                     \
-do                                                  \
-{                                                   \
-    if ( DbgIsErrorOut() )                          \
-        DbgError( aError, __FILE__, __LINE__ );     \
-} while(0)
-
 #define DBG_TESTSOLARMUTEX()                \
 do                                          \
 {                                           \
@@ -637,18 +559,6 @@ typedef const sal_Char* (*DbgUsr)(const void* pThis );
 #define DBG_CHKTHIS( aName, fTest ) ((void)0)
 #define DBG_CHKOBJ( pObj, aName, fTest ) ((void)0)
 
-#define DBG_ASSERTWARNING( sCon, aWarning ) ((void)0)
-#define DBG_ASSERT( sCon, aError ) ((void)0)
-#define DBG_BF_ASSERT( sCon, aError ) ((void)0)
-#define DBG_WARNING( aWarning ) ((void)0)
-#define DBG_WARNING1( aWarning, x1 ) ((void)0)
-#define DBG_WARNING2( aWarning, x1, x2 ) ((void)0)
-#define DBG_WARNING3( aWarning, x1, x2, x3 ) ((void)0)
-#define DBG_WARNING4( aWarning, x1, x2, x3, x4 ) ((void)0)
-#define DBG_WARNING5( aWarning, x1, x2, x3, x4, x5 ) ((void)0)
-#define DBG_WARNINGFILE( aWarning ) ((void)0)
-#define DBG_ERRORFILE( aError ) ((void)0)
-
 #define DBG_TESTSOLARMUTEX() ((void)0)
 
 #define DBG_INSTOUTTRACE( nOut ) ((void)0)
diff --git a/tools/qa/cppunit/test_reversemap.cxx b/tools/qa/cppunit/test_reversemap.cxx
index 190b4b2..caaa6d2 100644
--- a/tools/qa/cppunit/test_reversemap.cxx
+++ b/tools/qa/cppunit/test_reversemap.cxx
@@ -38,11 +38,11 @@
 #include "cppunit/TestFixture.h"
 #include "cppunit/extensions/HelperMacros.h"
 #include "cppunit/plugin/TestPlugIn.h"
+#include "rtl/oustringostreaminserter.hxx"
 #include <rtl/ustring.hxx>
 #include <vector>
 
 #include "tools/tenccvt.hxx"
-#include "unotest/oustringostreaminserter.hxx"
 
 //Tests for getBestMSEncodingByChar
 
diff --git a/tools/source/debug/debug.cxx b/tools/source/debug/debug.cxx
index b2b6367..d3f2c08 100644
--- a/tools/source/debug/debug.cxx
+++ b/tools/source/debug/debug.cxx
@@ -50,6 +50,7 @@
 
 #include <tools/debug.hxx>
 #include <rtl/string.h>
+#include <sal/log.h>
 #include <sal/macros.h>
 
 #include <vector>
@@ -60,22 +61,6 @@
 
 #ifdef DBG_UTIL
 
-// --- DbgErrors ---
-
-static sal_Char const DbgError_ProfEnd1[]   = "DBG_PROF...() without DBG_PROFSTART(): ";
-static sal_Char const DbgError_Xtor1[]      = "DBG_DTOR() or DBG_CHKTHIS() without DBG_CTOR(): ";
-
-static sal_Char const DbgError_CtorDtor1[]  = "this == NULL in class ";
-static sal_Char const DbgError_CtorDtor2[]  = "invalid this-Pointer %p in class ";
-static sal_Char const DbgError_CtorDtor3[]  = "Error-Msg from Object %p in class ";
-
-static sal_Char const DbgTrace_EnterCtor[]  = "Enter Ctor from class ";
-static sal_Char const DbgTrace_LeaveCtor[]  = "Leave Ctor from class ";
-static sal_Char const DbgTrace_EnterDtor[]  = "Enter Dtor from class ";
-static sal_Char const DbgTrace_LeaveDtor[]  = "Leave Dtor from class ";
-static sal_Char const DbgTrace_EnterMeth[]  = "Enter method from class ";
-static sal_Char const DbgTrace_LeaveMeth[]  = "Leave method from class ";
-
 // --- PointerList ---
 
 #define PBLOCKCOUNT     1024
@@ -1345,14 +1330,13 @@ void DbgProf( sal_uInt16 nAction, DbgDataType* pDbgData )
     if ( !(pData->aDbgData.nTestFlags & DBG_TEST_PROFILING) )
         return;
 
-    sal_Char    aBuf[DBG_BUF_MAXLEN];
     ProfType*   pProfData = (ProfType*)pDbgData->pData;
     sal_uIntPtr       nTime;
     if ( (nAction != DBG_PROF_START) && !pProfData )
     {
-        strcpy( aBuf, DbgError_ProfEnd1 );
-        strcat( aBuf, pDbgData->pName );
-        DbgError( aBuf );
+        SAL_WARN_S(
+            "tools.debug",
+            "DBG_PROF...() without DBG_PROFSTART(): " << pDbgData->pName);
         return;
     }
 
@@ -1387,7 +1371,8 @@ void DbgProf( sal_uInt16 nAction, DbgDataType* pDbgData )
 
             if ( pProfData->nStart == 0xFFFFFFFF )
             {
-                DbgError( DbgError_ProfEnd1 );
+                SAL_WARN(
+                    "tools.debug", "DBG_PROF...() without DBG_PROFSTART()");
                 return;
             }
 
@@ -1467,25 +1452,15 @@ void DbgXtor( DbgDataType* pDbgData, sal_uInt16 nAction, const void* pThis,
     if ( !pXtorData->bTest )
         return;
 
-    sal_Char    aBuf[DBG_BUF_MAXLEN];
     sal_uInt16      nAct = nAction & ~DBG_XTOR_DTOROBJ;
 
-    // Trace (Enter)
-    if ( (pData->aDbgData.nTestFlags & DBG_TEST_XTOR_TRACE) &&
-         !(nAction & DBG_XTOR_DTOROBJ) )
-    {
-        if ( nAct != DBG_XTOR_CHKOBJ )
-        {
-            if ( nAct == DBG_XTOR_CTOR )
-                strcpy( aBuf, DbgTrace_EnterCtor );
-            else if ( nAct == DBG_XTOR_DTOR )
-                strcpy( aBuf, DbgTrace_EnterDtor );
-            else
-                strcpy( aBuf, DbgTrace_EnterMeth );
-            strcat( aBuf, pDbgData->pName );
-            DbgTrace( aBuf );
-        }
-    }
+    SAL_INFO_IF_S(
+        ((pData->aDbgData.nTestFlags & DBG_TEST_XTOR_TRACE)
+         && !(nAction & DBG_XTOR_DTOROBJ) && nAct != DBG_XTOR_CHKOBJ),
+        "tools.debug",
+        (nAct == DBG_XTOR_CTOR ? "Enter Ctor from class "
+         : nAct == DBG_XTOR_DTOR ? "Enter Dtor from class "
+         : "Enter method from class ") << pDbgData->pName);
 
     // Sind noch Xtor-Tests als Trace an
     if ( pData->aDbgData.nTestFlags & DBG_TEST_XTOR_EXTRA )
@@ -1493,9 +1468,10 @@ void DbgXtor( DbgDataType* pDbgData, sal_uInt16 nAction, const void* pThis,
         // DBG_CTOR-Aufruf vor allen anderen DBG_XTOR-Aufrufen
         if ( ((nAction & ~DBG_XTOR_DTOROBJ) != DBG_XTOR_CTOR) && !pDbgData->pData )
         {
-            strcpy( aBuf, DbgError_Xtor1 );
-            strcat( aBuf, pDbgData->pName );
-            DbgError( aBuf );
+            SAL_WARN_S(
+                "tools.debug",
+                "DBG_DTOR() or DBG_CHKTHIS() without DBG_CTOR(): "
+                    << pDbgData->pName);
             return;
         }
 
@@ -1508,20 +1484,17 @@ void DbgXtor( DbgDataType* pDbgData, sal_uInt16 nAction, const void* pThis,
                 // This-Pointer == NULL
                 if ( !pThis )
                 {
-                    strcpy( aBuf, DbgError_CtorDtor1 );
-                    strcat( aBuf, pDbgData->pName );
-                    DbgError( aBuf );
+                    SAL_WARN_S(
+                        "tools.debug",
+                        "this == NULL in class " << pDbgData->pName);
                     return;
                 }
 
                 if ( (nAction & ~DBG_XTOR_DTOROBJ) != DBG_XTOR_CTOR )
                 {
-                    if ( !pXtorData->aThisList.IsIn( pThis ) )
-                    {
-                        sprintf( aBuf, DbgError_CtorDtor2, pThis );
-                        strcat( aBuf, pDbgData->pName );
-                        DbgError( aBuf );
-                    }
+                    SAL_WARN_IF_S(
+                        !pXtorData->aThisList.IsIn(pThis), "tools.debug",
+                        "invalid this-Pointer %p in class " << pDbgData->pName);
                 }
             }
         }
@@ -1585,32 +1558,21 @@ void DbgXtor( DbgDataType* pDbgData, sal_uInt16 nAction, const void* pThis,
         }
 
         // Gegebenenfalls Fehlermeldung ausgeben
-        if ( pMsg )
-        {
-            sprintf( aBuf, DbgError_CtorDtor3, pThis );
-            strcat( aBuf, pDbgData->pName );
-            strcat( aBuf, ": \n" );
-            strcat( aBuf, pMsg );
-            DbgError( aBuf );
-        }
+        SAL_WARN_IF_S(
+            pMsg, "tools.debug",
+            "Error-Msg from Object " << pThis << " in class "
+                << pDbgData->pName << ": " << pMsg);
     }
 
-    // Trace (Leave)
-    if ( (pData->aDbgData.nTestFlags & DBG_TEST_XTOR_TRACE) &&
-         (nAction & DBG_XTOR_DTOROBJ) )
-    {
-        if ( nAct != DBG_XTOR_CHKOBJ )
-        {
-            if ( nAct == DBG_XTOR_CTOR )
-                strcpy( aBuf, DbgTrace_LeaveCtor );
-            else if ( nAct == DBG_XTOR_DTOR )
-                strcpy( aBuf, DbgTrace_LeaveDtor );
-            else
-                strcpy( aBuf, DbgTrace_LeaveMeth );
-            strcat( aBuf, pDbgData->pName );
-            DbgTrace( aBuf );
-        }
-    }
+    SAL_INFO_IF_S(
+        ((pData->aDbgData.nTestFlags & DBG_TEST_XTOR_TRACE)
+         && (nAction & DBG_XTOR_DTOROBJ) && nAct != DBG_XTOR_CHKOBJ),
+        "tools.debug",
+        (nAct == DBG_XTOR_CTOR
+         ? "Leave Ctor from class "
+         : nAct == DBG_XTOR_DTOR
+         ? "Leave Dtor from class "
+         : "Leave method from class ") << pDbgData->pName);
 }
 
 // -----------------------------------------------------------------------
diff --git a/tools/source/rc/resmgr.cxx b/tools/source/rc/resmgr.cxx
index 1733e6e..2ea66b2 100644
--- a/tools/source/rc/resmgr.cxx
+++ b/tools/source/rc/resmgr.cxx
@@ -43,8 +43,10 @@
 #include <osl/file.hxx>
 #include <osl/mutex.hxx>
 #include <osl/signal.h>
+#include <rtl/oustringostreaminserter.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <rtl/strbuf.hxx>
+#include <sal/log.h>
 #include <tools/urlobj.hxx>
 #include <rtl/instance.hxx>
 #include <rtl/bootstrap.hxx>
@@ -947,11 +949,7 @@ void ResMgr::Init( const OUString& rFileName )
             InternalResMgr::FreeGlobalRes( aResHandle, pVoid );
         else
         {
-            rtl::OStringBuffer aStr(
-                RTL_CONSTASCII_STRINGPARAM("Wrong version:\n"));
-            aStr.append(rtl::OUStringToOString(pImpRes->aFileName,
-                RTL_TEXTENCODING_UTF8));
-            DbgError(aStr.getStr());
+            SAL_WARN_S("tools", "Wrong version: " << pImpRes->aFileName);
         }
     }
 #endif
diff --git a/unotest/inc/unotest/oustringostreaminserter.hxx 
b/unotest/inc/unotest/oustringostreaminserter.hxx
deleted file mode 100644
index 143c3a5..0000000
--- a/unotest/inc/unotest/oustringostreaminserter.hxx
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* Copyright 2000, 2010 Oracle and/or its affiliates.
-*
-* OpenOffice.org - a multi-platform office productivity suite
-*
-* This file is part of OpenOffice.org.
-*
-* OpenOffice.org is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Lesser General Public License version 3
-* only, as published by the Free Software Foundation.
-*
-* OpenOffice.org is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU Lesser General Public License version 3 for more details
-* (a copy is included in the LICENSE file that accompanied this code).
-*
-* You should have received a copy of the GNU Lesser General Public License
-* version 3 along with OpenOffice.org.  If not, see
-* <http://www.openoffice.org/license.html>
-* for a copy of the LGPLv3 License.
-************************************************************************/
-
-#ifndef INCLUDED_TEST_OUSTRINGOSTREAMINSERTER_HXX
-#define INCLUDED_TEST_OUSTRINGOSTREAMINSERTER_HXX
-
-#include "sal/config.h"
-
-#include <ostream>
-
-#include "osl/thread.h"
-#include "rtl/ustring.hxx"
-
-// Include this header to support rtl::OUString in CPPUNIT_ASSERT macros.
-
-namespace rtl {
-
-template< typename charT, typename traits > std::basic_ostream<charT, traits> &
-operator <<(
-    std::basic_ostream<charT, traits> & stream, rtl::OUString const & string)
-{
-    return stream <<
-        rtl::OUStringToOString(string, osl_getThreadTextEncoding()).getStr();
-        // best effort; potentially loses data due to conversion failures and
-        // embedded null characters
-}
-
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotest/prj/d.lst b/unotest/prj/d.lst
index a173c2f..4b5c05e 100644
--- a/unotest/prj/d.lst
+++ b/unotest/prj/d.lst
@@ -13,7 +13,6 @@ mkdir: %_DEST%\inc\unotest\detail
 ..\inc\unotest\filters-test.hxx %_DEST%\inc\unotest\filters-test.hxx
 ..\inc\unotest\gettestargument.hxx %_DEST%\inc\unotest\gettestargument.hxx
 ..\inc\unotest\officeconnection.hxx %_DEST%\inc\unotest\officeconnection.hxx
-..\inc\unotest\oustringostreaminserter.hxx %_DEST%\inc\unotest\oustringostreaminserter.hxx
 ..\inc\unotest\toabsolutefileurl.hxx %_DEST%\inc\unotest\toabsolutefileurl.hxx
 ..\inc\unotest\uniquepipename.hxx %_DEST%\inc\unotest\uniquepipename.hxx
 ..\%__SRC%\class\test.jar %_DEST%\bin\test.jar
diff --git a/vcl/source/app/dbggui.cxx b/vcl/source/app/dbggui.cxx
index 468e7c8..126c56c 100755
--- a/vcl/source/app/dbggui.cxx
+++ b/vcl/source/app/dbggui.cxx
@@ -39,6 +39,7 @@
 #include <limits.h>
 
 #include "tools/debug.hxx"
+#include "sal/log.h"
 
 #include "vcl/svapp.hxx"
 #include "vcl/event.hxx"
@@ -1454,10 +1455,12 @@ void DbgDialogTest( Window* pWindow )
 
         if ( bButton )
         {
-            if ( !bOKCancelButton )
-                DbgError( "Dialogs should have a OK- or CancelButton" );
-            if ( !bDefPushButton )
-                DbgError( "Dialogs should have a Button with WB_DEFBUTTON" );
+            SAL_WARN_IF(
+                !bOKCancelButton, "vcl",
+                "Dialogs should have a OK- or CancelButton");
+            SAL_WARN_IF(
+                !bDefPushButton, "vcl",
+                "Dialogs should have a Button with WB_DEFBUTTON");
         }
     }
 
@@ -1626,15 +1629,12 @@ void DbgDialogTest( Window* pWindow )
                 }
             }
 
-            if ( pChild->GetType() == WINDOW_MULTILINEEDIT )
-            {
-                if  (   ( 0 == ( pChild->GetStyle() & WB_IGNORETAB ) )
-                    &&  ( 0 == ( pChild->GetStyle() & WB_READONLY ) )
-                    )
-                {
-                    DbgError( "editable MultiLineEdits in Dialogs should have the Style 
WB_IGNORETAB" );
-                }
-            }
+            SAL_WARN_IF(
+                (pChild->GetType() == WINDOW_MULTILINEEDIT
+                 && (pChild->GetStyle() & (WB_IGNORETAB | WB_READONLY)) == 0),
+                "vcl",
+                ("editable MultiLineEdits in Dialogs should have the Style"
+                 " WB_IGNORETAB"));
 
             if ( (pChild->GetType() == WINDOW_RADIOBUTTON) ||
                  (pChild->GetType() == WINDOW_IMAGERADIOBUTTON) ||
diff --git a/binfilter/bf_basic/source/sbx/sbxbase.cxx b/binfilter/bf_basic/source/sbx/sbxbase.cxx
index 7ffbdd5..691030b 100644
--- a/binfilter/bf_basic/source/sbx/sbxbase.cxx
+++ b/binfilter/bf_basic/source/sbx/sbxbase.cxx
@@ -26,6 +26,8 @@
  *
  ************************************************************************/
 
+#include <rtl/oustringostreaminserter.hxx>
+#include <sal/log.h>
 #include <tools/stream.hxx>
 
 #include "sbx.hxx"
@@ -202,7 +204,7 @@ SbxBase* SbxBase::Create( UINT16 nSbxId, UINT32 nCreator )
     return pNew;
 }
 
-SbxObject* SbxBase::CreateObject( const XubString& rClass )
+SbxObject* SbxBase::CreateObject( const rtl::OUString& rClass )
 {
     SbxAppData* p = GetSbxData_Impl();
     SbxObject* pNew = NULL;
@@ -212,15 +214,7 @@ SbxObject* SbxBase::CreateObject( const XubString& rClass )
         if( pNew )
             break;
     }
-#ifdef DBG_UTIL
-    if( !pNew )
-    {
-        ByteString aMsg( "SBX: Keine Factory fuer Objektklasse " );
-        ByteString aClassStr( (const UniString&)rClass, RTL_TEXTENCODING_ASCII_US );
-        aMsg += aClassStr;
-        DbgError( (const char*)aMsg.GetBuffer() );
-    }
-#endif
+    SAL_WARN_IF_S(!pNew, "binfilter", "No factory for object class " << rClass);
     return pNew;
 }
 
diff --git a/binfilter/bf_basic/source/sbx/sbxobj.cxx b/binfilter/bf_basic/source/sbx/sbxobj.cxx
index 4b515d0..7bef1ac 100644
--- a/binfilter/bf_basic/source/sbx/sbxobj.cxx
+++ b/binfilter/bf_basic/source/sbx/sbxobj.cxx
@@ -375,20 +375,6 @@ SbxVariable* SbxObject::Make( const XubString& rName, SbxClassType ct, 
SbxDataTy
         SbxVariable* pRes = pArray->Find( rName, ct );
         if( pRes )
         {
-/* Wegen haeufiger Probleme (z.B. #67000) erstmal ganz raus
-#ifdef DBG_UTIL
-            if( pRes->GetHashCode() != nNameHash
-             && pRes->GetHashCode() != nParentHash )
-            {
-                XubString aMsg( "SBX-Element \"" );
-                aMsg += pRes->GetName();
-                aMsg += "\"\n in Objekt \"";
-                aMsg += GetName();
-                aMsg += "\" bereits vorhanden";
-                DbgError( (const char*)aMsg.GetStr() );
-            }
-#endif
-*/
             return pRes;
         }
     }
diff --git a/binfilter/bf_svtools/source/inc/poolio.hxx b/binfilter/bf_svtools/source/inc/poolio.hxx
index 6b2088b..6b515ce 100644
--- a/binfilter/bf_svtools/source/inc/poolio.hxx
+++ b/binfilter/bf_svtools/source/inc/poolio.hxx
@@ -122,17 +122,8 @@ struct SfxItemPool_Impl
 #endif
 
 #if defined(DBG_UTIL) && defined(MSC)
-#define SFX_TRACE(s,p) \
-        { \
-            ByteString aPtr(RTL_CONSTASCII_STRINGPARAM("0x0000:0x0000")); \
-            _snprintf(const_cast< sal_Char *>(aPtr.GetBuffer()), aPtr.Len(), \
-                       "%lp", p ); \
-            aPtr.Insert(s, 0); \
-            DbgTrace( aPtr.GetBuffer() ); \
-        }
 #define DBG(x) x
 #else
-#define SFX_TRACE(s,p)
 #define DBG(x)
 #endif
 
diff --git a/binfilter/bf_svtools/source/items1/svt_itempool.cxx 
b/binfilter/bf_svtools/source/items1/svt_itempool.cxx
index 06610ad..2b691ca 100644
--- a/binfilter/bf_svtools/source/items1/svt_itempool.cxx
+++ b/binfilter/bf_svtools/source/items1/svt_itempool.cxx
@@ -832,7 +832,6 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem )
             else
             {
                 SFX_ASSERT( 0, rItem.Which(), "removing Item without ref" );
-                SFX_TRACE( "to be removed, but not no refs: ", *ppHtArr );
             }
 
             // ggf. kleinstmoegliche freie Position merken
@@ -849,7 +848,6 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem )
 
     // nicht vorhanden
     SFX_ASSERT( 0, rItem.Which(), "removing Item not in Pool" );
-    SFX_TRACE( "to be removed, but not in pool: ", &rItem );
 }
 
 // -----------------------------------------------------------------------
diff --git a/binfilter/bf_svtools/source/items1/svt_poolio.cxx 
b/binfilter/bf_svtools/source/items1/svt_poolio.cxx
index 0d453dc..cd2426e 100644
--- a/binfilter/bf_svtools/source/items1/svt_poolio.cxx
+++ b/binfilter/bf_svtools/source/items1/svt_poolio.cxx
@@ -31,6 +31,7 @@
 #include <string.h>
 #include <stdio.h>
 
+#include <sal/log.h>
 #include <bf_svtools/bf_solar.h>
 #include <bf_svtools/itempool.hxx>
 #include "whassert.hxx"
@@ -668,13 +669,13 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
                                 delete rpNewItem;
                                 rpNewItem = pOldItem;
                                 bFound = TRUE;
-                                SFX_TRACE( "reusing item", pOldItem );
+                                SAL_INFO_S(
+                                    "binfilter", "reusing item" << pOldItem);
                             }
                         }
-                        if ( !bFound )
-                        {
-                            SFX_TRACE( "item not found: ", pOldItem );
-                        }
+                        SAL_INFO_IF_S(
+                            !bFound, "binfilter",
+                            "item not found: " << pOldItem);
                     }
                 }
             }
diff --git a/binfilter/inc/bf_basic/sbxcore.hxx b/binfilter/inc/bf_basic/sbxcore.hxx
index 582e46f..1f6fca9 100644
--- a/binfilter/inc/bf_basic/sbxcore.hxx
+++ b/binfilter/inc/bf_basic/sbxcore.hxx
@@ -41,6 +41,7 @@
 class SvStream;
 class String;
 class UniString;
+namespace rtl { class OUString; }
 
 // Das nachfolgende Makro definiert die vier  (fuenf) notwendigen Methoden
 // innerhalb eines SBX-Objekts. LoadPrivateData() und StorePrivateData()
@@ -138,7 +139,7 @@ public:
     static void RemoveFactory( SbxFactory* );
 
     static SbxBase* Create( UINT16, UINT32=SBXCR_SBX );
-    static SbxObject* CreateObject( const String& );
+    static SbxObject* CreateObject( const rtl::OUString& );
     // Sbx-Loesung als Ersatz fuer SfxBroadcaster::Enable()
     static BOOL StaticIsEnabledBroadcasting( void );
 };
diff --git a/binfilter/legacysmgr/source/legacy/legacy_binfilters_smgr.cxx 
b/binfilter/legacysmgr/source/legacy/legacy_binfilters_smgr.cxx
index 952e278..dc1a1af 100644
--- a/binfilter/legacysmgr/source/legacy/legacy_binfilters_smgr.cxx
+++ b/binfilter/legacysmgr/source/legacy/legacy_binfilters_smgr.cxx
@@ -25,16 +25,22 @@
  * for a copy of the LGPLv3 License.
  *
  ************************************************************************/
+
+#include "sal/config.h"
+
+#include <cassert>
+
 #include <boost/unordered_map.hpp>
 #include <boost/unordered_set.hpp>
 #include <list>
 
-#include "osl/diagnose.h"
 #include "osl/file.hxx"
 #include "osl/process.h"
 #include "rtl/bootstrap.hxx"
+#include "rtl/oustringostreaminserter.hxx"
 #include "rtl/ustrbuf.hxx"
 #include "rtl/unload.h"
+#include "sal/log.h"
 
 #include "uno/dispatcher.h"
 
@@ -483,13 +489,17 @@ void OServiceManager_Listener::disposing(const EventObject & rEvt )
         {
             x->remove( Any( &rEvt.Source, ::getCppuType( (const Reference<XInterface > *)0 ) ) );
         }
-        catch( const IllegalArgumentException & )
+        catch( const IllegalArgumentException & e )
         {
-            OSL_FAIL( "IllegalArgumentException catched" );
+            (void) e; // avoid warnings
+            SAL_WARN_S(
+                "binfilter", "IllegalArgumentException caught: " << e.Message);
         }
-        catch( const NoSuchElementException & )
+        catch( const NoSuchElementException & e )
         {
-            OSL_FAIL( "NoSuchElementException catched" );
+            (void) e; // avoid warnings
+            SAL_WARN_S(
+                "binfilter", "NoSuchElementException caught: " << e.Message);
         }
     }
 }
@@ -794,14 +804,13 @@ void OServiceManager::disposing()
             if( xComp.is() )
                 xComp->dispose();
         }
-        catch (const RuntimeException & exc)
+        catch (const RuntimeException & e)
         {
-#ifdef DEBUG
-            OString str( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
-            OSL_TRACE( "### RuntimeException occurred upon disposing factory: %s", str.getStr() );
-#else
-            (void)exc;
-#endif
+            (void) e; // avoid warnings
+            SAL_WARN_S(
+                "binfilter",
+                "RuntimeException occurred upon disposing factory: "
+                    << e.Message);
         }
     }
 
@@ -820,7 +829,7 @@ void OServiceManager::disposing()
     m_xContext.clear();
 
     // not only the Event should hold the object
-    OSL_ASSERT( m_refCount != 1 );
+    SAL_WARN_IF(m_refCount == 1, "binfilter", "only Event holds object");
 
     // Revoke this service manager as unloading listener
     rtl_removeUnloadingListener( m_nUnloadingListenerId);
@@ -997,23 +1006,20 @@ Reference< XInterface > OServiceManager::createInstanceWithContext(
                     Reference< XSingleServiceFactory > xFac2( xFactory, UNO_QUERY );
                     if (xFac2.is())
                     {
-#ifdef DEBUG
-                        OString aStr( OUStringToOString( rServiceSpecifier, 
RTL_TEXTENCODING_ASCII_US ) );
-                        OSL_TRACE( "### ignoring given context raising service %s !!!\n", 
aStr.getStr() );
-#endif
+                        SAL_INFO_S(
+                            "binfilter",
+                            "ignoring given context raising service "
+                                << rServiceSpecifier);
                         return xFac2->createInstance();
                     }
                 }
             }
         }
-        catch (const lang::DisposedException & exc)
+        catch (const lang::DisposedException & e)
         {
-#ifdef DEBUG
-            OString str( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
-            OSL_TRACE( "### DisposedException occurred: %s", str.getStr() );
-#else
-            (void)exc;
-#endif
+            (void) e; // avoid warnings
+            SAL_WARN_S(
+                "binfilter", "DisposedException occurred: " << e.Message);
         }
     }
 
@@ -1048,23 +1054,20 @@ Reference< XInterface > 
OServiceManager::createInstanceWithArgumentsAndContext(
                     Reference< XSingleServiceFactory > xFac2( xFactory, UNO_QUERY );
                     if (xFac2.is())
                     {
-#ifdef DEBUG
-                        OString aStr( OUStringToOString( rServiceSpecifier, 
RTL_TEXTENCODING_ASCII_US ) );
-                        OSL_TRACE( "### ignoring given context raising service %s !!!\n", 
aStr.getStr() );
-#endif
+                        SAL_INFO_S(
+                            "binfilter",
+                            "ignoring given context raising service "
+                                << rServiceSpecifier);
                         return xFac2->createInstanceWithArguments( rArguments );
                     }
                 }
             }
         }
-        catch (const lang::DisposedException & exc)
+        catch (const lang::DisposedException & e)
         {
-#ifdef DEBUG
-            OString str( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
-            OSL_TRACE( "### DisposedException occurred: %s", str.getStr() );
-#else
-            (void)exc;
-#endif
+            (void) e; // avoid warnings
+            SAL_WARN_S(
+                "binfilter", "DisposedException occurred: " << e.Message);
         }
     }
 
@@ -1105,7 +1108,7 @@ void OServiceManager::initialize( Sequence< Any > const & )
     throw (Exception)
 {
     check_undisposed();
-    OSL_FAIL( "not impl!" );
+    SAL_WARN("binfilter", "not impl!");
 }
 
 // XServiceInfo
@@ -1502,7 +1505,8 @@ Reference<XInterface > ORegistryServiceManager::loadWithImplementationName(
 
         if( xImpKey.is() )
         {
-            OSL_ASSERT( s_xLegacyMgr.is() );
+            SAL_WARN_IF(
+                !s_xLegacyMgr.is(), "binfilter", "no legacy service manager");
             ret = createSingleRegistryFactory(
                 s_xLegacyMgr.is()
                 ? s_xLegacyMgr
@@ -1593,7 +1597,7 @@ void ORegistryServiceManager::initialize(const Sequence< Any >& Arguments)
     }
 #if defined _DEBUG
     // to find all bootstrapping processes to be fixed...
-    OSL_ENSURE( !m_init, "### second init of service manager instance!" );
+    SAL_WARN_IF(m_init, "binfilter", "second init of service manager instance");
     m_init = true;
 #endif
 }
@@ -1762,12 +1766,16 @@ public:
     }
     virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw (RuntimeException)
     {
-        OSL_FAIL( "### unexpected call LegacyServiceManager::supportsService()!" );
+        SAL_WARN(
+            "binfilter",
+            "unexpected call LegacyServiceManager::supportsService()");
         return m_xOfficeMgr_si->supportsService( ServiceName );
     }
     virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (RuntimeException)
     {
-        OSL_FAIL( "### unexpected call LegacyServiceManager::getSupportedServiceNames()!" );
+        SAL_WARN(
+            "binfilter",
+            "unexpected call LegacyServiceManager::getSupportedServiceNames()");
         return m_xOfficeMgr_si->getSupportedServiceNames();
     }
 
@@ -2000,13 +2008,13 @@ void * SAL_CALL legacysmgr_component_getFactory(
     lang::XMultiServiceFactory * smgr,
     registry::XRegistryKey * key )
 {
+    assert(smgr != 0);
     try
     {
         if (! s_xLegacyMgr.is())
         {
             // * office mgr *
             Reference< lang::XMultiServiceFactory > xMgr( smgr );
-            OSL_ASSERT( xMgr.is() );
             Reference< beans::XPropertySet > xProps( xMgr, UNO_QUERY_THROW );
             Reference< XComponentContext > xOfficeContext(
                 xProps->getPropertyValue( OUSTR("DefaultContext") ),
@@ -2083,15 +2091,13 @@ void * SAL_CALL legacysmgr_component_getFactory(
         return component_getFactoryHelper(
             implName, s_xLegacyMgr.get(), key, s_entries );
     }
-    catch (const Exception & exc)
+    catch (const Exception & e)
     {
-        (void) exc; // avoid warnings
-        OSL_FAIL(
-            OSL_FORMAT(
-                ("unexpected exception in legacysmgr_component_getFactory:"
-                 " \"%s\""),
-                (rtl::OUStringToOString(exc.Message, RTL_TEXTENCODING_UTF8).
-                 getStr())));
+        (void) e; // avoid warnings
+        SAL_WARN_S(
+            "binfilter",
+            "unexpected exception in legacysmgr_component_getFactory: \""
+                << e.Message << '"');
     }
     return 0;
 }

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.