aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-10-25 07:27:07 +0000
committerMario <mario@mariovavti.com>2020-10-25 07:27:07 +0000
commit7112bcd134fcbc1c6cef6618c801e6f879d5e920 (patch)
treec4d5c87bbbf3cffe14d28125982141081702b698
parentd3d5ddfb434555373b892e127ad9faa6425af3bf (diff)
downloadvolse-hubzilla-7112bcd134fcbc1c6cef6618c801e6f879d5e920.tar.gz
volse-hubzilla-7112bcd134fcbc1c6cef6618c801e6f879d5e920.tar.bz2
volse-hubzilla-7112bcd134fcbc1c6cef6618c801e6f879d5e920.zip
bt_syslog() instead of syslog flag for btlogger
-rw-r--r--include/text.php25
1 files changed, 21 insertions, 4 deletions
diff --git a/include/text.php b/include/text.php
index 237202283..a300ccf58 100644
--- a/include/text.php
+++ b/include/text.php
@@ -659,6 +659,26 @@ function hz_syslog($msg, $priority = LOG_INFO) {
closelog();
}
+/**
+ * @brief like hz_syslog() but with a function backtrace to pinpoint certain classes
+ * of problems which show up deep in the calling stack.
+ *
+ * @param string $msg Message to log
+ * @param int $priority - compatible with syslog
+ */
+function bt_syslog($msg, $priority = LOG_INFO) {
+ $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
+ if($stack) {
+ for($x = 1; $x < count($stack); $x ++) {
+ $s = 'stack: ' . basename($stack[$x]['file']) . ':' . $stack[$x]['line'] . ':' . $stack[$x]['function'] . '()';
+ openlog("bt-log", LOG_PID | LOG_PERROR, LOG_LOCAL0);
+ syslog($priority, $msg);
+ closelog();
+ }
+ }
+}
+
+
/**
* @brief Logging function for Hubzilla.
@@ -723,7 +743,7 @@ function logid() {
* @param int $level A log level
* @param int $priority - compatible with syslog
*/
-function btlogger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO, $syslog = false) {
+function btlogger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) {
if(! defined('BTLOGGER_DEBUG_FILE'))
define('BTLOGGER_DEBUG_FILE','btlogger.out');
@@ -742,9 +762,6 @@ function btlogger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO, $syslog =
for($x = 1; $x < count($stack); $x ++) {
$s = 'stack: ' . basename($stack[$x]['file']) . ':' . $stack[$x]['line'] . ':' . $stack[$x]['function'] . '()';
logger($s,$level, $priority);
- if($syslog) {
- hz_syslog(print_r($s,true));
- }
if(file_exists(BTLOGGER_DEBUG_FILE) && is_writable(BTLOGGER_DEBUG_FILE)) {
@file_put_contents(BTLOGGER_DEBUG_FILE, $s . PHP_EOL, FILE_APPEND);
}