I've looked for several days, read multiple threads and i didnt find any answer.
Here is my problem : i'm remaking the log management on CodeIgniter 3.XX.
I collect the datas for each log message in a array like this :
$log_message['date'] = $date
$log_message['severity'] = $severity
$log_message['message'] = $message
etc etc. There is no problem collecting data from each log message and put them in an array.
The problem is that i want to json encode the datas and decode them in an another controller to display them on a dashboard.
so i use
$log_message = json_encode($log_message, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
Here is the result :
{
"message": "Severity: Compile Error --> Cannot redeclare Users::update_password_post() /application/controllers/api/Users.php 2055",
"level": "ERROR",
"date": "2019-10-21 16:53:24",
"short_message": "Users.php 2055",
"severity": "Compile",
"ip": "",
"trace": [
"core/Common.php MY_Exceptions->log_exception() (line:618)"
],
"short_trace": "core/Common.php MY_Exceptions->log_exception() (line:618)",
"uri": "[POST] /api/users/user"
}
and after several message i got this :
{
"message": "Severity: Compile Error --> Cannot redeclare Users::update_password_post() /application/controllers/api/Users.php 2055",
"level": "ERROR",
"date": "2019-10-21 16:53:24",
"short_message": "Users.php 2055",
"severity": "Compile",
"ip": "",
"trace": [
"core/Common.php MY_Exceptions->log_exception() (line:618)"
],
"short_trace": "core/Common.php MY_Exceptions->log_exception() (line:618)",
"uri": "[POST] /api/users/user"
}{
"message": "Severity: Compile Error --> Cannot redeclare Users::update_password_post() /application/controllers/api/Users.php 2055",
"level": "ERROR",
"date": "2019-10-21 16:53:24",
"short_message": "Users.php 2055",
"severity": "Compile",
"ip": "",
"trace": [
"core/Common.php MY_Exceptions->log_exception() (line:618)"
],
"short_trace": "core/Common.php MY_Exceptions->log_exception() (line:618)",
"uri": "[POST] /api/users/user"
}
But when i want to json_decode my file it is not seen as json array, so i added a "," between each mesage to separate them but i need to find a way to write a "[" at the beginning and a "]" at the end, knowing that the file is incremented by new log messages. Do you know a way to do this?
Thanks for advices, if my probleme is not clear or well readable tell me