[Libreoffice-commits] core.git: Branch 'feature/cib_contract57' - 2 commits - bridges/source sal/osl
Samuel Mehrbrodt
Samuel.Mehrbrodt at cib.de
Wed Jan 11 10:23:18 UTC 2017
Rebased ref, commits from common ancestor:
commit 07a6c16a19551ddc057a30c647fc29dcce48a567
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date: Wed Dec 21 21:16:49 2016 +0100
bridges win32/64: Log uno method calls
Change-Id: Ib18aea5e6ecf54dfabe9f417d5b288625dab0fb7
diff --git a/bridges/source/cpp_uno/msvc_win32_intel/cpp2uno.cxx b/bridges/source/cpp_uno/msvc_win32_intel/cpp2uno.cxx
index 58e4d64..e2f5976 100644
--- a/bridges/source/cpp_uno/msvc_win32_intel/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/msvc_win32_intel/cpp2uno.cxx
@@ -241,6 +241,13 @@ static typelib_TypeClass __cdecl cpp_mediate(
pThis);
typelib_InterfaceTypeDescription * pTypeDescr = pCppI->getTypeDescr();
+
+ SAL_INFO( "bridges.win32", "cpp_vtable_call: pCallStack=[" <<
+ std::hex << pCallStack[0] << "," << pCallStack[1] << "," << pCallStack[2] << ",...]" <<
+ ", pThis=" << pThis << ", pCppI=" << pCppI <<
+ std::dec << ", nFunctionIndex=" << nFunctionIndex << ", nVtableOffset=" << nVtableOffset );
+ SAL_INFO( "bridges.win32", "name=" << pTypeDescr->aBase.pTypeName );
+
if (nFunctionIndex >= pTypeDescr->nMapFunctionIndexToMemberIndex)
{
SAL_WARN(
@@ -261,6 +268,8 @@ static typelib_TypeClass __cdecl cpp_mediate(
TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] );
+ SAL_INFO( "bridges.win32", "Calling " << aMemberDescr.get()->pTypeName );
+
typelib_TypeClass eRet = typelib_TypeClass_VOID;
switch (aMemberDescr.get()->eTypeClass)
{
diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx b/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx
index 4f1905c..14776e7 100644
--- a/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx
@@ -240,6 +240,12 @@ extern "C" typelib_TypeClass cpp_vtable_call(
typelib_InterfaceTypeDescription * pTD = pCppI->getTypeDescr();
+ SAL_INFO( "bridges.win64", "cpp_vtable_call: pCallStack=[" <<
+ std::hex << pStack[0] << "," << pStack[1] << "," << pStack[2] << ",...]" <<
+ ", pThis=" << pThis << ", pCppI=" << pCppI <<
+ std::dec << ", nFunctionIndex=" << nFunctionIndex << ", nVtableOffset=" << nVtableOffset );
+ SAL_INFO( "bridges.win64", "name=" << pTD->aBase.pTypeName );
+
if ( nFunctionIndex >= pTD->nMapFunctionIndexToMemberIndex )
{
SAL_WARN(
@@ -260,6 +266,8 @@ extern "C" typelib_TypeClass cpp_vtable_call(
TypeDescription aMemberDescr( pTD->ppAllMembers[nMemberPos] );
+ SAL_INFO( "bridges.win64", "Calling " << aMemberDescr.get()->pTypeName );
+
typelib_TypeClass eRet;
switch ( aMemberDescr.get()->eTypeClass )
{
commit e06a339e37929af1132cd454e2fbd412ad55c3a5
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date: Wed Dec 21 21:15:49 2016 +0100
Allow to set log level/path in file
Expects a file logging.txt in the program/ directory
with the keys LogFilePath and LogLevel, e.g.:
LogFilePath=C:\\log.txt
LogLevel=info
Change-Id: I35c730469e4079139da908aa287b989dc98e0f9d
diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
index 9a8663c..326d44e 100644
--- a/sal/osl/all/log.cxx
+++ b/sal/osl/all/log.cxx
@@ -22,6 +22,7 @@
#include <fstream>
#include "osl/thread.hxx"
+#include "osl/process.h"
#include "rtl/string.h"
#include "sal/detail/log.h"
#include "sal/log.hxx"
@@ -81,7 +82,7 @@ char const * toString(sal_detail_LogLevel level) {
// the process is running":
#if defined ANDROID
-char const * getEnvironmentVariable() {
+char const * getLogLevel() {
return std::getenv("SAL_LOG");
}
@@ -99,14 +100,62 @@ char const * getEnvironmentVariable_(const char* env) {
return p2;
}
-char const * getEnvironmentVariable() {
+bool getValueFromLoggingIniFile(const char* key, char* value) {
+ OUString programDirectoryURL;
+ OUString programDirectoryPath;
+ osl_getProcessWorkingDir(&(programDirectoryURL.pData));
+ osl_getSystemPathFromFileURL(programDirectoryURL.pData, &programDirectoryPath.pData);
+ OUString aLogFile(programDirectoryPath + "/" + "logging.ini");
+ std::ifstream logFileStream(OUStringToOString( aLogFile, RTL_TEXTENCODING_ASCII_US).getStr());
+ if (!logFileStream.good())
+ return false;
+
+ std::size_t n;
+ std::string aKey;
+ std::string aValue;
+ std::string sWantedKey(key);
+ std::string sLine;
+ while (std::getline(logFileStream, sLine)) {
+ if (sLine.find('#') == 0)
+ continue;
+ if ( ( n = sLine.find('=') ) != std::string::npos) {
+ aKey = sLine.substr(0, n);
+ if (aKey != sWantedKey)
+ continue;
+ aValue = sLine.substr(n+1, sLine.length());
+ sprintf(value, "%s", aValue.c_str());
+ return true;
+ }
+ }
+ return false;
+}
+
+char const * getLogLevel() {
+ // First check the environment variable, then the setting in logging.ini
static char const * env = getEnvironmentVariable_("SAL_LOG");
- return env;
+ if (env != nullptr)
+ return env;
+
+ static char logLevel[1024];
+ if (getValueFromLoggingIniFile("LogLevel", logLevel)) {
+ return logLevel;
+ }
+
+ return nullptr;
}
char const * getLogFile() {
+ // First check the environment variable, then the setting in logging.ini
static char const * logFile = getEnvironmentVariable_("SAL_LOG_FILE");
- return logFile;
+ if (logFile != nullptr)
+ return logFile;
+
+ static char logFilePath[1024];
+ if (getValueFromLoggingIniFile("LogFilePath", logFilePath)) {
+ return logFilePath;
+ }
+
+ return nullptr;
}
#endif
@@ -115,7 +164,7 @@ bool report(sal_detail_LogLevel level, char const * area) {
if (level == SAL_DETAIL_LOG_LEVEL_DEBUG)
return true;
assert(area != 0);
- char const * env = getEnvironmentVariable();
+ char const * env = getLogLevel();
if (env == 0) {
env = "+WARN";
}
More information about the Libreoffice-commits
mailing list