Skip to content

Releases: thienel/tlog

v1.2.0 - Sensitive Field Masking

Choose a tag to compare

@thienel thienel released this 03 Feb 03:45

What's New

Sensitive Field Masking

Added support for masking sensitive fields in request/response body logs using regex patterns.

Usage:

r.Use(tlog.GinMiddleware(
    tlog.WithMaskPatterns(
        `(?i)password`,      // matches "password", "Password", "PASSWORD"
        `(?i)secret`,        // matches "secret", "Secret", etc.
        `(?i)token`,         // matches "token", "accessToken", etc.
        `(?i)api[_-]?key`,   // matches "api_key", "apiKey", "API-KEY"
    ),
))

Features:

  • Regex patterns for flexible field name matching
  • Recursively masks nested objects and arrays
  • Only applies to JSON bodies (non-JSON unchanged)
  • No performance impact when no patterns configured
  • Applied to both request and response bodies

Example:

// Before
{"username": "john", "password": "secret123", "data": {"api_key": "xyz"}}

// After (logged)
{"username": "john", "password": "******", "data": {"api_key": "******"}}

Commits

  • feat: add sensitive field masking support for request/response bodies
  • docs: add sensitive field masking documentation

v1.1.0

Choose a tag to compare

@thienel thienel released this 27 Dec 11:53

Release v1.1.0

Date: 2025-12-27

Improves by adding new fields and standardizing field naming.


New Fields

HTTP Access Log

Field Description
protocol HTTP protocol version (HTTP/1.1, HTTP/2)
host Host header value

Database Query Log

Field Description
operation SQL operation: SELECT, INSERT, UPDATE, DELETE, OTHER
table Table name parsed from SQL
slow_query Boolean flag for slow queries

Breaking Changes

HTTP Access Log

Old New
status status_code
latency (Duration) duration_ms (int64)
client_ip ip_address
query query_string

Database Query Log

Old New
rows rows_affected
elapsed (Duration) duration_ms (int64)

Example Output

HTTP Access Log

{
  "message": "Request completed",
  "request_id": "019405a0-1234-7abc-8def-0123456789ab",
  "method": "POST",
  "path": "/api/users",
  "status_code": 201,
  "duration_ms": 45,
  "ip_address": "192.168.1.100",
  "protocol": "HTTP/1.1",
  "host": "api.example.com",
  "response_size": 256
}

Database Query Log

{
  "message": "Slow database query detected",
  "operation": "SELECT",
  "table": "orders",
  "duration_ms": 523,
  "rows_affected": 10000,
  "slow_query": true,
  "sql": "SELECT * FROM orders WHERE created_at > ?"
}

Installation

go get github.com/thienel/tlog@v1.1.0

Changelog

  • Add protocol field to HTTP Access Log
  • Add host field to HTTP Access Log
  • Add operation field to Database Query Log
  • Add table field to Database Query Log
  • Add slow_query flag to Database Query Log
  • Rename status to status_code
  • Rename latency to duration_ms (int64)
  • Rename client_ip to ip_address
  • Rename query to query_string
  • Rename rows to rows_affected
  • Rename elapsed to duration_ms (int64)
  • Update README documentation