@mks2508/better-logger 0.0.1 → 0.0.2-alpha.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/.claude/settings.local.json +10 -1
- package/.github/workflows/ci.yml +319 -0
- package/.github/workflows/release.yml +269 -0
- package/.npmrc.bak +1 -0
- package/README.md +577 -0
- package/demo.html +840 -0
- package/dist/chunks/Logger-BQhMKy_T.js +2 -0
- package/dist/chunks/Logger-BQhMKy_T.js.map +1 -0
- package/dist/chunks/Logger-BrFKFZcD.js +978 -0
- package/dist/chunks/Logger-BrFKFZcD.js.map +1 -0
- package/dist/chunks/core-2opW4Pi3.js +194 -0
- package/dist/chunks/core-2opW4Pi3.js.map +1 -0
- package/dist/chunks/core-DyugwSYZ.js +4 -0
- package/dist/chunks/core-DyugwSYZ.js.map +1 -0
- package/dist/chunks/exports-BNP3R7dp.js +421 -0
- package/dist/chunks/exports-BNP3R7dp.js.map +1 -0
- package/dist/chunks/exports-U1xLBXrY.js +2 -0
- package/dist/chunks/exports-U1xLBXrY.js.map +1 -0
- package/dist/chunks/styling-DhUDzwlE.js +654 -0
- package/dist/chunks/styling-DhUDzwlE.js.map +1 -0
- package/dist/chunks/styling-tmRDI28D.js +2 -0
- package/dist/chunks/styling-tmRDI28D.js.map +1 -0
- package/dist/core.cjs +2 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.js +244 -0
- package/dist/core.js.map +1 -0
- package/dist/exports.cjs +2 -0
- package/dist/exports.cjs.map +1 -0
- package/dist/exports.js +237 -0
- package/dist/exports.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +105 -0
- package/dist/index.js.map +1 -0
- package/dist/styling.cjs +2 -0
- package/dist/styling.cjs.map +1 -0
- package/dist/styling.js +146 -0
- package/dist/styling.js.map +1 -0
- package/dist/types/core.d.ts +211 -0
- package/dist/types/exports.d.ts +600 -0
- package/dist/types/index.d.ts +675 -0
- package/dist/types/styling.d.ts +751 -0
- package/docs/CORE.md +264 -0
- package/docs/EXPORTS.md +467 -0
- package/docs/STYLING.md +405 -0
- package/index.html +28 -4
- package/package.json +37 -4
- package/src/Logger.ts +28 -8
- package/src/cli/CommandProcessor.ts +2 -2
- package/src/cli/commands/ExportCommand.ts +5 -0
- package/src/cli/commands/StatusCommand.ts +11 -10
- package/src/core.ts +320 -0
- package/src/example.ts +184 -62
- package/src/exports-module.ts +311 -0
- package/src/handlers/ExportLogHandler.ts +34 -13
- package/src/index.ts +97 -79
- package/src/main.ts +77 -7
- package/src/styling-module.ts +244 -0
- package/src/utils/stackTrace.ts +39 -10
- package/src/utils/timestamps.ts +1 -1
- package/tsconfig.json +40 -14
- package/vite.config.ts +84 -0
- package/dist/assets/index-DxvJByYN.js +0 -183
- package/dist/index.html +0 -334
package/README.md
ADDED
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# 🚀 Better Logger
|
|
4
|
+
|
|
5
|
+
**State-of-the-art console logger with advanced CSS styling, SVG support, animations, and CLI interface**
|
|
6
|
+
|
|
7
|
+
[](https://github.com/MKS2508/advanced-logger/releases)
|
|
8
|
+
[](https://typescriptlang.org)
|
|
9
|
+
[](https://bundlephobia.com)
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
[](https://nodejs.org)
|
|
12
|
+
|
|
13
|
+
*Transform your logging experience with advanced visual features, modular architecture, and enterprise-grade performance*
|
|
14
|
+
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 🌟 Features
|
|
20
|
+
|
|
21
|
+
| **Visual Excellence** | **Performance & Architecture** | **Developer Experience** |
|
|
22
|
+
|:---------------------|:-------------------------------|:-------------------------|
|
|
23
|
+
| 🎨 **Advanced CSS Styling** | ⚡ **64KB Full Bundle** | 💻 **CLI Interface** |
|
|
24
|
+
| 🖼️ **SVG Background Support** | 🎯 **Tree-Shakeable Modules** | 🔧 **TypeScript First** |
|
|
25
|
+
| ✨ **CSS Animations** | 🚀 **<13KB Gzipped** | 📦 **Modular Imports** |
|
|
26
|
+
| 🌈 **Theme System** | 💾 **Minimal Memory** | 🛠️ **Hot Reload** |
|
|
27
|
+
| 🎭 **Multi-Banner Types** | 📊 **Export Capabilities** | 🔍 **Stack Trace** |
|
|
28
|
+
|
|
29
|
+
## 🚀 Quick Start
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Install the package
|
|
33
|
+
npm install @mks2508/better-logger
|
|
34
|
+
|
|
35
|
+
# Basic usage
|
|
36
|
+
import logger from '@mks2508/better-logger'
|
|
37
|
+
|
|
38
|
+
logger.info('Hello, beautiful logs! 🎉')
|
|
39
|
+
logger.success('Operation completed successfully')
|
|
40
|
+
logger.error('Something went wrong', error)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Modular Imports
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
// Core logging only (~6KB)
|
|
47
|
+
import { debug, info, warn, error } from '@mks2508/better-logger/core'
|
|
48
|
+
|
|
49
|
+
// With advanced styling (~26KB)
|
|
50
|
+
import { logAnimated, setTheme } from '@mks2508/better-logger/styling'
|
|
51
|
+
|
|
52
|
+
// With export capabilities (~12KB)
|
|
53
|
+
import { exportLogs } from '@mks2508/better-logger/exports'
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## ✨ Visual Showcase
|
|
57
|
+
|
|
58
|
+
### Theme System
|
|
59
|
+
```typescript
|
|
60
|
+
import { setTheme, showBanner } from '@mks2508/better-logger'
|
|
61
|
+
|
|
62
|
+
// Apply theme with visual banner
|
|
63
|
+
setTheme('cyberpunk') // neon, dark, retro, cyberpunk
|
|
64
|
+
showBanner('animated') // simple, ascii, unicode, svg, animated
|
|
65
|
+
|
|
66
|
+
logger.info('Themed logging experience! 🌈')
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### SVG Backgrounds
|
|
70
|
+
```typescript
|
|
71
|
+
import { logWithSVG } from '@mks2508/better-logger'
|
|
72
|
+
|
|
73
|
+
const customSVG = `<svg>...</svg>`
|
|
74
|
+
logWithSVG('Custom branded message', customSVG, {
|
|
75
|
+
width: 400,
|
|
76
|
+
height: 80,
|
|
77
|
+
padding: '40px 200px'
|
|
78
|
+
})
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### CSS Animations
|
|
82
|
+
```typescript
|
|
83
|
+
import { logAnimated } from '@mks2508/better-logger'
|
|
84
|
+
|
|
85
|
+
logAnimated('🚀 Loading with style...', 3) // 3 second animation
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## 📦 Bundle Analysis
|
|
89
|
+
|
|
90
|
+
> **Optimized for modern applications with intelligent code splitting**
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
┌─────────────────┬─────────┬──────────┬─────────────────┐
|
|
94
|
+
│ Import │ Bundle │ Gzipped │ Use Case │
|
|
95
|
+
├─────────────────┼─────────┼──────────┼─────────────────┤
|
|
96
|
+
│ /core │ 6KB │ 2KB │ Basic logging │
|
|
97
|
+
│ /styling │ 26KB │ 5KB │ Visual features │
|
|
98
|
+
│ /exports │ 12KB │ 3KB │ Data export │
|
|
99
|
+
│ Full library │ 64KB │ 13KB │ All features │
|
|
100
|
+
└─────────────────┴─────────┴──────────┴─────────────────┘
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
<details>
|
|
104
|
+
<summary><b>📊 Detailed Size Breakdown</b></summary>
|
|
105
|
+
|
|
106
|
+
**ESM Build (Production)**
|
|
107
|
+
- Main entry: 3.1 KB
|
|
108
|
+
- Logger chunk: 34.5 KB (CSS styling, banners, SVG, animations)
|
|
109
|
+
- Styling chunk: 20.1 KB (themes, visual effects)
|
|
110
|
+
- Core utilities: 6.0 KB (stack trace, timestamps, handlers)
|
|
111
|
+
|
|
112
|
+
**CJS Build (Minified)**
|
|
113
|
+
- index.cjs: 2.1 KB (gzip: 0.8 KB)
|
|
114
|
+
- core.cjs: 3.2 KB (gzip: 1.3 KB)
|
|
115
|
+
- styling.cjs: 1.9 KB (gzip: 0.7 KB)
|
|
116
|
+
- exports.cjs: 2.6 KB (gzip: 0.9 KB)
|
|
117
|
+
|
|
118
|
+
</details>
|
|
119
|
+
|
|
120
|
+
## 🏗️ Architecture
|
|
121
|
+
|
|
122
|
+
```mermaid
|
|
123
|
+
graph TD
|
|
124
|
+
A[Better Logger] --> B[Core Module]
|
|
125
|
+
A --> C[Styling Module]
|
|
126
|
+
A --> D[Exports Module]
|
|
127
|
+
|
|
128
|
+
B --> E[Basic Logging]
|
|
129
|
+
B --> F[Scoped Loggers]
|
|
130
|
+
B --> G[Performance Timers]
|
|
131
|
+
|
|
132
|
+
C --> H[Theme System]
|
|
133
|
+
C --> I[SVG Support]
|
|
134
|
+
C --> J[Animations]
|
|
135
|
+
C --> K[Banner Types]
|
|
136
|
+
|
|
137
|
+
D --> L[CSV/JSON/XML Export]
|
|
138
|
+
D --> M[Remote Logging]
|
|
139
|
+
D --> N[Buffer Management]
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## 🎯 Module Guide
|
|
143
|
+
|
|
144
|
+
<table>
|
|
145
|
+
<tr>
|
|
146
|
+
<td width="33%" valign="top">
|
|
147
|
+
|
|
148
|
+
### 📦 Core Module
|
|
149
|
+
**Lightweight • Essential features only**
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
import {
|
|
153
|
+
debug, info, warn, error,
|
|
154
|
+
createScopedLogger,
|
|
155
|
+
time, timeEnd
|
|
156
|
+
} from '@mks2508/better-logger/core'
|
|
157
|
+
|
|
158
|
+
const api = createScopedLogger('API')
|
|
159
|
+
api.time('request')
|
|
160
|
+
api.info('Fetching data...')
|
|
161
|
+
api.timeEnd('request')
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**Size: 6KB • Perfect for libraries**
|
|
165
|
+
|
|
166
|
+
</td>
|
|
167
|
+
<td width="33%" valign="top">
|
|
168
|
+
|
|
169
|
+
### 🎨 Styling Module
|
|
170
|
+
**Visual • Themes & animations**
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
import {
|
|
174
|
+
setTheme, logAnimated,
|
|
175
|
+
logWithSVG, showBanner,
|
|
176
|
+
createStyle
|
|
177
|
+
} from '@mks2508/better-logger/styling'
|
|
178
|
+
|
|
179
|
+
setTheme('neon')
|
|
180
|
+
showBanner('svg')
|
|
181
|
+
|
|
182
|
+
const style = createStyle()
|
|
183
|
+
.bg('linear-gradient(...)')
|
|
184
|
+
.build()
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**Size: 26KB • Rich visual experience**
|
|
188
|
+
|
|
189
|
+
</td>
|
|
190
|
+
<td width="33%" valign="top">
|
|
191
|
+
|
|
192
|
+
### 📤 Exports Module
|
|
193
|
+
**Data management • Export capabilities**
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
import {
|
|
197
|
+
ExportLogger,
|
|
198
|
+
exportLogs, addRemoteHandler
|
|
199
|
+
} from '@mks2508/better-logger/exports'
|
|
200
|
+
|
|
201
|
+
const logger = new ExportLogger({
|
|
202
|
+
bufferSize: 1000
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
const csvData = await exportLogs('csv')
|
|
206
|
+
addRemoteHandler('https://api.logs.com')
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Size: 12KB • Enterprise features**
|
|
210
|
+
|
|
211
|
+
</td>
|
|
212
|
+
</tr>
|
|
213
|
+
</table>
|
|
214
|
+
|
|
215
|
+
## 💻 API Reference
|
|
216
|
+
|
|
217
|
+
### Basic Logging
|
|
218
|
+
```typescript
|
|
219
|
+
logger.debug('Debug information', { data: 'object' })
|
|
220
|
+
logger.info('📋 General information')
|
|
221
|
+
logger.warn('⚠️ Warning message')
|
|
222
|
+
logger.error('❌ Error occurred', error)
|
|
223
|
+
logger.success('✅ Operation successful')
|
|
224
|
+
logger.critical('🔥 Critical system error')
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Advanced Features
|
|
228
|
+
```typescript
|
|
229
|
+
// Performance timing
|
|
230
|
+
logger.time('operation')
|
|
231
|
+
// ... code execution
|
|
232
|
+
logger.timeEnd('operation') // Logs: operation: 245.67ms
|
|
233
|
+
|
|
234
|
+
// Data tables
|
|
235
|
+
logger.table([
|
|
236
|
+
{ name: 'Alice', role: 'Admin' },
|
|
237
|
+
{ name: 'Bob', role: 'User' }
|
|
238
|
+
])
|
|
239
|
+
|
|
240
|
+
// Grouped logging
|
|
241
|
+
logger.group('User Session')
|
|
242
|
+
logger.info('Login successful')
|
|
243
|
+
logger.warn('Password expires soon')
|
|
244
|
+
logger.groupEnd()
|
|
245
|
+
|
|
246
|
+
// Stack traces
|
|
247
|
+
logger.trace('Deep debugging information')
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### CLI System
|
|
251
|
+
```typescript
|
|
252
|
+
// Interactive command interface
|
|
253
|
+
logger.cli('/help') // Show available commands
|
|
254
|
+
logger.cli('/theme neon') // Change theme
|
|
255
|
+
logger.cli('/banner ascii') // Change banner type
|
|
256
|
+
logger.cli('/export csv') // Export logs as CSV
|
|
257
|
+
logger.cli('/status') // Show logger status
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## 🎨 Styling API
|
|
261
|
+
|
|
262
|
+
### Custom Styles
|
|
263
|
+
```typescript
|
|
264
|
+
import { createStyle, stylePresets } from '@mks2508/better-logger'
|
|
265
|
+
|
|
266
|
+
// Build custom style
|
|
267
|
+
const myStyle = createStyle()
|
|
268
|
+
.bg('linear-gradient(45deg, #ff6b6b, #feca57)')
|
|
269
|
+
.color('white')
|
|
270
|
+
.padding('12px 20px')
|
|
271
|
+
.rounded('10px')
|
|
272
|
+
.shadow('0 4px 15px rgba(0,0,0,0.3)')
|
|
273
|
+
.bold()
|
|
274
|
+
.build()
|
|
275
|
+
|
|
276
|
+
console.log('%cCustom Message', myStyle)
|
|
277
|
+
|
|
278
|
+
// Use presets
|
|
279
|
+
console.log('%cSuccess!', stylePresets.success)
|
|
280
|
+
console.log('%cError!', stylePresets.error)
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Theme Configuration
|
|
284
|
+
```typescript
|
|
285
|
+
// Available themes
|
|
286
|
+
const themes = ['default', 'dark', 'neon', 'cyberpunk', 'retro']
|
|
287
|
+
|
|
288
|
+
// Set theme with banner
|
|
289
|
+
setTheme('cyberpunk') // Automatically shows themed banner
|
|
290
|
+
|
|
291
|
+
// Manual banner display
|
|
292
|
+
showBanner('animated') // simple, ascii, unicode, svg, animated
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## 📊 Export & Remote Logging
|
|
296
|
+
|
|
297
|
+
### Export Capabilities
|
|
298
|
+
```typescript
|
|
299
|
+
import { ExportLogger } from '@mks2508/better-logger/exports'
|
|
300
|
+
|
|
301
|
+
const logger = new ExportLogger({ bufferSize: 1000 })
|
|
302
|
+
|
|
303
|
+
// Export in different formats
|
|
304
|
+
const csvData = await logger.exportLogs('csv')
|
|
305
|
+
const jsonData = await logger.exportLogs('json', {
|
|
306
|
+
filter: { level: 'error' },
|
|
307
|
+
limit: 100
|
|
308
|
+
})
|
|
309
|
+
|
|
310
|
+
// Get statistics
|
|
311
|
+
const stats = logger.getLogStats()
|
|
312
|
+
console.log(`Errors: ${stats.error}, Warnings: ${stats.warn}`)
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Remote Logging
|
|
316
|
+
```typescript
|
|
317
|
+
// Add remote endpoints
|
|
318
|
+
logger.addRemoteHandler('https://api.logs.company.com', 'api-key')
|
|
319
|
+
logger.addRemoteHandler('wss://realtime-logs.com/stream')
|
|
320
|
+
|
|
321
|
+
// Logs are automatically sent to remote endpoints
|
|
322
|
+
logger.error('This will be sent to remote servers')
|
|
323
|
+
|
|
324
|
+
// Flush pending logs
|
|
325
|
+
await logger.flushRemoteHandlers()
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
## 🔧 Configuration
|
|
329
|
+
|
|
330
|
+
### Logger Configuration
|
|
331
|
+
```typescript
|
|
332
|
+
import { Logger } from '@mks2508/better-logger'
|
|
333
|
+
|
|
334
|
+
const logger = new Logger({
|
|
335
|
+
verbosity: 'info', // debug, info, warn, error, critical, silent
|
|
336
|
+
enableColors: true, // Enable CSS styling
|
|
337
|
+
enableTimestamps: true, // Add timestamps to logs
|
|
338
|
+
enableStackTrace: false, // Include stack trace info
|
|
339
|
+
globalPrefix: 'MyApp', // Global prefix for all logs
|
|
340
|
+
bufferSize: 1000, // Enable export functionality
|
|
341
|
+
theme: 'neon', // Default theme
|
|
342
|
+
bannerType: 'svg' // Banner type for initialization
|
|
343
|
+
})
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Environment Variables
|
|
347
|
+
```bash
|
|
348
|
+
# .env configuration
|
|
349
|
+
LOGGER_VERBOSITY=debug
|
|
350
|
+
LOGGER_ENABLE_COLORS=true
|
|
351
|
+
LOGGER_THEME=cyberpunk
|
|
352
|
+
LOGGER_BUFFER_SIZE=2000
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
## ⚡ Performance
|
|
356
|
+
|
|
357
|
+
> **Benchmarked on Chrome 120, Node.js 20, 1000 log entries**
|
|
358
|
+
|
|
359
|
+
```
|
|
360
|
+
┌─────────────────┬──────────┬──────────┬─────────────────┐
|
|
361
|
+
│ Operation │ Time │ Memory │ vs Console.log │
|
|
362
|
+
├─────────────────┼──────────┼──────────┼─────────────────┤
|
|
363
|
+
│ Basic Logging │ 0.12ms │ +2MB │ 1.5x slower │
|
|
364
|
+
│ Styled Logging │ 0.35ms │ +5MB │ 2.8x slower │
|
|
365
|
+
│ SVG Backgrounds │ 1.2ms │ +8MB │ 5x slower │
|
|
366
|
+
│ Buffer Export │ 15ms │ +10MB │ N/A │
|
|
367
|
+
└─────────────────┴──────────┴──────────┴─────────────────┘
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
**Memory Usage:**
|
|
371
|
+
- Core module: <2MB additional RAM
|
|
372
|
+
- Full library: <15MB additional RAM
|
|
373
|
+
- Buffer (1000 entries): ~3MB
|
|
374
|
+
- Themes & styling: ~2MB
|
|
375
|
+
|
|
376
|
+
## 🛠️ Development
|
|
377
|
+
|
|
378
|
+
### Setup
|
|
379
|
+
```bash
|
|
380
|
+
# Clone repository
|
|
381
|
+
git clone https://github.com/MKS2508/advanced-logger.git
|
|
382
|
+
cd advanced-logger
|
|
383
|
+
|
|
384
|
+
# Install dependencies
|
|
385
|
+
npm install
|
|
386
|
+
|
|
387
|
+
# Development server
|
|
388
|
+
npm run dev
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
### Build System
|
|
392
|
+
```bash
|
|
393
|
+
npm run build # Production build (ESM + CJS)
|
|
394
|
+
npm run build:watch # Development build with watch
|
|
395
|
+
npm run preview # Preview built library
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
**Build Output:**
|
|
399
|
+
- ESM modules in `dist/*.js`
|
|
400
|
+
- CJS modules in `dist/*.cjs`
|
|
401
|
+
- TypeScript declarations in `dist/types/`
|
|
402
|
+
- Source maps for debugging
|
|
403
|
+
|
|
404
|
+
### Testing
|
|
405
|
+
```bash
|
|
406
|
+
# Interactive testing (browser)
|
|
407
|
+
npm run dev
|
|
408
|
+
# Open http://localhost:5173
|
|
409
|
+
|
|
410
|
+
# Run specific tests
|
|
411
|
+
npm run test:core # Core module tests
|
|
412
|
+
npm run test:styling # Styling tests
|
|
413
|
+
npm run test:exports # Export functionality
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
<details>
|
|
417
|
+
<summary><b>📁 Project Structure</b></summary>
|
|
418
|
+
|
|
419
|
+
```
|
|
420
|
+
advanced-logger/
|
|
421
|
+
├── src/
|
|
422
|
+
│ ├── index.ts # Main entry - full library
|
|
423
|
+
│ ├── core.ts # Core module - minimal logging
|
|
424
|
+
│ ├── styling-module.ts # Styling module - visual features
|
|
425
|
+
│ ├── exports-module.ts # Exports module - data management
|
|
426
|
+
│ │
|
|
427
|
+
│ ├── Logger.ts # Core Logger implementation
|
|
428
|
+
│ ├── types/ # TypeScript type definitions
|
|
429
|
+
│ ├── utils/ # Utility functions
|
|
430
|
+
│ ├── styling/ # Styling system
|
|
431
|
+
│ ├── handlers/ # Log handlers
|
|
432
|
+
│ ├── cli/ # CLI command system
|
|
433
|
+
│ └── constants.ts # Configuration constants
|
|
434
|
+
│
|
|
435
|
+
├── dist/ # Built library files
|
|
436
|
+
│ ├── *.js # ESM builds
|
|
437
|
+
│ ├── *.cjs # CommonJS builds
|
|
438
|
+
│ ├── chunks/ # Code-split chunks
|
|
439
|
+
│ └── types/ # TypeScript declarations
|
|
440
|
+
│
|
|
441
|
+
├── examples/ # Usage examples
|
|
442
|
+
├── tests/ # Test suites
|
|
443
|
+
└── docs/ # Documentation
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
</details>
|
|
447
|
+
|
|
448
|
+
## 📚 Examples
|
|
449
|
+
|
|
450
|
+
### Enterprise Dashboard
|
|
451
|
+
```typescript
|
|
452
|
+
import logger, { createScopedLogger } from '@mks2508/better-logger'
|
|
453
|
+
import { setTheme } from '@mks2508/better-logger/styling'
|
|
454
|
+
|
|
455
|
+
// Configure for enterprise use
|
|
456
|
+
setTheme('dark')
|
|
457
|
+
logger.setGlobalPrefix('DASHBOARD')
|
|
458
|
+
|
|
459
|
+
const apiLogger = createScopedLogger('API')
|
|
460
|
+
const dbLogger = createScopedLogger('DATABASE')
|
|
461
|
+
const authLogger = createScopedLogger('AUTH')
|
|
462
|
+
|
|
463
|
+
// Structured logging with scoped contexts
|
|
464
|
+
apiLogger.time('user-fetch')
|
|
465
|
+
apiLogger.info('Fetching user data', { userId: 12345 })
|
|
466
|
+
|
|
467
|
+
dbLogger.debug('SQL Query', {
|
|
468
|
+
query: 'SELECT * FROM users WHERE id = ?',
|
|
469
|
+
params: [12345]
|
|
470
|
+
})
|
|
471
|
+
|
|
472
|
+
authLogger.success('User authenticated', {
|
|
473
|
+
user: 'john.doe@company.com',
|
|
474
|
+
role: 'admin'
|
|
475
|
+
})
|
|
476
|
+
|
|
477
|
+
apiLogger.timeEnd('user-fetch') // Logs: API user-fetch: 245.32ms
|
|
478
|
+
|
|
479
|
+
// Export session logs
|
|
480
|
+
const sessionLogs = await logger.exportLogs('json', {
|
|
481
|
+
filter: { from: sessionStart },
|
|
482
|
+
limit: 1000
|
|
483
|
+
})
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
### Debugging & Development
|
|
487
|
+
```typescript
|
|
488
|
+
import { Logger } from '@mks2508/better-logger'
|
|
489
|
+
|
|
490
|
+
const debugLogger = new Logger({
|
|
491
|
+
verbosity: 'debug',
|
|
492
|
+
enableStackTrace: true,
|
|
493
|
+
theme: 'cyberpunk'
|
|
494
|
+
})
|
|
495
|
+
|
|
496
|
+
// Rich debugging information
|
|
497
|
+
debugLogger.group('🔍 Bug Investigation')
|
|
498
|
+
debugLogger.debug('Component state', componentState)
|
|
499
|
+
debugLogger.warn('Performance degradation detected')
|
|
500
|
+
debugLogger.trace('Call stack analysis')
|
|
501
|
+
|
|
502
|
+
// Interactive CLI debugging
|
|
503
|
+
debugLogger.cli('/status') // Check logger configuration
|
|
504
|
+
debugLogger.cli('/export csv --level error --limit 50')
|
|
505
|
+
|
|
506
|
+
debugLogger.groupEnd()
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
## 🤝 Contributing
|
|
510
|
+
|
|
511
|
+
Contributions are welcome! This project follows semantic versioning and uses conventional commits.
|
|
512
|
+
|
|
513
|
+
```bash
|
|
514
|
+
# Fork and clone
|
|
515
|
+
git clone https://github.com/yourusername/advanced-logger.git
|
|
516
|
+
|
|
517
|
+
# Create feature branch
|
|
518
|
+
git checkout -b feature/amazing-feature
|
|
519
|
+
|
|
520
|
+
# Install dependencies
|
|
521
|
+
npm install
|
|
522
|
+
|
|
523
|
+
# Make changes and test
|
|
524
|
+
npm run dev
|
|
525
|
+
|
|
526
|
+
# Commit with conventional format
|
|
527
|
+
git commit -m "feat: add amazing new feature"
|
|
528
|
+
|
|
529
|
+
# Push and create PR
|
|
530
|
+
git push origin feature/amazing-feature
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
### Development Scripts
|
|
534
|
+
```bash
|
|
535
|
+
npm run dev # Development server with HMR
|
|
536
|
+
npm run build # Production build
|
|
537
|
+
npm run test # Run test suite
|
|
538
|
+
npm run lint # ESLint + Prettier
|
|
539
|
+
npm run type-check # TypeScript validation
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
## 📈 Roadmap
|
|
543
|
+
|
|
544
|
+
- [x] Core logging functionality with CSS styling
|
|
545
|
+
- [x] Advanced visual features (SVG, animations, themes)
|
|
546
|
+
- [x] Export capabilities (CSV, JSON, XML)
|
|
547
|
+
- [x] CLI interface with interactive commands
|
|
548
|
+
- [x] Modular architecture with tree-shaking
|
|
549
|
+
- [x] TypeScript declarations and documentation
|
|
550
|
+
- [ ] React/Vue.js framework integrations
|
|
551
|
+
- [ ] WebSocket real-time log streaming
|
|
552
|
+
- [ ] Browser DevTools extension
|
|
553
|
+
- [ ] Performance monitoring dashboard
|
|
554
|
+
- [ ] Log aggregation service
|
|
555
|
+
- [ ] Mobile-optimized interface
|
|
556
|
+
|
|
557
|
+
## 📄 License
|
|
558
|
+
|
|
559
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
560
|
+
|
|
561
|
+
## 🙏 Acknowledgments
|
|
562
|
+
|
|
563
|
+
- **Modern Browser APIs** for advanced console styling capabilities
|
|
564
|
+
- **Vite** for lightning-fast build system and development experience
|
|
565
|
+
- **TypeScript** for robust type safety and developer experience
|
|
566
|
+
- **Terser** for production-ready minification and optimization
|
|
567
|
+
|
|
568
|
+
---
|
|
569
|
+
|
|
570
|
+
<div align="center">
|
|
571
|
+
<b>Better Logger</b> • Elevate your logging experience to the next level
|
|
572
|
+
<br><br>
|
|
573
|
+
<a href="https://github.com/MKS2508/advanced-logger/wiki">📚 Documentation</a> •
|
|
574
|
+
<a href="https://github.com/MKS2508/advanced-logger/examples">🧩 Examples</a> •
|
|
575
|
+
<a href="https://github.com/MKS2508/advanced-logger/issues">🐛 Report Bug</a> •
|
|
576
|
+
<a href="https://github.com/MKS2508/advanced-logger/issues">✨ Request Feature</a>
|
|
577
|
+
</div>
|