custom-plugin-lib
custom-plugin-lib copied to clipboard
Default logs in TRACE or DEBUG level
The description of the bug or the rationale of your proposal
It's quite common for developers to forget to implement some logs which are essentials to debug a service behavior and the integration with external systems. Some of this logs are always the same, and the developer should take them for granted, so that she can focus on logs for her specific domain. Here is the proposal for some of this default (or boilerplate) logs:
- For each route defined by means of
addRawCustomPlugin
, the following logs should be set: a. a TRACE/DEBUG log of the entire request with headers and payload b. a TRACE/DEBUG log of the entire response with headers and payload
Sensitive information should be take into account in order not to accidentally log it. A simple solution for this problem could consist of a simple flag opt-out
boolean flag to be set in the json schema of the endpoint for all the fields that should be omitted from the logs (like all the personal information
Here's an example of such a JSON schema:
{
"headers": {
"type": "object",
"properties": {
"authorization": {"type":"string", "hide": true"}
}
},
"body": {
"type": "object",
"properties": {
"name": {"type": "string"},
"surname": {"type": "string"},
"taxCode": {"type": "string", "hide": true"}
},
},
"response": {
"200": {
"type": "object",
"properties": {
"medicalRecordID": {"type": "string", "hide": "true"}
}
}
}
- For each call that is directed to an external service by means of a service proxy: a. a TRACE/DEBUG log with all the request that is forwarded to the external service b. a TRACE/DEBUG log with all the response that is received from the external service
With these default/boilerplate logs, the developer should not remember to add noisy logs to her code, and she would know that it only takes to set the right LOG_LEVEL environment variable to have all the information she needs to debug a problem.