Skip to content

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