aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2016-12-21 23:35:54 -0800
committerzotlabs <mike@macgirvin.com>2016-12-21 23:35:54 -0800
commitf2bfdfdeddea86784ce2d17b3c35e46a1c582b79 (patch)
tree5845446bc4aaf9305e33e8392906f00afd1a027d /include/text.php
parent9d49faca614a08d2414f657619ad56db414c230b (diff)
downloadvolse-hubzilla-f2bfdfdeddea86784ce2d17b3c35e46a1c582b79.tar.gz
volse-hubzilla-f2bfdfdeddea86784ce2d17b3c35e46a1c582b79.tar.bz2
volse-hubzilla-f2bfdfdeddea86784ce2d17b3c35e46a1c582b79.zip
provide separate logging (if configured) for btlogger which is used to catch really subtle issues which don't always leave an audit trail. Similar to dbfail.out, the file btlogger.out (if it exists and is write-able) will only log these unusual situations with backtraces so we can find the culprits.
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php15
1 files changed, 14 insertions, 1 deletions
diff --git a/include/text.php b/include/text.php
index d6151d8ef..c4fafd8ef 100644
--- a/include/text.php
+++ b/include/text.php
@@ -656,11 +656,24 @@ function logger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) {
function btlogger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) {
logger($msg, $level, $priority);
+
+ if(file_exists('btlogger.log') && is_writable('btlogger.log')) {
+ $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
+ $where = basename($stack[0]['file']) . ':' . $stack[0]['line'] . ':' . $stack[1]['function'] . ': ';
+ $s = datetime_convert() . ':' . log_priority_str($priority) . ':' . session_id() . ':' . $where . $msg . PHP_EOL;
+ @file_put_contents('btlogger.log', $s, FILE_APPEND);
+ }
+
if(version_compare(PHP_VERSION, '5.4.0') >= 0) {
$stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
if($stack) {
for($x = 1; $x < count($stack); $x ++) {
- logger('stack: ' . basename($stack[$x]['file']) . ':' . $stack[$x]['line'] . ':' . $stack[$x]['function'] . '()',$level, $priority);
+ $s = 'stack: ' . basename($stack[$x]['file']) . ':' . $stack[$x]['line'] . ':' . $stack[$x]['function'] . '()';
+ logger($s,$level, $priority);
+
+ if(file_exists('btlogger.log') && is_writable('btlogger.log')) {
+ @file_put_contents('btlogger.log', $s, FILE_APPEND);
+ }
}
}
}