Skip to content

Commit 65e8acb

Browse files
handle frontend error logging
1 parent 3a13ce9 commit 65e8acb

3 files changed

Lines changed: 33 additions & 1 deletion

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.0.7",
2+
"version": "1.0.8",
33
"name": "jsonms/server",
44
"description": "The JSON.ms Request Handler Server is a robust backend solution designed to manage and process all incoming requests from the main JSON.ms website.",
55
"license": "BSD-3-Clause",
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
use JSONms\Controllers\RestfulController;
4+
5+
class ErrorController extends RestfulController
6+
{
7+
public function saveAction($errors)
8+
{
9+
foreach ($errors as $error) {
10+
$this->query('insert-error', [
11+
'key' => $error->key,
12+
'message' => $error->message,
13+
'source' => $error->source,
14+
'line' => $error->line,
15+
'column' => $error->column,
16+
'stack' => $error->stack,
17+
'occurred_on' => $error->occurred_on,
18+
'last_timestamp' => $error->last_timestamp,
19+
'version' => $error->version,
20+
'route' => $error->route,
21+
'count' => $error->count,
22+
'user_agent' => $error->user_agent,
23+
'created_by' => $this->getCurrentUserId(),
24+
]);
25+
}
26+
27+
$this->responseJson(true);
28+
}
29+
}

src/queries/insert-error.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
INSERT INTO errors (`key`, `message`, `source`, `line`, `column`, `stack`, `occurred_on`, `last_timestamp`, `version`, `route`, `count`, `user_agent`, `created_by`)
2+
VALUES (:key, :message, :source, :line, :column, :stack, :occurred_on, :last_timestamp, :version, :route, :count, :user_agent, :created_by)
3+
ON DUPLICATE KEY UPDATE `count` = `count` + :count, `updated_at` = NOW();

0 commit comments

Comments
 (0)