Skip to content

Conversation

vishr
Copy link
Member

@vishr vishr commented Sep 16, 2025

Summary

Addresses issue #2665 by providing comprehensive documentation for the Logger middleware that was previously lacking detailed explanations and examples.

Changes

📚 Configuration Examples (8 different scenarios):

  • Basic usage with default settings
  • Custom simple format
  • JSON format with custom fields
  • Custom time formatting
  • Logging headers, query params, form data, and cookies
  • File output configuration
  • Custom tag functions with user logic
  • Conditional logging with Skipper
  • External logging service integration

🏷️ Complete Tag Reference organized by category:

  • Time Tags: 7 different timestamp formats
  • Request Information: 10 request-related tags
  • Response Information: 6 response-related tags
  • Dynamic Tags: 4 parameterized tag types with examples

📖 Enhanced Field Documentation:

  • Clear purpose explanation for each LoggerConfig field
  • Usage examples and best practices
  • Default values and behavior
  • Proper Go reference time format examples

🔧 Troubleshooting Section:

  • 4 common issues with solutions
  • Performance optimization tips
  • Best practices for high-traffic applications

🚀 Function Documentation:

  • Detailed explanation of default Logger() behavior with example JSON output
  • Comprehensive LoggerWithConfig() documentation with usage examples

Impact

This enhancement transforms the Logger middleware from having minimal documentation to having enterprise-grade documentation that:

  • Helps new users quickly understand and configure the middleware
  • Provides advanced patterns for experienced developers
  • Reduces support burden by answering common questions upfront
  • Improves developer experience with clear examples and troubleshooting

Testing

  • ✅ All existing tests pass
  • ✅ Code compiles without issues
  • ✅ Documentation follows Go documentation conventions
  • ✅ Examples are syntactically correct and functional

Fixes #2665

Before/After

Before: Basic tag list with minimal explanations
After: 200+ lines of comprehensive documentation with 8+ complete configuration examples

The issue specifically requested "detailed explanations of configuration options and comprehensive examples for various use cases" - this PR delivers exactly that.

…xamples

Addresses issue #2665 by providing comprehensive documentation for the Logger
middleware including:

**Configuration Examples:**
- Basic usage with default settings
- Custom simple and JSON formats
- Custom time formatting
- Header, query, form, and cookie logging
- File output configuration
- Custom tag functions
- Conditional logging with Skipper
- External logging service integration

**Detailed Tag Reference:**
- Complete list of all available tags (time, request, response, dynamic)
- Clear explanations of each tag's purpose and format
- Examples showing proper usage

**Enhanced Field Documentation:**
- Detailed descriptions for all LoggerConfig fields
- Examples for each configuration option
- Default values and behavior

**Troubleshooting Section:**
- Common issues and solutions
- Performance optimization tips
- Best practices for high-traffic applications

**Function Documentation:**
- Enhanced Logger() and LoggerWithConfig() documentation
- Example outputs and usage patterns

This makes the Logger middleware much more accessible to new users while
providing advanced configuration guidance for experienced developers.

Fixes #2665

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copy link
Contributor

@aldas aldas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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 Logger Middleware Documentation with Detailed Configuration Examples
2 participants