@clicoh/logging
v1.1.0
Published
Structured JSON logging for ClicOH Node.js Express services
Downloads
507
Readme
@clicoh/logging
Structured JSON logging for ClicOH Node.js and Express services.
Install
bun add @clicoh/loggingThe package is public on npmjs.com, so consumers do not need a registry token.
Usage
import logger, {
logErrorMiddleware,
logTimeStartMiddleware,
printGeneralLog,
requestLogMiddleware,
} from '@clicoh/logging';
printGeneralLog(
{ message: 'Shipment created' },
'shipmentCreated',
logger,
);Optional middleware exports:
import { auditMiddleware, memoryMiddleware } from '@clicoh/logging';Configuration
SERVICE_NAME: stable service name used in Loki.ENVIRONMENTorNODE_ENV: deployment environment.LOG_LEVEL:error,warn,info, ordebug.LOG_HTTP_FULL: includes sanitized request headers in HTTP and audit logs. Request bodies are logged by the service after redacting sensitive fields.LOG_HTTP_MASK_PATH: whentrue, masks path IDs, UUIDs, emails, and tokens as:value. It defaults tofalse, sourlcontains the real path without its query string.routealways contains the masked path for grouping in Loki.LOG_MEMORY_USAGE: enables memory-delta logs.MAX_LOG_STRING_LENGTH: maximum length for individual strings.MAX_LOG_EVENT_LENGTH: maximum UTF-8 byte size for a complete JSON line.AWS_REGION: optional region metadata.
Errors are written to stderr. Other enabled levels are written to stdout.
Releases
The first public version is published manually with npm 2FA. Subsequent semver
tags publish through .github/workflows/publish.yml using npm trusted
publishing (OIDC), without long-lived registry tokens.
