summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/model/LogEntries_model.php12
-rw-r--r--includes/pages/admin_log.php8
-rw-r--r--includes/sys_log.php6
3 files changed, 13 insertions, 13 deletions
diff --git a/includes/model/LogEntries_model.php b/includes/model/LogEntries_model.php
index 0e11bf8e..f0ee6673 100644
--- a/includes/model/LogEntries_model.php
+++ b/includes/model/LogEntries_model.php
@@ -5,16 +5,16 @@ use Engelsystem\Database\DB;
/**
* Creates a log entry.
*
- * @param string $nick Username
- * @param string $message Log Message
+ * @param string $logLevel Log level
+ * @param string $message Log Message
* @return bool
*/
-function LogEntry_create($nick, $message)
+function LogEntry_create($logLevel, $message)
{
return DB::insert('
- INSERT INTO `LogEntries` (`timestamp`, `nick`, `message`)
+ INSERT INTO `LogEntries` (`timestamp`, `level`, `message`)
VALUES(?, ?, ?)
- ', [time(), $nick, $message]);
+ ', [time(), $logLevel, $message]);
}
/**
@@ -43,7 +43,7 @@ function LogEntries_filter($keyword)
return DB::select('
SELECT *
FROM `LogEntries`
- WHERE `nick` LIKE ?
+ WHERE `level` LIKE ?
OR `message` LIKE ?
ORDER BY `timestamp` DESC
',
diff --git a/includes/pages/admin_log.php b/includes/pages/admin_log.php
index 03c9abb0..694b1d5a 100644
--- a/includes/pages/admin_log.php
+++ b/includes/pages/admin_log.php
@@ -17,12 +17,10 @@ function admin_log()
if (request()->has('keyword')) {
$filter = strip_request_item('keyword');
}
- $log_entries_source = LogEntries_filter($filter);
+ $log_entries = LogEntries_filter($filter);
- $log_entries = [];
- foreach ($log_entries_source as $log_entry) {
+ foreach ($log_entries as &$log_entry) {
$log_entry['date'] = date('d.m.Y H:i', $log_entry['timestamp']);
- $log_entries[] = $log_entry;
}
return page_with_title(admin_log_title(), [
@@ -33,7 +31,7 @@ function admin_log()
]),
table([
'date' => 'Time',
- 'nick' => 'Angel',
+ 'level' => 'Type',
'message' => 'Log Entry'
], $log_entries)
]);
diff --git a/includes/sys_log.php b/includes/sys_log.php
index c4ef890e..513586e6 100644
--- a/includes/sys_log.php
+++ b/includes/sys_log.php
@@ -9,10 +9,12 @@
function engelsystem_log($message)
{
global $user;
-
$nick = "Guest";
+ $logger = app('logger');
+
if (isset($user)) {
$nick = User_Nick_render($user);
}
- LogEntry_create($nick, $message);
+
+ $logger->info('{nick}: {message}', ['nick' => $nick, 'message' => $message]);
}