Skip to content

Conversation

@gitcrusher
Copy link

@gitcrusher gitcrusher commented Nov 20, 2025

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:

  • A Quick-Reference Table: clearly defining each level (DEBUG to FATAL), their associated colors, and specific use-cases.
  • Code Examples: Practical Go snippets showing how to call each log level (e.g., logger.Warn(...)).
  • Console Outputs: Visual representations of what the logs look like in the terminal (including the 4-character level prefixes like DEBU, NOTI).
  • Technical Details: Added integer values and stream destinations (stdout vs stderr) for deeper understanding.

How this helps developers:

  • Reduces Ambiguity: Helps developers decide exactly when to use NOTICE vs INFO or WARN vs ERROR.
  • Improves Debugging: Encourages the use of DEBUG for granular details, keeping production logs clean.
  • Standardization: Ensures the whole team uses logging levels consistently across the project.

Related Issue

Fixes #2557

** Changes **

  • This is strictly a documentation update (.md files) and does not alter the codebase or logic.

Additional Information:

  • No external dependencies are required.
  • Preview of changes:
    • Added a "Log Levels & Usage" table.
    • Added "Example Snippet" and "Output" blocks for all 6 log levels.
Screenshot 2025-11-21 044302 Screenshot 2025-11-21 044313 Screenshot 2025-11-21 044324 Screenshot 2025-11-21 044336

@gitcrusher gitcrusher closed this Nov 20, 2025
@gitcrusher gitcrusher deleted the docs/issue-2557-log-levels branch November 20, 2025 23:38
@gitcrusher gitcrusher restored the docs/issue-2557-log-levels branch November 20, 2025 23:44
Copy link
Member

@aryanmehrotra aryanmehrotra left a 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

  1. Usage guidelines along with anti-patterns (when not to use each level)
  2. Guidance for handling sensitive data (PII/secrets masking)
  3. Notes on performance impact and log volume control

@Umang01-hash
Copy link
Member

@gitcrusher Please resolve the review comment given by @aryanmehrotra.

@gitcrusher
Copy link
Author

Would be updating soon

@gitcrusher
Copy link
Author

gitcrusher commented Nov 23, 2025

@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".
Secondly developers must manually mask Sensitive Personal Information (SPI) and Personally Identifiable Information (PII) before passing variables to the logger or it could lead to leakage of personal information. if there is some more depth you could give to me

@gitcrusher
Copy link
Author

@gitcrusher Please resolve the review comment given by @aryanmehrotra.
kindly guide more onto pii and how would you like the formatting according to me the best way be creating a sub heading inside LOG only for PII and Volume control or log levels.

@gitcrusher
Copy link
Author

@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.
Screenshot 2025-11-23 182158
Screenshot 2025-11-23 182210
Screenshot 2025-11-23 182233
Screenshot 2025-11-23 182244
Screenshot 2025-11-23 182255
Screenshot 2025-11-23 182309
Screenshot 2025-11-23 182321
Screenshot 2025-11-23 182330
Screenshot 2025-11-23 182338
Screenshot 2025-11-23 182346
Screenshot 2025-11-23 182355
Screenshot 2025-11-23 182403
here note onto performance and log volume is also written
Screenshot 2025-11-23 182418

Copy link
Member

@coolwednesday coolwednesday left a 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 !

@gitcrusher
Copy link
Author

@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.

@gitcrusher
Copy link
Author

@coolwednesday do you want to add table as well or only table without detailed description of topic kindly suggest

@coolwednesday
Copy link
Member

@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.

@gitcrusher
Copy link
Author

@coolwednesday, @aryanmehrotra , @Umang01-hash kindly check the updates. changes have been taken cared off
image
image

@gitcrusher
Copy link
Author

i would love my or to get approved if every concern is solved @Umang01-hash @coolwednesday @aryanmehrotra

@gitcrusher
Copy link
Author

Kindly review my pr @Umang01-hash @coolwednesday @aryanmehrotra

### DEBUG
This is the lowest priority level. It represents the most detailed/granual information.

**Color -** Grey
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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
Copy link
Member

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)
Copy link
Member

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

Copy link
Member

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

Comment on lines +152 to +160
func HealthHandler(ctx *gofr.Context) (interface{}, error) {
ctx.Info("Health Check Passed")
return "OK", nil
}
```
**Output**
```Console
INFO [14:05:02] Health Check Passed
```
Copy link
Member

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

Copy link
Member

@aryanmehrotra aryanmehrotra left a 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

@Umang01-hash
Copy link
Member

@gitcrusher Please resolve the review comments given by @aryanmehrotra.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhance documentation to add about the different log levels

4 participants