summaryrefslogtreecommitdiff
path: root/sal/osl/all
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2016-12-08 11:22:37 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-01-10 06:31:33 +0000
commit56d071c10ca8016848f1f059aa3eb197fe928844 (patch)
tree956ba2f8f51a7845c603aa0875e83d40d8938e68 /sal/osl/all
parent014b9ac2e4ec22a1eed2fde806edd7a840035a45 (diff)
rename SAL_DEBUG_TRACE to SAL_DEBUG_BACKTRACE
since "trace" is such a generic term, this makes it easier to actually find the feature when you need it. And add feature to limit stack depth of the reported backtrace. Change-Id: Iab3e4ceb2e8480e7b5e2b920eb6c5d7631e21c43 Reviewed-on: https://gerrit.libreoffice.org/31752 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sal/osl/all')
-rw-r--r--sal/osl/all/log.cxx29
1 files changed, 20 insertions, 9 deletions
diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
index 23f45cdb4875..7245a51000b4 100644
--- a/sal/osl/all/log.cxx
+++ b/sal/osl/all/log.cxx
@@ -68,7 +68,6 @@ char const * toString(sal_detail_LogLevel level) {
case SAL_DETAIL_LOG_LEVEL_WARN:
return "warn";
case SAL_DETAIL_LOG_LEVEL_DEBUG:
- case SAL_DETAIL_LOG_LEVEL_DEBUG_TRACE:
return "debug";
default:
assert(false); // this cannot happen
@@ -188,8 +187,7 @@ void maybeOutputTimestamp(std::ostringstream &s) {
#endif
bool isDebug(sal_detail_LogLevel level) {
- return level == SAL_DETAIL_LOG_LEVEL_DEBUG ||
- level == SAL_DETAIL_LOG_LEVEL_DEBUG_TRACE;
+ return level == SAL_DETAIL_LOG_LEVEL_DEBUG;
}
bool report(sal_detail_LogLevel level, char const * area) {
@@ -298,10 +296,6 @@ void log(
}
s << message;
- if (level == SAL_DETAIL_LOG_LEVEL_DEBUG_TRACE) {
- s << " at:\n";
- s << OUString(osl_backtraceAsString(), SAL_NO_ACQUIRE);
- }
s << '\n';
#if defined ANDROID
@@ -314,7 +308,6 @@ void log(
android_log_level = ANDROID_LOG_WARN;
break;
case SAL_DETAIL_LOG_LEVEL_DEBUG:
- case SAL_DETAIL_LOG_LEVEL_DEBUG_TRACE:
android_log_level = ANDROID_LOG_DEBUG;
break;
default:
@@ -336,7 +329,6 @@ void log(
prio = LOG_WARNING;
break;
case SAL_DETAIL_LOG_LEVEL_DEBUG:
- case SAL_DETAIL_LOG_LEVEL_DEBUG_TRACE:
prio = LOG_DEBUG;
break;
default:
@@ -359,6 +351,16 @@ void log(
#endif
}
+void log_backtrace(
+ sal_detail_LogLevel level, char const * area, char const * where,
+ char const * message, int maxNoStackFramesToDisplay)
+{
+ OUString buff = OUString::createFromAscii(message) +
+ " at:\n" +
+ OUString(osl_backtraceAsString(maxNoStackFramesToDisplay), SAL_NO_ACQUIRE);
+ log(level, area, where, buff.toUtf8().getStr());
+}
+
}
void sal_detail_log(
@@ -370,6 +372,15 @@ void sal_detail_log(
}
}
+void sal_detail_log_backtrace(
+ sal_detail_LogLevel level, char const * area, char const * where,
+ char const * message, int maxNoStackFramesToDisplay)
+{
+ if (report(level, area)) {
+ log_backtrace(level, area, where, message, maxNoStackFramesToDisplay);
+ }
+}
+
void sal_detail_logFormat(
sal_detail_LogLevel level, char const * area, char const * where,
char const * format, ...)