summaryrefslogtreecommitdiff
path: root/includes/sys_log.php
blob: 9ac17dc09ecb336b93f5a9cf438649da6166035d (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
<?php

use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;

/**
 * Write a log entry.
 * This should be used to log user's activity.
 *
 * @param string $message
 * @param string $level
 */
function engelsystem_log($message, $level = LogLevel::INFO)
{
    $nick = "Guest";
    /** @var LoggerInterface $logger */
    $logger = app('logger');
    $user = auth()->user();

    if ($user) {
        $nick = User_Nick_render($user);
    }

    $logger->log($level, '{nick}: {message}', ['nick' => $nick, 'message' => $message]);
}