-
Notifications
You must be signed in to change notification settings - Fork 1.7k
docs: added description for log levels and usage guidelines with exam… #2567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
docs: added description for log levels and usage guidelines with exam… #2567
Conversation
aryanmehrotra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few key things are missing which would help the developer write better code and only log what's truely important which are
- Usage guidelines along with anti-patterns (when not to use each level)
- Guidance for handling sensitive data (PII/secrets masking)
- Notes on performance impact and log volume control
|
@gitcrusher Please resolve the review comment given by @aryanmehrotra. |
|
Would be updating soon |
|
@aryanmehrotra i want to know that for PII and log volume should i have to write these as different section and also i want re-assure some part related to making secret/pii which is like that Gofr doesn't have automatic masking and it does not automatically detect or mask fields named "password", "token", or "credit_card". |
|
|
@aryanmehrotra in the new commit i have removed table as it could create a confusion in developers and instead the different subsections are provided with detailed information and Examples with the enhancement taken under consideration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make the following updates:
Thank you !
|
@coolwednesday i have updated the concerns and i have used the ctx. and app.logger(). according to its use cases just like for fatal most every issues would be inside main.go and for other there would be gofr used do we gonna use ctx. Kindly have a look. |
|
@coolwednesday do you want to add table as well or only table without detailed description of topic kindly suggest |
I wasn't aware of what the other maintainer's had said. Reading upon his view, I think this is okay. |
… ctx *gofr.Context has been added
…usher/gofr into docs/issue-2557-log-levels
|
@coolwednesday, @aryanmehrotra , @Umang01-hash kindly check the updates. changes have been taken cared off |
|
i would love my or to get approved if every concern is solved @Umang01-hash @coolwednesday @aryanmehrotra |
|
Kindly review my pr @Umang01-hash @coolwednesday @aryanmehrotra |
| ### DEBUG | ||
| This is the lowest priority level. It represents the most detailed/granual information. | ||
|
|
||
| **Color -** Grey |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
color is not required as that is not of much use to the user and we cannot tell about the json colors so it can be removed
| #### **Examples of when Not to Use:** | ||
|
|
||
|
|
||
| ***1. Avoid Logging Critical Business Data:*** Do not utilize `DEBUG` for audit trails or essential transaction records. In production environments, this level is typically suppressed to optimize performance, resulting in the loss of critical business insights. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this statement is incorrect - we should never log essential transaction records
this is true - this level is typically suppressed to optimize performance
but resulting in the loss of critical business insights. - is incorrect, logs should not be used for critical business insights for that we can push metrics or store the data, logs are for system health and any debugging purpose.
|
|
||
| --- | ||
| ### INFO | ||
| Represents standard operational events. It is the default fallback level if an unknown level string is provided. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is unknown level string?
| ### INFO | ||
| Represents standard operational events. It is the default fallback level if an unknown level string is provided. | ||
|
|
||
| **Color -** Cyan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be removed
| records := 5000 | ||
| duration := "1.2s" | ||
|
|
||
| ctx.Info("Data export job completed successfully", "JobID", jobID, "Records", records, "Duration", duration) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is conflicting as in the above debug logs we mentioning about starting job and here we are telling about finishing
nor its correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moreover these are cron jobs, and gofr would automatically log the start and stop
| func HealthHandler(ctx *gofr.Context) (interface{}, error) { | ||
| ctx.Info("Health Check Passed") | ||
| return "OK", nil | ||
| } | ||
| ``` | ||
| **Output** | ||
| ```Console | ||
| INFO [14:05:02] Health Check Passed | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this call again happens at very frequent interval we need to improve the examples
aryanmehrotra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Examples need to be consistent so its easy to understand and relate
|
@gitcrusher Please resolve the review comments given by @aryanmehrotra. |















Description:
This PR significantly enhances the Observability > Logs documentation by adding a comprehensive reference guide for GoFr log levels.
Previously, the documentation listed the available levels but lacked specific guidelines on when to use them or what they looked like in the console. This update fills that gap by adding:
DEBUGtoFATAL), their associated colors, and specific use-cases.logger.Warn(...)).DEBU,NOTI).stdoutvsstderr) for deeper understanding.How this helps developers:
NOTICEvsINFOorWARNvsERROR.DEBUGfor granular details, keeping production logs clean.Related Issue
Fixes #2557
** Changes **
.mdfiles) and does not alter the codebase or logic.Additional Information: