Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,72 @@ Log messages are beautifully formatted with colorized timestamps, levels, and sm
- 🟢 **LOG**: Green - Critical messages that always display
- ⚫ **Timestamps**: Gray (ISO) and Cyan (local time) for easy scanning

### Customizing Log Elements

**LogEngine v2.1+ introduces the ability to customize which elements are included in your log output** while keeping log levels mandatory for clarity and consistency.

#### Available Customization Options

You can control the inclusion of timestamp elements:

- **ISO Timestamp**: `[2025-05-29T16:57:45.678Z]` - Precise UTC timestamp
- **Local Time**: `[4:57PM]` - Human-readable local time
- **Log Level**: `[INFO]` - Always included (non-customizable as per design)

#### Format Configuration Examples

```typescript
import { LogEngine, LogMode } from '@wgtechlabs/log-engine';

// Default format (backward compatible)
LogEngine.configure({ mode: LogMode.DEBUG });
LogEngine.info('Server started');
// Output: [2025-05-29T16:57:45.678Z][4:57PM][INFO]: Server started

// Only ISO timestamp
LogEngine.configure({
mode: LogMode.DEBUG,
format: {
includeIsoTimestamp: true,
includeLocalTime: false
}
});
LogEngine.info('Database connected');
// Output: [2025-05-29T16:57:45.678Z][INFO]: Database connected

// Only local time
LogEngine.configure({
mode: LogMode.DEBUG,
format: {
includeIsoTimestamp: false,
includeLocalTime: true
}
});
LogEngine.warn('Rate limit approaching');
// Output: [4:57PM][WARN]: Rate limit approaching

// Minimal format (no timestamps)
LogEngine.configure({
mode: LogMode.DEBUG,
format: {
includeIsoTimestamp: false,
includeLocalTime: false
}
});
LogEngine.error('Connection failed');
// Output: [ERROR]: Connection failed
```

#### Benefits of Log Element Customization

- **🎯 Reduced Verbosity**: Remove unnecessary timestamp information in containerized environments where external logging systems add timestamps
- **📱 Space Efficiency**: Minimize log line length for mobile or constrained display environments
- **🔧 Integration Ready**: Match existing log format requirements in your infrastructure
- **⚡ Performance**: Slightly reduced formatting overhead when timestamps are disabled
- **🔒 Backward Compatible**: Default behavior remains unchanged - existing code continues to work without modifications

**Note**: Log levels (`[DEBUG]`, `[INFO]`, `[WARN]`, `[ERROR]`, `[LOG]`) are always included regardless of configuration to maintain log clarity and filtering capabilities.

## 🔒 Advanced Data Redaction

**LogEngine features comprehensive built-in PII protection with advanced customization capabilities that automatically redacts sensitive information from your logs.** This security-first approach prevents accidental exposure of passwords, tokens, emails, and other sensitive data while maintaining full debugging capabilities with enterprise-grade flexibility.
Expand Down
45 changes: 40 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,50 @@
"type": "module",
"keywords": [
"logging",
"logger",
"log",
"winston-alternative",
"security",
"redaction",
"pii-protection",
"data-redaction",
"typescript",
"javascript",
"nodejs",
"express",
"fastify",
"koa",
"nestjs",
"bot",
"discord",
"telegram",
"privacy",
"gdpr",
"compliance"
"compliance",
"opensource",
"mit-license",
"esm",
"cjs",
"zero-dependencies",
"structured-logging",
"json-logging"
],
"packageManager": "[email protected]",
"license": "MIT",
"author": "WG Tech Labs <[email protected]> (https://wgtechlabs.com)",
"contributors": [
"Waren Gonzaga <[email protected]> (https://warengonzaga.com)"
],
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/wgtechlabs"
},
{
"type": "github",
"url": "https://github.com/sponsors/warengonzaga"
}
],
"main": "./dist/cjs/index.cjs",
"module": "./dist/esm/index.js",
"types": "./dist/esm/index.d.ts",
Expand All @@ -40,13 +65,22 @@
}
},
"files": [
"dist/**/*",
"dist/",
"README.md",
"LICENSE"
],
"repository": {
"type": "git",
"url": "https://github.com/wgtechlabs/log-engine.git"
"url": "git+https://github.com/wgtechlabs/log-engine.git"
},
"homepage": "https://github.com/wgtechlabs/log-engine#readme",
"bugs": {
"url": "https://github.com/wgtechlabs/log-engine/issues"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/",
"tag": "latest"
},
"scripts": {
"build": "node scripts/forklift-runner.js --clean",
Expand All @@ -71,7 +105,7 @@
"validate": "run-s lint test build",
"clean": "rm -rf dist coverage",
"coverage:open": "open coverage/lcov-report/index.html",
"coverage:upload": "curl -Os https://uploader.codecov.io/latest/windows/codecov.exe && codecov.exe"
"coverage:upload": "npx codecov"
},
"devDependencies": {
"@types/eslint-plugin-security": "^3",
Expand All @@ -89,6 +123,7 @@
"typescript": "^5.8.3"
},
"engines": {
"node": ">=16.0.0"
"node": ">=16.0.0",
"npm": ">=7.0.0"
}
}
Loading
Loading