Skip to content

feat(logger): Request Logging Implementation using Pino Logger #1967

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

FarazRazi
Copy link

@FarazRazi FarazRazi commented Apr 21, 2025

Request Logging Implementation

Issue Attached: #908

Overview

Adds comprehensive request logging using Pino logger with both concise and detailed logging options.

Features

  • One-line info logs for quick monitoring ([INFO] GET /api/users)
  • Detailed debug logs for troubleshooting
  • Automatic redaction of sensitive data (tokens, passwords, etc.)
  • Response duration tracking
  • Error logging with stack traces

Configuration

LOG_LEVEL=info  # error, warn, info, debug, trace
LOG_PRETTY=true # Enable pretty printing

Usage

The logger is automatically applied to all routes. No setup required.

Example Output

// Info level (default)
[INFO] GET /api/users

// Debug level
{
  "level": "debug",
  "message": "Incoming Request",
  "method": "POST",
  "url": "/api/users",
  "body": { "name": "John" },
  "headers": { "authorization": "[REDACTED]" }
}

Dependencies

  • pino
  • pino-pretty
  • @types/pino

@FarazRazi FarazRazi changed the title Request Logging Implementation feat(logger): Request Logging Implementation using Pino Logger Apr 21, 2025
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.

1 participant