efcx-json-logger
v2.0.1
Published
A simple Node.js 18 package to log JSON objects using Winston
Maintainers
Readme
Winston Logger + Audit Logging
A lightweight Winston-based logger with built-in audit logging and frontend logging support.
Provides structured logging, error handling, console formatting with colors, and optional metadata fields for tracking requests and debugging.
Installation
npm install efcx-json-logger
---
## Importing
const { auditLog } = require('efcx-json-logger');
---
## Usage
### Audit Logging
Use auditLog() to log user actions (create, update, delete, etc.) in a structured JSON format.
### Audit Logging Parameters
auditLog({
userId: "u123",
userName: "John Doe",
action: "CREATE", // CREATE, UPDATE, DELETE
resource: "Team",
resourceId: "team_456",
ip: "192.168.1.10",
updatedData: { name: "Engineering" },
level: "info",
className: "TeamService",
methodName: "createTeam",
CID: "CID-789",
tenantId: "example",
service: "unified_admin" # service name should be the name of the component that is posting the logs
});
### Output
2025-09-02 14:30:00 | info | TeamService | createTeam | | { "timestamp": "2025-09-02T14:35:00.123Z", "user_id": "u123", "user_name": "John Doe", "action": "CREATE", "resource": "Team", "resource_id": "team_456", "source_ip_address": "192.168.1.10", "attributes": { "service": "unified_admin", "updated_data": { "name": "EFCX-team" } }, "type": "audit_logging", "level": "info" } | CID-789
const { frontendLog } = require('efcx-json-logger');
---
## Usage
### Audit Logging
Use frontendLog() to frontend usefull logs in a structured JSON format.
### Audit Logging Parameters
frontendLog({
userId: "u123",
userName: "John Doe",
ip: "192.168.1.10",
updatedData: { name: "Engineering" },
level: "info",
CID: "CID-789",
tenantId: "example",
service: "unified_admin" # service name should be the name of the component that is posting the logs
});
### Output
2025-09-02 14:30:00 | info | TeamService | createTeam | | { "timestamp": "2025-09-02T14:35:00.123Z", "user_id": "u123", "user_name": "John Doe", "action": "CREATE", "resource": "Team", "resource_id": "team_456", "source_ip_address": "192.168.1.10", "attributes": { "service": "unified_admin", "updated_data": { "name": "EFCX-team" } }, "type": "audit_logging", "level": "info" } | CID-789
