Repository navigation
Releases: thienel/tlog
Releases · thienel/tlog
Release list
v1.2.0 - Sensitive Field Masking
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
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.0Changelog
- Add
protocolfield to HTTP Access Log - Add
hostfield to HTTP Access Log - Add
operationfield to Database Query Log - Add
tablefield to Database Query Log - Add
slow_queryflag to Database Query Log - Rename
statustostatus_code - Rename
latencytoduration_ms(int64) - Rename
client_iptoip_address - Rename
querytoquery_string - Rename
rowstorows_affected - Rename
elapsedtoduration_ms(int64) - Update README documentation