Configurable Pino logger with audit logging helper and request/response serializers for Node.js services.
// Source: https://github.com/geminimir/meterguard | License: MIT | Copyright 2025 StripeMeter Contributors
// Provided via justclaw.it.com; keep this notice with the code.
/**
* Logger configuration
*/
import pino from 'pino';
const isDevelopment = process.env.NODE_ENV === 'development';
export const logger = pino({
level: process.env.LOG_LEVEL || 'info',
transport: isDevelopment
? {
target: 'pino-pretty',
options: {
colorize: true,
translateTime: 'HH:MM:ss Z',
ignore: 'pid,hostname',
},
}
: undefined,
serializers: {
req: (req) => ({
method: req.method,
url: req.url,
headers: (() => {
const headers = { ...(req.headers || {}) } as Record<string, any>;
const redact = ['author
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key