Write Logs
Use this api to write a list of logs to db
Flow: Write a list of log to db
URL : /api-auth/write
Method : POST
Authorization : Use OAuth token
Validate Rule
'service' => ['required', 'string'],
'logs' => ['required', 'array'],
'logs.*.view_level' => ['nullable', 'integer'],
'logs.*.log_level' => ['required', 'string'],
'logs.*.event' => ['nullable', 'string'],
'logs.*.message' => ['nullable', 'string'],
'logs.*.log' => ['nullable', 'string'],
'logs.*.entity.*.type' => ['nullable', 'string'],
'logs.*.entity.*.value' => ['nullable'],
'logs.*.causer_kind' => ['nullable', 'integer'],
'logs.*.causer' => ['required', 'string'],
'logs.*.causer_name' => ['nullable', 'string'],
'logs.*.properties' => ['nullable', 'array'],
'logs.*.batch_action' => ['nullable', 'string'],
'logs.*.created_at' => ['nullable', 'date'],
Example
{
"service": "pmc-oms-order-manage-api",
"logs": [
{
"view_level": 1,
"log_level": "important",
"message": "Updating order 6368951174 from Web",
"log": "{\"order_number\":\"6368951174\",\"status\":\"PROCESSING\"}",
"entity": [
{
"type": "order_number",
"value": "6368951174"
},
{
"type": "order_id",
"value": "303116"
}
],
"event": "App\\Jobs\\OrderProcessingJob->handle()",
"properties": {
"existingOrder": "{\"id\":303116,\"user_id\":92114,\"delivery_id\":794658,\"cancel_reason_id\":null,\"cancelled_at\":null}"
},
"created_at": "2023-09-19T02:54:45.322983Z",
"causer_kind": 1,
"causer": "67",
"causer_name": "pmc-order-manage-api"
}
]
}
Success Response
Code : 200 OK
Content example
{
"success": true,
"errors": null,
"errorCode": null,
"data": true
}
Error Response
Code : 400 BAD REQUEST
Content :
{
"success": false,
"errors": {
"service": [
"The service field is required."
]
},
"errorCode": 400,
"data": null
}
cURL
curl --location 'https://api-gateway.dev.pharmacity.io/pmc-ecm-logs-api/api-auth/write' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJjcmF0IjoxNjk1MDkxNjQxLCJoYXNoIjoiYjYwYTE1MzgwYmE5NjlhZTE5MjkyNjc2MmI4Zjk1MjYiLCJ1c2VyIjp7ImlkIjo1LCJraW5kIjoxLCJpc19hZG1pbiI6dHJ1ZSwicm9sZXMiOm51bGwsIm5hbWUiOiJMdXUgSG9hbmcgS2hhbmggTMawdSBIb8OgbmcgS2jDoW5oIER1eSIsImV4dGVybmFsX2lkIjoiODAxMjAwIiwiZXh0ZXJuYWxfZGF0YSI6eyJwaG9uZSI6IjA5MDMxNDc3NTYiLCJ1c2VyX2FnZW50IjoiUG9zdG1hblJ1bnRpbWUiLCJ1c2VyX2lkIjoiMSJ9fX0.McQuorDYQcZGzwPP1NxqztcUbOh3y1hdZ4-tXxRXXHRij57smiOjO4xCmPc8M-NrjHJREL63ES6QhFTxppowAw' \
--data '{
"service": "pmc-oms-order-manage-api",
"logs": [
{
"view_level": 1,
"log_level": "important",
"message": "Updating order 6368951174 from Web",
"log": "{\"order_number\":\"6368951174\",\"status\":\"PROCESSING\"}",
"entity": [
{
"type": "order_number",
"value": "6368951174"
},
{
"type": "order_id",
"value": "303116"
}
],
"event": "App\\Jobs\\OrderProcessingJob->handle()",
"properties": {
"existingOrder": "{\"id\":303116,\"user_id\":92114,\"delivery_id\":794658,\"cancel_reason_id\":null,\"cancelled_at\":null}"
},
"created_at": "2023-09-19T02:54:45.322983Z",
"causer_kind": 1,
"causer": "67",
"causer_name": "pmc-order-manage-api"
}
]
}'