From 70a6b9ffbd676a1384433a86205d2cd4f2d4f4b1 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 22 Nov 2011 09:34:46 +0100 Subject: New sal/log.h obsoletes osl/diagnose.h and tools/debug.hxx. * New SAL_INFO..., SAL_WARN... macros. * New SAL_STREAM supersedes OSL_FORMAT. * oustringostreaminserter.hxx moved from unotest to rtl (and always UTF-8 now). * TODO to enable GCC __attribute__((format)) in sal/log.h (requires call-site cleanup). * Further functionality in tools/debug.hxx (DBG_MEMTEST, DBG_CTOR, etc.) not yet addressed. * Some replacements tools String -> rtl::OUString. --- jvmfwk/plugins/sunmajor/pluginlib/diagnostics.h | 94 +++---------------------- jvmfwk/plugins/sunmajor/pluginlib/util.cxx | 13 ++-- 2 files changed, 12 insertions(+), 95 deletions(-) (limited to 'jvmfwk') diff --git a/jvmfwk/plugins/sunmajor/pluginlib/diagnostics.h b/jvmfwk/plugins/sunmajor/pluginlib/diagnostics.h index 6a8ef3232bc4..eb1cd03c8a8d 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 - -#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 00843ec8f03a..1b2dd2335e39 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); -- cgit