Skip to content

Event Logger API Endpoints

Rachel Sensenig edited this page Apr 4, 2023 · 2 revisions

Event Logger API Endpoints

This API endpoint passes log messages from the front-end to the back-end. This endpoint currently does two things: (1) uses Winston to store log messages in an error.log file that's in the root of the project (if the project is being run in development, then the log messages are also printed to the console) (2) uses an objection.js model and knex migration to send log messages to the PostgreSQL database

The front-end logging (created using vue-logger-plugin) is currently attached to posts to /api/checkout/create-transaction and /api/lob/createLetter in the ActionComplete.vue component. Additional front-end logging can be attached by using $log (see further documentation about vue-logger-plugin here: https://github.com/dev-tavern/vue-logger-plugin/tree/develop-v1).

Send Log Messages to Winston

POST

Syntax

/api/event_logger/log

Request

The body of this request is a JSON object that provides log message information, including “severity” and “data.”

Example request.body:

{
severity: “error”,
data: "An error occured at /lob/checkout/createLetter: Request failed with status code 500, AxiosError, ERR_BAD_RESPONSE”
}

Response

If successful, we will receive a response status of 200. We will also see the log message added in JSON format to the error.log file in the root of the project. If in development, the log message will be printed to the console.

Send Log Messages to Database

POST

Syntax

/api/event_logger/log

Request

The body of this request is a JSON object that provides log message information, including “severity” and “data.”

Example request.body:

{
severity: “error”,
data: "An error occured at /lob/checkout/createLetter: Request failed with status code 500, AxiosError, ERR_BAD_RESPONSE”
}

Response

If successful, the log message will be added to the error_logs table in the Postgres database. To connect to the Postgres database, follow these instructions: https://github.com/ProgramEquity/amplify/wiki/Interacting-with-Postgres.

If not successful, we will receive a response status of 500, and the message “an error happened with the ErrorLog query insert.”

Clone this wiki locally