@mks2508/better-logger 5.0.0 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{Logger-Cbi1f10o.js → Logger-CKqzXDh3.js} +2 -2
- package/dist/chunks/{Logger-Cbi1f10o.js.map → Logger-CKqzXDh3.js.map} +1 -1
- package/dist/chunks/{Logger-BZ7B7OXE.js → Logger-D_vuKP4l.js} +2 -2
- package/dist/chunks/{Logger-BZ7B7OXE.js.map → Logger-D_vuKP4l.js.map} +1 -1
- package/dist/chunks/cli-module-B-njrTWb.js +2 -0
- package/dist/chunks/cli-module-B-njrTWb.js.map +1 -0
- package/dist/chunks/{cli-module-ClIJmaT8.js → cli-module-Cx7qotPY.js} +16 -9
- package/dist/chunks/cli-module-Cx7qotPY.js.map +1 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/exports.cjs +1 -1
- package/dist/exports.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/styling.cjs +1 -1
- package/dist/styling.js +2 -2
- package/dist/terminal/formatter.d.ts.map +1 -1
- package/package.json +5 -1
- package/.claude/settings.local.json +0 -48
- package/.github/workflows/ci-quality.yml +0 -357
- package/.github/workflows/docs-demo.yml +0 -119
- package/.github/workflows/releases-core.yml +0 -512
- package/.github/workflows/releases-full.yml +0 -582
- package/.github/workflows-backup/ci.yml +0 -221
- package/.github/workflows-backup/nightly.yml +0 -196
- package/.github/workflows-backup/release-optimized.yml +0 -373
- package/.github/workflows-backup/release.yml +0 -269
- package/.release-notes-0.2.0.md +0 -129
- package/.yamllint +0 -28
- package/CHANGELOG.json +0 -1076
- package/CHANGELOG.md +0 -209
- package/CLAUDE.md +0 -217
- package/bun.lock +0 -333
- package/demo.html +0 -847
- package/dist/chunks/cli-module-CadqgZ1Z.js +0 -2
- package/dist/chunks/cli-module-CadqgZ1Z.js.map +0 -1
- package/dist/chunks/cli-module-ClIJmaT8.js.map +0 -1
- package/docs/API.md +0 -918
- package/docs/CORE.md +0 -264
- package/docs/DEVELOPMENT.md +0 -731
- package/docs/EXPORTS.md +0 -467
- package/docs/PACKAGES.md +0 -244
- package/docs/STYLING.md +0 -405
- package/docs/_config.yml +0 -36
- package/docs/index.md +0 -179
- package/examples/README.md +0 -208
- package/examples/basic-logging.js +0 -75
- package/examples/data-export.js +0 -234
- package/examples/package.json +0 -16
- package/examples/performance-timing.js +0 -170
- package/examples/simplified-api.js +0 -124
- package/examples/styling-themes.js +0 -207
- package/index.html +0 -358
- package/packages/core/package.json +0 -57
- package/packages/exports/package.json +0 -41
- package/packages/nodejs-opentui/README.md +0 -232
- package/packages/nodejs-opentui/package.json +0 -72
- package/packages/nodejs-opentui/src/LogRenderer.ts +0 -171
- package/packages/nodejs-opentui/src/OpenTUILogHandler.ts +0 -178
- package/packages/nodejs-opentui/src/components/LogBadge.tsx +0 -131
- package/packages/nodejs-opentui/src/index.ts +0 -133
- package/packages/nodejs-opentui/src/types.ts +0 -158
- package/packages/nodejs-opentui/tsconfig.json +0 -20
- package/packages/styling/package.json +0 -41
- package/playground/demo-all.ts +0 -95
- package/playground/demo-box.ts +0 -85
- package/playground/demo-levels.ts +0 -56
- package/playground/demo-real-world.ts +0 -98
- package/playground/demo-spinner.ts +0 -77
- package/playground/demo-steps.ts +0 -72
- package/playground/demo-table.ts +0 -83
- package/project-utils/README.md +0 -172
- package/project-utils/auto-release-gemini.ts +0 -1193
- package/project-utils/auto-release-ui.ts +0 -1329
- package/project-utils/commit-generator.ts +0 -1385
- package/project-utils/commit-ui.ts +0 -264
- package/project-utils/git-utils.ts +0 -199
- package/project-utils/github-release-manager.ts +0 -466
- package/project-utils/project-config.ts +0 -260
- package/project-utils/prompt-templates.js +0 -345
- package/project-utils/prompt-templates.ts +0 -422
- package/project-utils/version-manager.ts +0 -1078
- package/public/vite.svg +0 -1
- package/src/Logger.ts +0 -1858
- package/src/ScopedLogger.ts +0 -256
- package/src/cli/CommandProcessor.ts +0 -248
- package/src/cli/commands/ConfigCommand.ts +0 -93
- package/src/cli/commands/ExportCommand.ts +0 -276
- package/src/cli/commands/HistoryCommand.ts +0 -117
- package/src/cli/commands/StatusCommand.ts +0 -112
- package/src/cli/commands/ThemeCommand.ts +0 -88
- package/src/cli/help.ts +0 -127
- package/src/cli/index.ts +0 -71
- package/src/cli-module.ts +0 -21
- package/src/cli-primitives/box.ts +0 -86
- package/src/cli-primitives/cli-table.ts +0 -62
- package/src/cli-primitives/divider.ts +0 -17
- package/src/cli-primitives/header.ts +0 -18
- package/src/cli-primitives/index.ts +0 -13
- package/src/cli-primitives/server-fallback.ts +0 -54
- package/src/cli-primitives/spinner.ts +0 -133
- package/src/cli-primitives/step.ts +0 -22
- package/src/constants.ts +0 -313
- package/src/core.ts +0 -397
- package/src/example.ts +0 -210
- package/src/exports-module.ts +0 -311
- package/src/handlers/AnalyticsLogHandler.ts +0 -22
- package/src/handlers/ExportLogHandler.ts +0 -610
- package/src/handlers/FileLogHandler.ts +0 -169
- package/src/handlers/RemoteLogHandler.ts +0 -42
- package/src/handlers/index.ts +0 -8
- package/src/hooks/HookManager.ts +0 -177
- package/src/hooks/index.ts +0 -1
- package/src/index.ts +0 -395
- package/src/main.ts +0 -196
- package/src/serializers/SerializerRegistry.ts +0 -173
- package/src/serializers/index.ts +0 -1
- package/src/style.css +0 -96
- package/src/styling/LogStyleBuilder.ts +0 -355
- package/src/styling/SemanticStyles.ts +0 -380
- package/src/styling/SmartPresets.ts +0 -288
- package/src/styling/StyleBuilder.ts +0 -319
- package/src/styling/StyleCache.ts +0 -131
- package/src/styling/banners.ts +0 -168
- package/src/styling/index.ts +0 -27
- package/src/styling/themes.ts +0 -235
- package/src/styling-module.ts +0 -244
- package/src/terminal/color-converter.ts +0 -315
- package/src/terminal/formatter.ts +0 -236
- package/src/terminal/terminal-renderer.ts +0 -342
- package/src/transports/ConsoleTransport.ts +0 -28
- package/src/transports/FileTransport.ts +0 -53
- package/src/transports/HttpTransport.ts +0 -56
- package/src/transports/TransportManager.ts +0 -130
- package/src/transports/index.ts +0 -4
- package/src/types/core.ts +0 -417
- package/src/types/handlers.ts +0 -95
- package/src/types/hooks.ts +0 -45
- package/src/types/index.ts +0 -83
- package/src/types/serializers.ts +0 -30
- package/src/types/transports.ts +0 -52
- package/src/typescript.svg +0 -1
- package/src/utils/adapter.ts +0 -291
- package/src/utils/ansi-colors.ts +0 -333
- package/src/utils/environment-detector.ts +0 -170
- package/src/utils/environment.ts +0 -94
- package/src/utils/formatting.ts +0 -332
- package/src/utils/index.ts +0 -33
- package/src/utils/opentui-detection.ts +0 -138
- package/src/utils/output.ts +0 -227
- package/src/utils/stackTrace.ts +0 -144
- package/src/utils/timestamps.ts +0 -80
- package/src/vite-env.d.ts +0 -1
- package/src/writers/BufferWriter.ts +0 -157
- package/src/writers/index.ts +0 -6
- package/test-core-browser.html +0 -237
- package/test-core-node.js +0 -63
- package/tests/test-conflict-resolution.ts +0 -391
- package/tests/validate-workflows.sh +0 -131
- package/tests/yaml-autofix.sh +0 -146
- package/tsconfig.json +0 -50
- package/vite.config.ts +0 -256
package/docs/EXPORTS.md
DELETED
|
@@ -1,467 +0,0 @@
|
|
|
1
|
-
# 📤 Exports Module
|
|
2
|
-
|
|
3
|
-
**Data management with CSV/JSON/XML export and remote logging capabilities**
|
|
4
|
-
|
|
5
|
-
```typescript
|
|
6
|
-
import { ExportLogger, exportLogs } from '@mks2508/better-logger/exports'
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
**Bundle Size:** 12KB • **Gzipped:** 3KB
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## ✨ Features
|
|
14
|
-
|
|
15
|
-
- 📄 **Multiple Export Formats** (CSV, JSON, XML)
|
|
16
|
-
- 📡 **Remote Logging** to external services
|
|
17
|
-
- 🗂️ **Buffer Management** with circular buffer
|
|
18
|
-
- 📊 **Log Statistics** and analytics
|
|
19
|
-
- 🔍 **Advanced Filtering** by level, date, content
|
|
20
|
-
- ⚡ **Batch Operations** for performance
|
|
21
|
-
- 🔒 **Secure Remote Transmission** with API keys
|
|
22
|
-
|
|
23
|
-
## 🚀 Quick Start
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
import { ExportLogger } from '@mks2508/better-logger/exports'
|
|
27
|
-
|
|
28
|
-
// Create logger with export capabilities
|
|
29
|
-
const logger = new ExportLogger({ bufferSize: 1000 })
|
|
30
|
-
|
|
31
|
-
// Log some data
|
|
32
|
-
logger.info('User logged in', { userId: 123 })
|
|
33
|
-
logger.error('Payment failed', { orderId: 456, error: 'timeout' })
|
|
34
|
-
logger.success('Order completed', { orderId: 789, amount: 99.99 })
|
|
35
|
-
|
|
36
|
-
// Export logs
|
|
37
|
-
const csvData = await logger.exportLogs('csv')
|
|
38
|
-
const jsonData = await logger.exportLogs('json', {
|
|
39
|
-
filter: { level: 'error' },
|
|
40
|
-
limit: 50
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
// Setup remote logging
|
|
44
|
-
logger.addRemoteHandler('https://api.logs.company.com', 'api-key-here')
|
|
45
|
-
|
|
46
|
-
// Get statistics
|
|
47
|
-
const stats = logger.getLogStats()
|
|
48
|
-
console.log(`Total logs: ${stats.info + stats.error + stats.warn}`)
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## 📄 Export Formats
|
|
52
|
-
|
|
53
|
-
### CSV Export
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
const csvData = await logger.exportLogs('csv', {
|
|
57
|
-
filter: {
|
|
58
|
-
level: 'error',
|
|
59
|
-
from: new Date('2024-01-01'),
|
|
60
|
-
to: new Date()
|
|
61
|
-
},
|
|
62
|
-
limit: 100
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
// CSV Output:
|
|
66
|
-
// timestamp,level,prefix,message,location
|
|
67
|
-
// 2024-01-15T10:30:00.123Z,error,API,"Payment timeout","api.js:45:12"
|
|
68
|
-
// 2024-01-15T10:31:15.456Z,error,DB,"Connection lost","database.js:23:8"
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### JSON Export
|
|
72
|
-
|
|
73
|
-
```typescript
|
|
74
|
-
const jsonData = await logger.exportLogs('json', {
|
|
75
|
-
filter: { level: 'error' },
|
|
76
|
-
groupBy: 'level'
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
// JSON Output:
|
|
80
|
-
{
|
|
81
|
-
"metadata": {
|
|
82
|
-
"exportTime": "2024-01-15T10:30:00.000Z",
|
|
83
|
-
"totalLogs": 15,
|
|
84
|
-
"filters": { "level": "error" }
|
|
85
|
-
},
|
|
86
|
-
"logs": [
|
|
87
|
-
{
|
|
88
|
-
"id": "log_001",
|
|
89
|
-
"timestamp": "2024-01-15T10:30:00.123Z",
|
|
90
|
-
"level": "error",
|
|
91
|
-
"prefix": "API",
|
|
92
|
-
"message": "Payment timeout",
|
|
93
|
-
"args": [{ "orderId": 456, "error": "timeout" }],
|
|
94
|
-
"location": {
|
|
95
|
-
"file": "api.js",
|
|
96
|
-
"line": 45,
|
|
97
|
-
"column": 12,
|
|
98
|
-
"function": "processPayment"
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
]
|
|
102
|
-
}
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### XML Export
|
|
106
|
-
|
|
107
|
-
```typescript
|
|
108
|
-
const xmlData = await logger.exportLogs('xml', {
|
|
109
|
-
groupBy: 'level',
|
|
110
|
-
minimal: false
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
// XML Output:
|
|
114
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
115
|
-
<logs>
|
|
116
|
-
<metadata>
|
|
117
|
-
<exportTime>2024-01-15T10:30:00.000Z</exportTime>
|
|
118
|
-
<totalLogs>15</totalLogs>
|
|
119
|
-
</metadata>
|
|
120
|
-
<entries>
|
|
121
|
-
<log id="log_001" level="error">
|
|
122
|
-
<timestamp>2024-01-15T10:30:00.123Z</timestamp>
|
|
123
|
-
<prefix>API</prefix>
|
|
124
|
-
<message>Payment timeout</message>
|
|
125
|
-
<location file="api.js" line="45" column="12" function="processPayment"/>
|
|
126
|
-
</log>
|
|
127
|
-
</entries>
|
|
128
|
-
</logs>
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## 📡 Remote Logging
|
|
132
|
-
|
|
133
|
-
### Adding Remote Endpoints
|
|
134
|
-
|
|
135
|
-
```typescript
|
|
136
|
-
import { ExportLogger } from '@mks2508/better-logger/exports'
|
|
137
|
-
|
|
138
|
-
const logger = new ExportLogger({ bufferSize: 1000 })
|
|
139
|
-
|
|
140
|
-
// Add remote endpoints
|
|
141
|
-
logger.addRemoteHandler('https://logs.company.com/api/logs', 'secret-api-key')
|
|
142
|
-
logger.addRemoteHandler('wss://realtime.company.com/logs')
|
|
143
|
-
logger.addRemoteHandler('https://analytics.company.com/events', 'analytics-key')
|
|
144
|
-
|
|
145
|
-
// All logs are automatically sent to remote endpoints
|
|
146
|
-
logger.error('This will be sent to all 3 endpoints')
|
|
147
|
-
logger.info('User action', { action: 'click', element: 'button' })
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
### Remote Handler Configuration
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
// HTTP endpoint with authentication
|
|
154
|
-
logger.addRemoteHandler('https://api.example.com/logs', {
|
|
155
|
-
apiKey: 'your-secret-key',
|
|
156
|
-
headers: {
|
|
157
|
-
'Content-Type': 'application/json',
|
|
158
|
-
'User-Agent': 'BetterLogger/1.0'
|
|
159
|
-
},
|
|
160
|
-
retries: 3,
|
|
161
|
-
timeout: 5000
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
// WebSocket endpoint
|
|
165
|
-
logger.addRemoteHandler('wss://realtime.example.com/logs', {
|
|
166
|
-
reconnect: true,
|
|
167
|
-
reconnectInterval: 5000,
|
|
168
|
-
maxReconnectAttempts: 10
|
|
169
|
-
})
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
### Batch Remote Logging
|
|
173
|
-
|
|
174
|
-
```typescript
|
|
175
|
-
// Configure batch settings
|
|
176
|
-
const logger = new ExportLogger({
|
|
177
|
-
bufferSize: 1000,
|
|
178
|
-
remoteBatch: {
|
|
179
|
-
size: 10, // Send in batches of 10 logs
|
|
180
|
-
interval: 5000, // Or every 5 seconds
|
|
181
|
-
maxWait: 30000 // Force send after 30 seconds
|
|
182
|
-
}
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
// Logs are automatically batched for efficiency
|
|
186
|
-
for (let i = 0; i < 100; i++) {
|
|
187
|
-
logger.info(`Log entry ${i}`)
|
|
188
|
-
} // Sent as 10 batches of 10 logs each
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### Flushing Remote Logs
|
|
192
|
-
|
|
193
|
-
```typescript
|
|
194
|
-
// Force send all pending logs
|
|
195
|
-
await logger.flushRemoteHandlers()
|
|
196
|
-
|
|
197
|
-
// Clear remote endpoints
|
|
198
|
-
logger.clearRemoteHandlers()
|
|
199
|
-
|
|
200
|
-
// Check remote status
|
|
201
|
-
const remoteStatus = logger.getRemoteStatus()
|
|
202
|
-
console.log('Active endpoints:', remoteStatus.active)
|
|
203
|
-
console.log('Failed endpoints:', remoteStatus.failed)
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
## 🗂️ Buffer Management
|
|
207
|
-
|
|
208
|
-
### Buffer Configuration
|
|
209
|
-
|
|
210
|
-
```typescript
|
|
211
|
-
const logger = new ExportLogger({
|
|
212
|
-
bufferSize: 2000, // Maximum 2000 log entries
|
|
213
|
-
bufferMode: 'circular', // Overwrite oldest when full
|
|
214
|
-
persistBuffer: true, // Save to localStorage
|
|
215
|
-
bufferKey: 'app-logs' // Storage key name
|
|
216
|
-
})
|
|
217
|
-
|
|
218
|
-
// Get buffer information
|
|
219
|
-
const bufferStats = logger.getBufferStats()
|
|
220
|
-
console.log('Buffer usage:', bufferStats.usage, '%')
|
|
221
|
-
console.log('Oldest log:', bufferStats.oldestLog)
|
|
222
|
-
console.log('Newest log:', bufferStats.newestLog)
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
### Buffer Operations
|
|
226
|
-
|
|
227
|
-
```typescript
|
|
228
|
-
// Get all buffered logs
|
|
229
|
-
const allLogs = logger.getLogs()
|
|
230
|
-
console.log('Total logs in buffer:', allLogs.length)
|
|
231
|
-
|
|
232
|
-
// Clear the buffer
|
|
233
|
-
logger.clearLogs()
|
|
234
|
-
|
|
235
|
-
// Get logs with filtering
|
|
236
|
-
const recentErrors = logger.getLogs({
|
|
237
|
-
level: 'error',
|
|
238
|
-
since: Date.now() - (24 * 60 * 60 * 1000) // Last 24 hours
|
|
239
|
-
})
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
## 📊 Analytics & Statistics
|
|
243
|
-
|
|
244
|
-
### Log Statistics
|
|
245
|
-
|
|
246
|
-
```typescript
|
|
247
|
-
const stats = logger.getLogStats()
|
|
248
|
-
|
|
249
|
-
console.log('Log Distribution:')
|
|
250
|
-
console.log('- Debug:', stats.debug)
|
|
251
|
-
console.log('- Info:', stats.info)
|
|
252
|
-
console.log('- Warnings:', stats.warn)
|
|
253
|
-
console.log('- Errors:', stats.error)
|
|
254
|
-
console.log('- Critical:', stats.critical)
|
|
255
|
-
|
|
256
|
-
// Performance metrics
|
|
257
|
-
console.log('Buffer efficiency:', stats.bufferEfficiency, '%')
|
|
258
|
-
console.log('Average log size:', stats.averageLogSize, 'bytes')
|
|
259
|
-
console.log('Logs per minute:', stats.logsPerMinute)
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
### Advanced Analytics
|
|
263
|
-
|
|
264
|
-
```typescript
|
|
265
|
-
// Get detailed analytics
|
|
266
|
-
const analytics = logger.getAnalytics({
|
|
267
|
-
timeframe: '24h', // Last 24 hours
|
|
268
|
-
groupBy: 'hour', // Group by hour
|
|
269
|
-
includeMetrics: true // Include performance metrics
|
|
270
|
-
})
|
|
271
|
-
|
|
272
|
-
// Analytics Output:
|
|
273
|
-
{
|
|
274
|
-
timeframe: {
|
|
275
|
-
start: '2024-01-14T10:30:00.000Z',
|
|
276
|
-
end: '2024-01-15T10:30:00.000Z',
|
|
277
|
-
duration: '24 hours'
|
|
278
|
-
},
|
|
279
|
-
summary: {
|
|
280
|
-
totalLogs: 1547,
|
|
281
|
-
errorRate: 0.023, // 2.3% error rate
|
|
282
|
-
averagePerHour: 64.4,
|
|
283
|
-
peakHour: '14:00',
|
|
284
|
-
peakCount: 142
|
|
285
|
-
},
|
|
286
|
-
breakdown: {
|
|
287
|
-
'10:00': { debug: 45, info: 23, warn: 3, error: 1 },
|
|
288
|
-
'11:00': { debug: 52, info: 31, warn: 5, error: 2 },
|
|
289
|
-
// ... hourly breakdown
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
## 🔍 Advanced Filtering
|
|
295
|
-
|
|
296
|
-
### Filter Options
|
|
297
|
-
|
|
298
|
-
```typescript
|
|
299
|
-
interface ExportFilters {
|
|
300
|
-
level?: LogLevel | LogLevel[] // Filter by log level(s)
|
|
301
|
-
from?: Date | string // Start date/time
|
|
302
|
-
to?: Date | string // End date/time
|
|
303
|
-
prefix?: string | string[] // Filter by prefix(es)
|
|
304
|
-
content?: string // Search message content
|
|
305
|
-
hasArgs?: boolean // Only logs with additional arguments
|
|
306
|
-
function?: string // Filter by calling function
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
// Complex filtering example
|
|
310
|
-
const filteredData = await logger.exportLogs('json', {
|
|
311
|
-
filter: {
|
|
312
|
-
level: ['error', 'critical'],
|
|
313
|
-
from: '2024-01-01',
|
|
314
|
-
to: new Date(),
|
|
315
|
-
prefix: ['API', 'DATABASE'],
|
|
316
|
-
content: 'timeout'
|
|
317
|
-
},
|
|
318
|
-
limit: 200,
|
|
319
|
-
groupBy: 'prefix'
|
|
320
|
-
})
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
### Real-time Filtering
|
|
324
|
-
|
|
325
|
-
```typescript
|
|
326
|
-
// Stream filtered logs in real-time
|
|
327
|
-
logger.onLog((entry) => {
|
|
328
|
-
if (entry.level === 'error' && entry.prefix === 'PAYMENT') {
|
|
329
|
-
// Send immediate alert for payment errors
|
|
330
|
-
sendSlackAlert(entry)
|
|
331
|
-
}
|
|
332
|
-
})
|
|
333
|
-
|
|
334
|
-
// Conditional remote logging
|
|
335
|
-
logger.addRemoteHandler('https://critical-alerts.com/api', {
|
|
336
|
-
filter: (entry) => entry.level === 'critical',
|
|
337
|
-
immediate: true // Skip batching for critical logs
|
|
338
|
-
})
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
## 🎯 Use Cases
|
|
342
|
-
|
|
343
|
-
### Error Tracking & Monitoring
|
|
344
|
-
|
|
345
|
-
```typescript
|
|
346
|
-
const errorLogger = new ExportLogger({
|
|
347
|
-
bufferSize: 5000,
|
|
348
|
-
autoExport: {
|
|
349
|
-
format: 'json',
|
|
350
|
-
trigger: 'error', // Auto-export on errors
|
|
351
|
-
destination: 'https://error-tracking.com/api'
|
|
352
|
-
}
|
|
353
|
-
})
|
|
354
|
-
|
|
355
|
-
// Production error handling
|
|
356
|
-
try {
|
|
357
|
-
await riskyOperation()
|
|
358
|
-
} catch (error) {
|
|
359
|
-
errorLogger.error('Operation failed', {
|
|
360
|
-
error: error.message,
|
|
361
|
-
stack: error.stack,
|
|
362
|
-
context: getCurrentContext()
|
|
363
|
-
})
|
|
364
|
-
|
|
365
|
-
// Automatically exports and sends to error tracking service
|
|
366
|
-
}
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
### Audit Logging
|
|
370
|
-
|
|
371
|
-
```typescript
|
|
372
|
-
const auditLogger = new ExportLogger({
|
|
373
|
-
bufferSize: 10000,
|
|
374
|
-
encryption: true, // Encrypt sensitive data
|
|
375
|
-
immutable: true, // Prevent log modification
|
|
376
|
-
digitalSigning: true // Sign logs for integrity
|
|
377
|
-
})
|
|
378
|
-
|
|
379
|
-
// Audit trail
|
|
380
|
-
auditLogger.info('User login', {
|
|
381
|
-
userId: 123,
|
|
382
|
-
ip: '192.168.1.100',
|
|
383
|
-
userAgent: 'Mozilla/5.0...'
|
|
384
|
-
})
|
|
385
|
-
|
|
386
|
-
auditLogger.info('Data access', {
|
|
387
|
-
userId: 123,
|
|
388
|
-
resource: '/api/sensitive-data',
|
|
389
|
-
action: 'read'
|
|
390
|
-
})
|
|
391
|
-
|
|
392
|
-
// Export signed audit logs
|
|
393
|
-
const auditTrail = await auditLogger.exportLogs('xml', {
|
|
394
|
-
signed: true,
|
|
395
|
-
encrypted: true
|
|
396
|
-
})
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
### Performance Monitoring
|
|
400
|
-
|
|
401
|
-
```typescript
|
|
402
|
-
const perfLogger = new ExportLogger({
|
|
403
|
-
bufferSize: 2000,
|
|
404
|
-
includePerformanceMetrics: true
|
|
405
|
-
})
|
|
406
|
-
|
|
407
|
-
// Performance tracking
|
|
408
|
-
perfLogger.time('api-request')
|
|
409
|
-
const result = await apiCall()
|
|
410
|
-
perfLogger.timeEnd('api-request')
|
|
411
|
-
|
|
412
|
-
perfLogger.info('Request completed', {
|
|
413
|
-
duration: performance.now() - startTime,
|
|
414
|
-
memory: process.memoryUsage(),
|
|
415
|
-
cpu: process.cpuUsage()
|
|
416
|
-
})
|
|
417
|
-
|
|
418
|
-
// Export performance data
|
|
419
|
-
const perfData = await perfLogger.exportLogs('csv', {
|
|
420
|
-
filter: { hasMetrics: true },
|
|
421
|
-
format: 'performance' // Special performance format
|
|
422
|
-
})
|
|
423
|
-
```
|
|
424
|
-
|
|
425
|
-
## 🔧 Configuration Options
|
|
426
|
-
|
|
427
|
-
### Logger Configuration
|
|
428
|
-
|
|
429
|
-
```typescript
|
|
430
|
-
interface ExportLoggerConfig {
|
|
431
|
-
bufferSize?: number // Buffer size (default: 1000)
|
|
432
|
-
bufferMode?: 'circular' | 'grow' // Buffer behavior
|
|
433
|
-
autoExport?: { // Automatic export settings
|
|
434
|
-
format: ExportFormat
|
|
435
|
-
trigger: 'size' | 'time' | 'level'
|
|
436
|
-
threshold: number
|
|
437
|
-
destination?: string
|
|
438
|
-
}
|
|
439
|
-
remote?: { // Remote logging settings
|
|
440
|
-
batchSize: number
|
|
441
|
-
batchInterval: number
|
|
442
|
-
retries: number
|
|
443
|
-
timeout: number
|
|
444
|
-
}
|
|
445
|
-
encryption?: boolean // Encrypt log data
|
|
446
|
-
compression?: boolean // Compress exports
|
|
447
|
-
includeStackTrace?: boolean // Include stack traces
|
|
448
|
-
includePerformance?: boolean // Include perf metrics
|
|
449
|
-
}
|
|
450
|
-
```
|
|
451
|
-
|
|
452
|
-
### Environment Variables
|
|
453
|
-
|
|
454
|
-
```bash
|
|
455
|
-
# .env configuration
|
|
456
|
-
BETTER_LOGGER_BUFFER_SIZE=5000
|
|
457
|
-
BETTER_LOGGER_REMOTE_ENDPOINT=https://logs.company.com/api
|
|
458
|
-
BETTER_LOGGER_API_KEY=your-secret-key
|
|
459
|
-
BETTER_LOGGER_ENCRYPTION=true
|
|
460
|
-
BETTER_LOGGER_AUTO_EXPORT=true
|
|
461
|
-
```
|
|
462
|
-
|
|
463
|
-
---
|
|
464
|
-
|
|
465
|
-
**Perfect for:** Production applications • Error tracking • Audit logging • Performance monitoring • Data analytics
|
|
466
|
-
|
|
467
|
-
[← Back to main documentation](../README.md)
|
package/docs/PACKAGES.md
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
layout: default
|
|
3
|
-
title: Sub-Packages Guide
|
|
4
|
-
permalink: /packages/
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# 📦 Sub-Packages Guide
|
|
8
|
-
|
|
9
|
-
Better Logger provides modular architecture with independent packages for specific functionality.
|
|
10
|
-
|
|
11
|
-
## Package Overview
|
|
12
|
-
|
|
13
|
-
| Package | Description | Size | Dependencies |
|
|
14
|
-
|---------|-------------|------|--------------|
|
|
15
|
-
| `@mks2508/better-logger` | **Main package** - Full functionality | ~45KB | None |
|
|
16
|
-
| `@mks2508/better-logger-core` | **Core logging** - Essential features only | ~15KB | None |
|
|
17
|
-
| `@mks2508/better-logger-styling` | **Styling system** - CSS themes & visuals | ~12KB | core |
|
|
18
|
-
| `@mks2508/better-logger-exports` | **Export handlers** - File, remote, analytics | ~18KB | core |
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## 🚀 Installation Options
|
|
23
|
-
|
|
24
|
-
### Full Package (Recommended)
|
|
25
|
-
```bash
|
|
26
|
-
npm install @mks2508/better-logger
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### Modular Installation
|
|
30
|
-
```bash
|
|
31
|
-
# Core functionality only
|
|
32
|
-
npm install @mks2508/better-logger-core
|
|
33
|
-
|
|
34
|
-
# Add styling capabilities
|
|
35
|
-
npm install @mks2508/better-logger-styling
|
|
36
|
-
|
|
37
|
-
# Add export functionality
|
|
38
|
-
npm install @mks2508/better-logger-exports
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## 📋 Package Details
|
|
44
|
-
|
|
45
|
-
### Core Package (`@mks2508/better-logger-core`)
|
|
46
|
-
|
|
47
|
-
**What it includes:**
|
|
48
|
-
- ✅ Basic logging methods (debug, info, warn, error, critical)
|
|
49
|
-
- ✅ Log level filtering and verbosity
|
|
50
|
-
- ✅ Performance timing (time/timeEnd)
|
|
51
|
-
- ✅ Stack trace capture
|
|
52
|
-
- ✅ Scoped loggers with prefixes
|
|
53
|
-
- ✅ Basic console grouping
|
|
54
|
-
|
|
55
|
-
**What it excludes:**
|
|
56
|
-
- ❌ Advanced CSS styling and themes
|
|
57
|
-
- ❌ Export handlers (file, remote, analytics)
|
|
58
|
-
- ❌ CLI interface
|
|
59
|
-
- ❌ SVG banners and animations
|
|
60
|
-
|
|
61
|
-
```typescript
|
|
62
|
-
// Core-only usage
|
|
63
|
-
import { Logger } from '@mks2508/better-logger-core';
|
|
64
|
-
|
|
65
|
-
const logger = new Logger();
|
|
66
|
-
logger.info('Basic logging works!');
|
|
67
|
-
logger.time('operation');
|
|
68
|
-
// ... do work
|
|
69
|
-
logger.timeEnd('operation');
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### Styling Package (`@mks2508/better-logger-styling`)
|
|
73
|
-
|
|
74
|
-
**What it adds:**
|
|
75
|
-
- ✅ Advanced CSS gradients and themes
|
|
76
|
-
- ✅ Pre-built theme variants (matrix, cyberpunk, etc.)
|
|
77
|
-
- ✅ Custom style builder with fluent API
|
|
78
|
-
- ✅ SVG banner support
|
|
79
|
-
- ✅ Animation effects for console output
|
|
80
|
-
|
|
81
|
-
```typescript
|
|
82
|
-
// With styling capabilities
|
|
83
|
-
import { Logger } from '@mks2508/better-logger-core';
|
|
84
|
-
import { applyTheme, StyleBuilder } from '@mks2508/better-logger-styling';
|
|
85
|
-
|
|
86
|
-
const logger = new Logger();
|
|
87
|
-
applyTheme(logger, 'matrix');
|
|
88
|
-
|
|
89
|
-
// Custom styling
|
|
90
|
-
const style = new StyleBuilder()
|
|
91
|
-
.backgroundColor('#1a1a2e')
|
|
92
|
-
.color('#eee')
|
|
93
|
-
.fontSize('14px')
|
|
94
|
-
.build();
|
|
95
|
-
|
|
96
|
-
logger.info('Styled message', { style });
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### Exports Package (`@mks2508/better-logger-exports`)
|
|
100
|
-
|
|
101
|
-
**What it adds:**
|
|
102
|
-
- ✅ File export handlers (CSV, JSON, XML)
|
|
103
|
-
- ✅ Remote logging to external services
|
|
104
|
-
- ✅ Analytics integration handlers
|
|
105
|
-
- ✅ Custom export format support
|
|
106
|
-
- ✅ Batch processing and buffering
|
|
107
|
-
|
|
108
|
-
```typescript
|
|
109
|
-
// With export capabilities
|
|
110
|
-
import { Logger } from '@mks2508/better-logger-core';
|
|
111
|
-
import { FileLogHandler, RemoteLogHandler } from '@mks2508/better-logger-exports';
|
|
112
|
-
|
|
113
|
-
const logger = new Logger();
|
|
114
|
-
|
|
115
|
-
// Add file export
|
|
116
|
-
logger.addHandler(new FileLogHandler({
|
|
117
|
-
filename: 'app.log',
|
|
118
|
-
format: 'json',
|
|
119
|
-
maxSize: '10MB'
|
|
120
|
-
}));
|
|
121
|
-
|
|
122
|
-
// Add remote logging
|
|
123
|
-
logger.addHandler(new RemoteLogHandler({
|
|
124
|
-
endpoint: 'https://api.example.com/logs',
|
|
125
|
-
apiKey: 'your-key',
|
|
126
|
-
batchSize: 100
|
|
127
|
-
}));
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
## 🔧 Build Your Own Stack
|
|
133
|
-
|
|
134
|
-
### Minimal Setup (Core Only)
|
|
135
|
-
Perfect for lightweight applications or libraries.
|
|
136
|
-
|
|
137
|
-
```typescript
|
|
138
|
-
import { Logger } from '@mks2508/better-logger-core';
|
|
139
|
-
|
|
140
|
-
const logger = new Logger({
|
|
141
|
-
prefix: '[MyApp]',
|
|
142
|
-
level: 'info'
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
export default logger;
|
|
146
|
-
```
|
|
147
|
-
**Bundle size:** ~15KB
|
|
148
|
-
|
|
149
|
-
### Visual Setup (Core + Styling)
|
|
150
|
-
For applications that need visual appeal in dev tools.
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
import { Logger } from '@mks2508/better-logger-core';
|
|
154
|
-
import { applyTheme } from '@mks2508/better-logger-styling';
|
|
155
|
-
|
|
156
|
-
const logger = new Logger();
|
|
157
|
-
applyTheme(logger, 'cyberpunk');
|
|
158
|
-
|
|
159
|
-
export default logger;
|
|
160
|
-
```
|
|
161
|
-
**Bundle size:** ~27KB
|
|
162
|
-
|
|
163
|
-
### Full-Featured Setup (All Packages)
|
|
164
|
-
Complete logging solution with all capabilities.
|
|
165
|
-
|
|
166
|
-
```typescript
|
|
167
|
-
import { Logger } from '@mks2508/better-logger-core';
|
|
168
|
-
import { applyTheme } from '@mks2508/better-logger-styling';
|
|
169
|
-
import { FileLogHandler } from '@mks2508/better-logger-exports';
|
|
170
|
-
|
|
171
|
-
const logger = new Logger();
|
|
172
|
-
applyTheme(logger, 'matrix');
|
|
173
|
-
logger.addHandler(new FileLogHandler({ filename: 'app.log' }));
|
|
174
|
-
|
|
175
|
-
export default logger;
|
|
176
|
-
```
|
|
177
|
-
**Bundle size:** ~45KB
|
|
178
|
-
|
|
179
|
-
---
|
|
180
|
-
|
|
181
|
-
## 📊 Performance Comparison
|
|
182
|
-
|
|
183
|
-
| Setup | Bundle Size | Load Time | Memory Usage | Features |
|
|
184
|
-
|-------|-------------|-----------|--------------|----------|
|
|
185
|
-
| Core Only | 15KB | <10ms | <2MB | Basic logging |
|
|
186
|
-
| Core + Styling | 27KB | <15ms | <3MB | Styled output |
|
|
187
|
-
| Core + Exports | 33KB | <20ms | <4MB | With file/remote |
|
|
188
|
-
| Full Package | 45KB | <25ms | <5MB | All features |
|
|
189
|
-
|
|
190
|
-
---
|
|
191
|
-
|
|
192
|
-
## 🔄 Migration Guide
|
|
193
|
-
|
|
194
|
-
### From Full to Modular
|
|
195
|
-
If you want to reduce bundle size:
|
|
196
|
-
|
|
197
|
-
```typescript
|
|
198
|
-
// Before: Full package
|
|
199
|
-
import { Logger } from '@mks2508/better-logger';
|
|
200
|
-
|
|
201
|
-
// After: Modular approach
|
|
202
|
-
import { Logger } from '@mks2508/better-logger-core';
|
|
203
|
-
import { applyTheme } from '@mks2508/better-logger-styling'; // Only if needed
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
### From v0.8.x to v0.1.0-rc.1
|
|
207
|
-
The package structure changed in v0.1.0-rc.1:
|
|
208
|
-
|
|
209
|
-
```bash
|
|
210
|
-
# Update all packages
|
|
211
|
-
npm update @mks2508/better-logger@0.1.0-rc.1
|
|
212
|
-
npm update @mks2508/better-logger-core@0.1.0-rc.1
|
|
213
|
-
npm update @mks2508/better-logger-styling@0.1.0-rc.1
|
|
214
|
-
npm update @mks2508/better-logger-exports@0.1.0-rc.1
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
---
|
|
218
|
-
|
|
219
|
-
## 🎯 Recommendations
|
|
220
|
-
|
|
221
|
-
### For Libraries
|
|
222
|
-
Use **core-only** to minimize dependencies:
|
|
223
|
-
```bash
|
|
224
|
-
npm install @mks2508/better-logger-core
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
### For Applications
|
|
228
|
-
Use **full package** for complete features:
|
|
229
|
-
```bash
|
|
230
|
-
npm install @mks2508/better-logger
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
### For Production APIs
|
|
234
|
-
Use **core + exports** for logging + file/remote:
|
|
235
|
-
```bash
|
|
236
|
-
npm install @mks2508/better-logger-core @mks2508/better-logger-exports
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
### For Development
|
|
240
|
-
Use **full package** with enhanced CLI:
|
|
241
|
-
```bash
|
|
242
|
-
npm install @mks2508/better-logger
|
|
243
|
-
# Includes interactive CLI, history, plugins, etc.
|
|
244
|
-
```
|