massenergize / api

Backend Code for Massenergize Portal. This provides the API to the backend database, and is shared by the various front-end portal projects.
MIT License
5 stars 8 forks source link

API Logging Feature #923

Open archx3 opened 6 months ago

archx3 commented 6 months ago

Sure, here is the feature ticket for API request logging:

DESCRIPTION

The API request logging feature is intended to provide visibility into the API requests made within our application. This will help in debugging, performance optimization, and understanding the usage patterns of our API.

USER STORY

As a Developer I want to have a log of all API requests so that I can debug, optimize performance, and understand usage patterns.

Possible Scenarios

SCENARIO 1. GIVEN an API request is made WHEN the request is processed THEN the details of the request should be logged

SCENARIO 2. GIVEN an API request is made WHEN an error occurs during the processing of the request THEN the error details should be logged along with the request details

SCENARIO 3. GIVEN the API request logs WHEN I need to debug an issue or understand usage patterns THEN I should be able to query the logs based on various parameters like time, API endpoint, response status, etc.

Required Permissions

Developers with access to the server logs.

Acceptance Criteria

UX Design

Not applicable as this is a backend feature.

Technical Considerations

Consider using a logging library that supports different log levels (like info, debug, error) and log formats (like JSON). Also, ensure that sensitive information like passwords are not logged. The logs should be stored in a way that they can be easily queried (like in a log management system).

BradHN1 commented 6 months ago

This would be useful. Would the logging be active for all deployments (dev, canary and prod) at all times, or could one enable or disable it. How about for a locally running API? Would be nice if the logging noted the elapsed time and also elapsed time for the database access, is that possible?