summaryrefslogtreecommitdiff
path: root/includes/sys_log.php
blob: b253d6ad1fa417d437f18ee02b81f3e59c1e8d25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php

/**
 * Write a log entry.
 * This should be used to log user's activity.
 *
 * @param string $message
 */
function engelsystem_log($message)
{
    global $user;

    $nick = "Guest";
    if (isset($user)) {
        $nick = User_Nick_render($user);
    }
    LogEntry_create($nick, $message);
}

/**
 * Generates a PHP Stacktrace.
 *
 * @return string
 */
function debug_string_backtrace()
{
    ob_start();
    debug_print_backtrace();
    $trace = ob_get_contents();
    ob_end_clean();

    // Remove first item from backtrace as it's this function which
    // is redundant.
    $trace = preg_replace('/^#0\s+' . __FUNCTION__ . "[^\n]*\n/", '', $trace, 1);

    // Renumber backtrace items.
    // $trace = preg_replace('/^#(\d+)/me', '\'#\' . ($1 - 1)', $trace);

    return $trace;
}