@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/docs/STYLING.md
ADDED
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
# đ¨ Styling Module
|
|
2
|
+
|
|
3
|
+
**Advanced visual features with themes, SVG support, and CSS animations**
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
import { setTheme, logAnimated, logWithSVG } from '@mks2508/better-logger/styling'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
**Bundle Size:** 26KB âĸ **Gzipped:** 5KB
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## ⨠Features
|
|
14
|
+
|
|
15
|
+
- đ **5 Built-in Themes** (default, dark, neon, cyberpunk, retro)
|
|
16
|
+
- đ **5 Banner Types** (simple, ascii, unicode, svg, animated)
|
|
17
|
+
- đŧī¸ **SVG Background Support** with custom graphics
|
|
18
|
+
- ⨠**CSS Animations** with keyframe injection
|
|
19
|
+
- đ¨ **Style Builder API** for custom console styles
|
|
20
|
+
- đ¯ **Theme-aware Components** with automatic styling
|
|
21
|
+
- đ **Live Theme Switching** with visual feedback
|
|
22
|
+
|
|
23
|
+
## đ Quick Start
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import {
|
|
27
|
+
setTheme, showBanner,
|
|
28
|
+
logAnimated, logWithSVG,
|
|
29
|
+
createStyle, stylePresets
|
|
30
|
+
} from '@mks2508/better-logger/styling'
|
|
31
|
+
|
|
32
|
+
// Apply theme with visual banner
|
|
33
|
+
setTheme('cyberpunk')
|
|
34
|
+
showBanner('animated')
|
|
35
|
+
|
|
36
|
+
// Animated logging
|
|
37
|
+
logAnimated('đ Application starting...', 3)
|
|
38
|
+
|
|
39
|
+
// SVG backgrounds
|
|
40
|
+
const logoSVG = `<svg>...</svg>`
|
|
41
|
+
logWithSVG('Company Logo', logoSVG, {
|
|
42
|
+
width: 400,
|
|
43
|
+
height: 80
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
// Custom styles
|
|
47
|
+
const customStyle = createStyle()
|
|
48
|
+
.bg('linear-gradient(45deg, #ff6b6b, #feca57)')
|
|
49
|
+
.color('white')
|
|
50
|
+
.padding('15px')
|
|
51
|
+
.rounded('10px')
|
|
52
|
+
.build()
|
|
53
|
+
|
|
54
|
+
console.log('%cCustom Message', customStyle)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## đ Theme System
|
|
58
|
+
|
|
59
|
+
### Available Themes
|
|
60
|
+
|
|
61
|
+
| Theme | Primary Colors | Best For |
|
|
62
|
+
|-------|---------------|----------|
|
|
63
|
+
| `default` | Blue gradients | Professional apps |
|
|
64
|
+
| `dark` | Dark theme | Night mode |
|
|
65
|
+
| `neon` | Bright neon colors | Gaming/Creative |
|
|
66
|
+
| `cyberpunk` | Purple/Pink | Futuristic UIs |
|
|
67
|
+
| `retro` | Warm vintage | Nostalgic designs |
|
|
68
|
+
|
|
69
|
+
### Theme Usage
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { setTheme, getAvailableThemes } from '@mks2508/better-logger/styling'
|
|
73
|
+
|
|
74
|
+
// Apply theme
|
|
75
|
+
setTheme('neon') // Shows themed banner automatically
|
|
76
|
+
|
|
77
|
+
// List available themes
|
|
78
|
+
console.log(getAvailableThemes())
|
|
79
|
+
// ['default', 'dark', 'neon', 'cyberpunk', 'retro']
|
|
80
|
+
|
|
81
|
+
// Theme switching
|
|
82
|
+
const themes = ['default', 'dark', 'neon']
|
|
83
|
+
themes.forEach((theme, index) => {
|
|
84
|
+
setTimeout(() => setTheme(theme), index * 2000)
|
|
85
|
+
})
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## đ Banner System
|
|
89
|
+
|
|
90
|
+
### Banner Types
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { showBanner, setBannerType } from '@mks2508/better-logger/styling'
|
|
94
|
+
|
|
95
|
+
// Show specific banner
|
|
96
|
+
showBanner('simple') // Text-only
|
|
97
|
+
showBanner('ascii') // ASCII art
|
|
98
|
+
showBanner('unicode') // Unicode box drawing
|
|
99
|
+
showBanner('svg') // SVG graphics
|
|
100
|
+
showBanner('animated') // CSS animations
|
|
101
|
+
|
|
102
|
+
// Set default banner type
|
|
103
|
+
setBannerType('svg')
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Banner Examples
|
|
107
|
+
|
|
108
|
+
**ASCII Banner:**
|
|
109
|
+
```
|
|
110
|
+
ââââââââââââââââââââââââââââââââââââ
|
|
111
|
+
â BETTER LOGGER â
|
|
112
|
+
â Advanced Console Logging â
|
|
113
|
+
ââââââââââââââââââââââââââââââââââââ
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**SVG Banner:**
|
|
117
|
+
- Custom graphics with gradients
|
|
118
|
+
- Logo integration
|
|
119
|
+
- Responsive sizing
|
|
120
|
+
|
|
121
|
+
**Animated Banner:**
|
|
122
|
+
- Gradient animations
|
|
123
|
+
- Fade transitions
|
|
124
|
+
- Loading effects
|
|
125
|
+
|
|
126
|
+
## đŧī¸ SVG Support
|
|
127
|
+
|
|
128
|
+
### Basic SVG Logging
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { logWithSVG } from '@mks2508/better-logger/styling'
|
|
132
|
+
|
|
133
|
+
// Default branded SVG
|
|
134
|
+
logWithSVG('Welcome to Better Logger!')
|
|
135
|
+
|
|
136
|
+
// Custom SVG content
|
|
137
|
+
const customSVG = `
|
|
138
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 80'>
|
|
139
|
+
<defs>
|
|
140
|
+
<linearGradient id='brand' x1='0%' y1='0%' x2='100%' y2='0%'>
|
|
141
|
+
<stop offset='0%' style='stop-color:#667eea'/>
|
|
142
|
+
<stop offset='100%' style='stop-color:#764ba2'/>
|
|
143
|
+
</linearGradient>
|
|
144
|
+
</defs>
|
|
145
|
+
<rect width='100%' height='100%' fill='url(#brand)' rx='8'/>
|
|
146
|
+
<text x='200' y='45' text-anchor='middle' fill='white'
|
|
147
|
+
font-family='Arial' font-size='18' font-weight='bold'>
|
|
148
|
+
My Application
|
|
149
|
+
</text>
|
|
150
|
+
</svg>`
|
|
151
|
+
|
|
152
|
+
logWithSVG('Custom Branding', customSVG, {
|
|
153
|
+
width: 400,
|
|
154
|
+
height: 80,
|
|
155
|
+
padding: '40px 200px'
|
|
156
|
+
})
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Advanced SVG Options
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
interface StyleOptions {
|
|
163
|
+
width?: number // SVG width in pixels
|
|
164
|
+
height?: number // SVG height in pixels
|
|
165
|
+
padding?: string // CSS padding around SVG
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Logo with specific dimensions
|
|
169
|
+
logWithSVG('Product Launch', logoSVG, {
|
|
170
|
+
width: 600,
|
|
171
|
+
height: 120,
|
|
172
|
+
padding: '60px 300px'
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
// Compact notification
|
|
176
|
+
logWithSVG('Alert', alertSVG, {
|
|
177
|
+
width: 200,
|
|
178
|
+
height: 40,
|
|
179
|
+
padding: '20px 100px'
|
|
180
|
+
})
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## ⨠CSS Animations
|
|
184
|
+
|
|
185
|
+
### Animated Logging
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
import { logAnimated } from '@mks2508/better-logger/styling'
|
|
189
|
+
|
|
190
|
+
// Basic animation (3 seconds)
|
|
191
|
+
logAnimated('Loading...')
|
|
192
|
+
|
|
193
|
+
// Custom duration
|
|
194
|
+
logAnimated('đ Feature launched!', 5) // 5 seconds
|
|
195
|
+
|
|
196
|
+
// Multiple animations
|
|
197
|
+
logAnimated('Phase 1 complete', 2)
|
|
198
|
+
setTimeout(() => {
|
|
199
|
+
logAnimated('Phase 2 starting', 2)
|
|
200
|
+
}, 2500)
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Animation Effects
|
|
204
|
+
|
|
205
|
+
**Gradient Animation:**
|
|
206
|
+
- Moving background gradients
|
|
207
|
+
- Smooth color transitions
|
|
208
|
+
- Infinite loop animation
|
|
209
|
+
|
|
210
|
+
**Technical Implementation:**
|
|
211
|
+
```css
|
|
212
|
+
@keyframes loggerGradient {
|
|
213
|
+
0% { background-position: 0% 50%; }
|
|
214
|
+
50% { background-position: 100% 50%; }
|
|
215
|
+
100% { background-position: 0% 50%; }
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## đ¨ Style Builder API
|
|
220
|
+
|
|
221
|
+
### Building Custom Styles
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
import { createStyle, StyleBuilder } from '@mks2508/better-logger/styling'
|
|
225
|
+
|
|
226
|
+
// Fluent interface
|
|
227
|
+
const alertStyle = createStyle()
|
|
228
|
+
.bg('linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%)')
|
|
229
|
+
.color('#ffffff')
|
|
230
|
+
.padding('12px 20px')
|
|
231
|
+
.rounded('8px')
|
|
232
|
+
.border('2px solid #ff5252')
|
|
233
|
+
.shadow('0 4px 15px rgba(255, 107, 107, 0.4)')
|
|
234
|
+
.bold()
|
|
235
|
+
.font('Monaco, Consolas, monospace')
|
|
236
|
+
.animation('pulse 1s ease-in-out infinite')
|
|
237
|
+
.build()
|
|
238
|
+
|
|
239
|
+
console.log('%cđ¨ Critical Alert', alertStyle)
|
|
240
|
+
|
|
241
|
+
// Chaining methods
|
|
242
|
+
const successStyle = new StyleBuilder()
|
|
243
|
+
.bg('#4caf50')
|
|
244
|
+
.color('white')
|
|
245
|
+
.padding('8px 16px')
|
|
246
|
+
.rounded('4px')
|
|
247
|
+
.build()
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Available Style Methods
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
interface StyleBuilder {
|
|
254
|
+
// Background
|
|
255
|
+
bg(gradient: string): StyleBuilder
|
|
256
|
+
backgroundColor(color: string): StyleBuilder
|
|
257
|
+
|
|
258
|
+
// Typography
|
|
259
|
+
color(color: string): StyleBuilder
|
|
260
|
+
font(family: string): StyleBuilder
|
|
261
|
+
fontSize(size: string): StyleBuilder
|
|
262
|
+
bold(): StyleBuilder
|
|
263
|
+
italic(): StyleBuilder
|
|
264
|
+
|
|
265
|
+
// Layout
|
|
266
|
+
padding(padding: string): StyleBuilder
|
|
267
|
+
margin(margin: string): StyleBuilder
|
|
268
|
+
display(display: string): StyleBuilder
|
|
269
|
+
|
|
270
|
+
// Visual effects
|
|
271
|
+
border(border: string): StyleBuilder
|
|
272
|
+
rounded(radius: string): StyleBuilder
|
|
273
|
+
shadow(shadow: string): StyleBuilder
|
|
274
|
+
|
|
275
|
+
// Animations
|
|
276
|
+
animation(animation: string): StyleBuilder
|
|
277
|
+
transition(transition: string): StyleBuilder
|
|
278
|
+
|
|
279
|
+
// Custom CSS
|
|
280
|
+
css(property: string, value: string): StyleBuilder
|
|
281
|
+
|
|
282
|
+
// Build final style
|
|
283
|
+
build(): string
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## đ¯ Pre-built Style Presets
|
|
288
|
+
|
|
289
|
+
### Using Style Presets
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
import { stylePresets } from '@mks2508/better-logger/styling'
|
|
293
|
+
|
|
294
|
+
// Available presets
|
|
295
|
+
console.log('%câ
Success!', stylePresets.success)
|
|
296
|
+
console.log('%câ Error!', stylePresets.error)
|
|
297
|
+
console.log('%câ ī¸ Warning!', stylePresets.warning)
|
|
298
|
+
console.log('%câšī¸ Info', stylePresets.info)
|
|
299
|
+
console.log('%cđ¯ Accent', stylePresets.accent)
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Preset Definitions
|
|
303
|
+
|
|
304
|
+
```typescript
|
|
305
|
+
const stylePresets = {
|
|
306
|
+
success: 'background: linear-gradient(135deg, #4caf50, #45a049); color: white; ...',
|
|
307
|
+
error: 'background: linear-gradient(135deg, #f44336, #d32f2f); color: white; ...',
|
|
308
|
+
warning: 'background: linear-gradient(135deg, #ff9800, #f57c00); color: white; ...',
|
|
309
|
+
info: 'background: linear-gradient(135deg, #2196f3, #1976d2); color: white; ...',
|
|
310
|
+
accent: 'background: linear-gradient(135deg, #9c27b0, #7b1fa2); color: white; ...'
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
## đ§ Advanced Usage
|
|
315
|
+
|
|
316
|
+
### Theme-aware Logging
|
|
317
|
+
|
|
318
|
+
```typescript
|
|
319
|
+
import { setTheme } from '@mks2508/better-logger/styling'
|
|
320
|
+
import { info, success, error } from '@mks2508/better-logger'
|
|
321
|
+
|
|
322
|
+
// Apply theme
|
|
323
|
+
setTheme('cyberpunk')
|
|
324
|
+
|
|
325
|
+
// All subsequent logs use theme colors
|
|
326
|
+
info('System initialized') // Uses cyberpunk info colors
|
|
327
|
+
success('Connection established') // Uses cyberpunk success colors
|
|
328
|
+
error('Authentication failed') // Uses cyberpunk error colors
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Dynamic Style Generation
|
|
332
|
+
|
|
333
|
+
```typescript
|
|
334
|
+
import { createStyle } from '@mks2508/better-logger/styling'
|
|
335
|
+
|
|
336
|
+
// Generate styles based on log level
|
|
337
|
+
function getLogStyle(level: string) {
|
|
338
|
+
const colors = {
|
|
339
|
+
error: ['#f44336', '#d32f2f'],
|
|
340
|
+
warn: ['#ff9800', '#f57c00'],
|
|
341
|
+
info: ['#2196f3', '#1976d2'],
|
|
342
|
+
success: ['#4caf50', '#45a049']
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const [primary, secondary] = colors[level] || colors.info
|
|
346
|
+
|
|
347
|
+
return createStyle()
|
|
348
|
+
.bg(`linear-gradient(135deg, ${primary}, ${secondary})`)
|
|
349
|
+
.color('white')
|
|
350
|
+
.padding('8px 16px')
|
|
351
|
+
.rounded('6px')
|
|
352
|
+
.bold()
|
|
353
|
+
.build()
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
console.log('%cDynamic Error', getLogStyle('error'))
|
|
357
|
+
console.log('%cDynamic Success', getLogStyle('success'))
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### Performance Optimization
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
// Pre-build styles for better performance
|
|
364
|
+
const CACHED_STYLES = {
|
|
365
|
+
header: createStyle().bg('#1976d2').color('white').padding('15px').build(),
|
|
366
|
+
footer: createStyle().bg('#424242').color('#ccc').padding('10px').build(),
|
|
367
|
+
highlight: createStyle().bg('#ffeb3b').color('#333').padding('5px').build()
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// Use cached styles
|
|
371
|
+
console.log('%cApplication Header', CACHED_STYLES.header)
|
|
372
|
+
console.log('%cHighlighted text', CACHED_STYLES.highlight)
|
|
373
|
+
console.log('%cFooter info', CACHED_STYLES.footer)
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
## đą Browser Compatibility
|
|
377
|
+
|
|
378
|
+
### Feature Detection
|
|
379
|
+
|
|
380
|
+
```typescript
|
|
381
|
+
// Automatic fallbacks for unsupported features
|
|
382
|
+
if (typeof document !== 'undefined') {
|
|
383
|
+
// Browser environment - full styling support
|
|
384
|
+
logWithSVG('Rich graphics available')
|
|
385
|
+
logAnimated('Animations supported')
|
|
386
|
+
} else {
|
|
387
|
+
// Node.js environment - graceful degradation
|
|
388
|
+
console.log('Text-only fallback')
|
|
389
|
+
}
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### Support Matrix
|
|
393
|
+
|
|
394
|
+
| Feature | Chrome | Firefox | Safari | Node.js |
|
|
395
|
+
|---------|--------|---------|--------|---------|
|
|
396
|
+
| CSS Styling | â
| â
| â
| â |
|
|
397
|
+
| SVG Backgrounds | â
| â
| â
| â |
|
|
398
|
+
| Animations | â
| â
| â
| â |
|
|
399
|
+
| Unicode Banners | â
| â
| â
| â
|
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
**Perfect for:** Frontend applications âĸ Interactive demos âĸ Creative projects âĸ Brand-aware logging
|
|
404
|
+
|
|
405
|
+
[â Back to main documentation](../README.md)
|
package/index.html
CHANGED
|
@@ -209,8 +209,8 @@
|
|
|
209
209
|
<body>
|
|
210
210
|
<div class="container">
|
|
211
211
|
<header class="header">
|
|
212
|
-
<h1>đ
|
|
213
|
-
<p>
|
|
212
|
+
<h1>đ Better Logger Demo</h1>
|
|
213
|
+
<p>Complete library with styling, SVG, animations, export & CLI features</p>
|
|
214
214
|
<div class="console-note">
|
|
215
215
|
đ Open your browser's Developer Console to see the styled log output
|
|
216
216
|
<button class="devtools-button" id="devtools-btn" onclick="tryOpenDevTools()">
|
|
@@ -245,7 +245,31 @@
|
|
|
245
245
|
</section>
|
|
246
246
|
|
|
247
247
|
<section class="advanced-section">
|
|
248
|
-
<h2>
|
|
248
|
+
<h2>Visual Features</h2>
|
|
249
|
+
<div class="button-grid">
|
|
250
|
+
<button class="log-button info" onclick="testBanners()">
|
|
251
|
+
đ¨ Banner System
|
|
252
|
+
</button>
|
|
253
|
+
<button class="log-button debug" onclick="testThemes()">
|
|
254
|
+
đ Theme Switching
|
|
255
|
+
</button>
|
|
256
|
+
<button class="log-button success" onclick="testSVG()">
|
|
257
|
+
đŧī¸ SVG Backgrounds
|
|
258
|
+
</button>
|
|
259
|
+
<button class="log-button warn" onclick="testAnimations()">
|
|
260
|
+
⨠CSS Animations
|
|
261
|
+
</button>
|
|
262
|
+
<button class="log-button info" onclick="testCLI()">
|
|
263
|
+
đģ CLI Commands
|
|
264
|
+
</button>
|
|
265
|
+
<button class="log-button critical" onclick="testExports()">
|
|
266
|
+
đ¤ Export Features
|
|
267
|
+
</button>
|
|
268
|
+
</div>
|
|
269
|
+
</section>
|
|
270
|
+
|
|
271
|
+
<section class="advanced-section">
|
|
272
|
+
<h2>Core Features</h2>
|
|
249
273
|
<div class="button-grid">
|
|
250
274
|
<button class="log-button info" onclick="testTable()">
|
|
251
275
|
đ Table Display
|
|
@@ -270,7 +294,7 @@
|
|
|
270
294
|
</main>
|
|
271
295
|
|
|
272
296
|
<footer class="footer">
|
|
273
|
-
<p>
|
|
297
|
+
<p>Better Logger v0.0.1 | Built with TypeScript & Modern Web Standards</p>
|
|
274
298
|
</footer>
|
|
275
299
|
</div>
|
|
276
300
|
<script>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mks2508/better-logger",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2-alpha.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "State-of-the-art console logger with advanced CSS styling, SVG support, animations, and CLI interface",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,15 +21,48 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
24
|
-
"url": "https://github.com/MKS2508/advanced-logger.git"
|
|
24
|
+
"url": "git+https://github.com/MKS2508/advanced-logger.git"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/MKS2508/advanced-logger/issues"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://mks2508.github.io/advanced-logger/",
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"registry": "https://registry.npmjs.org/"
|
|
25
32
|
},
|
|
26
33
|
"scripts": {
|
|
27
34
|
"dev": "vite",
|
|
28
35
|
"build": "tsc && vite build",
|
|
29
|
-
"
|
|
36
|
+
"build:watch": "vite build --watch",
|
|
37
|
+
"build:analyze": "vite build --mode analyze",
|
|
38
|
+
"preview": "vite preview",
|
|
39
|
+
"clean": "rm -rf dist node_modules/.vite",
|
|
40
|
+
"type-check": "tsc --noEmit",
|
|
41
|
+
"lint": "echo 'Linting with ESLint...' && exit 0",
|
|
42
|
+
"lint:fix": "echo 'Fixing with ESLint...' && exit 0",
|
|
43
|
+
"test": "echo 'Running tests...' && exit 0",
|
|
44
|
+
"test:watch": "echo 'Running tests in watch mode...' && exit 0",
|
|
45
|
+
"test:coverage": "echo 'Running tests with coverage...' && exit 0",
|
|
46
|
+
"test:performance": "echo 'Running performance benchmarks...' && exit 0",
|
|
47
|
+
"test:visual": "echo 'Running visual tests...' && exit 0",
|
|
48
|
+
"prepublishOnly": "npm run clean && npm run type-check && npm run build",
|
|
49
|
+
"release": "npm version patch && npm publish --access public",
|
|
50
|
+
"release:minor": "npm version minor && npm publish --access public",
|
|
51
|
+
"release:major": "npm version major && npm publish --access public",
|
|
52
|
+
"release:alpha": "npm version prerelease --preid=alpha && npm publish --access public --tag alpha",
|
|
53
|
+
"release:beta": "npm version prerelease --preid=beta && npm publish --access public --tag beta",
|
|
54
|
+
"demo:serve": "python3 -m http.server 8080",
|
|
55
|
+
"size-limit": "echo 'Checking bundle sizes...' && ls -la dist/",
|
|
56
|
+
"ci:install": "npm ci",
|
|
57
|
+
"ci:build": "npm run build",
|
|
58
|
+
"ci:test": "npm run test",
|
|
59
|
+
"ci:publish": "npm publish --access public --ignore-scripts",
|
|
60
|
+
"ci:publish:github": "npm publish --registry=https://npm.pkg.github.com --access public --ignore-scripts"
|
|
30
61
|
},
|
|
31
62
|
"devDependencies": {
|
|
63
|
+
"terser": "^5.43.1",
|
|
32
64
|
"typescript": "~5.8.3",
|
|
33
|
-
"vite": "^7.1.2"
|
|
65
|
+
"vite": "^7.1.2",
|
|
66
|
+
"vite-plugin-dts": "^4.5.4"
|
|
34
67
|
}
|
|
35
68
|
}
|
package/src/Logger.ts
CHANGED
|
@@ -234,7 +234,7 @@ export class Logger {
|
|
|
234
234
|
timestamp: formatTimestamp(),
|
|
235
235
|
level,
|
|
236
236
|
prefix,
|
|
237
|
-
stackInfo: stackInfo
|
|
237
|
+
stackInfo: stackInfo ? stackInfo : undefined,
|
|
238
238
|
};
|
|
239
239
|
|
|
240
240
|
this.handlers.forEach(handler => {
|
|
@@ -290,7 +290,19 @@ export class Logger {
|
|
|
290
290
|
|
|
291
291
|
// Override with success styling
|
|
292
292
|
const successStyle = LEVEL_STYLES.success;
|
|
293
|
-
|
|
293
|
+
let emoji = 'â
';
|
|
294
|
+
let label = 'SUCCESS';
|
|
295
|
+
|
|
296
|
+
if (successStyle) {
|
|
297
|
+
if (successStyle.emoji) {
|
|
298
|
+
emoji = successStyle.emoji;
|
|
299
|
+
}
|
|
300
|
+
if (successStyle.label) {
|
|
301
|
+
label = successStyle.label;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const successFormat = format.replace(/âšī¸ INFO/, `${emoji} ${label}`);
|
|
294
306
|
|
|
295
307
|
const groupIndent = ' '.repeat(this.groupDepth);
|
|
296
308
|
const finalFormat = groupIndent + successFormat;
|
|
@@ -306,7 +318,7 @@ export class Logger {
|
|
|
306
318
|
timestamp: formatTimestamp(),
|
|
307
319
|
level: 'info',
|
|
308
320
|
prefix,
|
|
309
|
-
stackInfo: stackInfo
|
|
321
|
+
stackInfo: stackInfo ? stackInfo : undefined,
|
|
310
322
|
};
|
|
311
323
|
|
|
312
324
|
this.handlers.forEach(handler => {
|
|
@@ -429,7 +441,8 @@ export class Logger {
|
|
|
429
441
|
* Display banner with specified or configured type
|
|
430
442
|
*/
|
|
431
443
|
showBanner(bannerType?: BannerType): void {
|
|
432
|
-
|
|
444
|
+
const effectiveBannerType = bannerType ? bannerType : this.config.bannerType;
|
|
445
|
+
displayInitBanner(effectiveBannerType);
|
|
433
446
|
}
|
|
434
447
|
|
|
435
448
|
/**
|
|
@@ -495,14 +508,21 @@ export class Logger {
|
|
|
495
508
|
*/
|
|
496
509
|
logGrouped<T>(items: T[], groupBy: (item: T) => string): void {
|
|
497
510
|
try {
|
|
498
|
-
// Use Object.groupBy if available (ES2024)
|
|
499
|
-
|
|
500
|
-
|
|
511
|
+
// Use Object.groupBy if available (ES2024), otherwise fallback to reduce
|
|
512
|
+
let grouped: Record<string, T[]>;
|
|
513
|
+
|
|
514
|
+
if ((Object as any).groupBy) {
|
|
515
|
+
grouped = (Object as any).groupBy(items, groupBy);
|
|
516
|
+
} else {
|
|
517
|
+
grouped = items.reduce((acc, item) => {
|
|
501
518
|
const key = groupBy(item);
|
|
502
|
-
if (!acc[key])
|
|
519
|
+
if (!acc[key]) {
|
|
520
|
+
acc[key] = [];
|
|
521
|
+
}
|
|
503
522
|
acc[key].push(item);
|
|
504
523
|
return acc;
|
|
505
524
|
}, {} as Record<string, T[]>);
|
|
525
|
+
}
|
|
506
526
|
|
|
507
527
|
Object.entries(grouped).forEach(([group, groupItems]) => {
|
|
508
528
|
this.group(`Group: ${group}`);
|
|
@@ -51,7 +51,7 @@ export class CommandProcessor {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
const parts = commandString.slice(1).split(' ');
|
|
54
|
-
const commandName = parts[0];
|
|
54
|
+
const commandName = parts[0] || '';
|
|
55
55
|
const args = parts.slice(1).join(' ');
|
|
56
56
|
|
|
57
57
|
const command = this.commands.get(commandName);
|
|
@@ -61,7 +61,7 @@ export class CommandProcessor {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
try {
|
|
64
|
-
await command.execute(args, logger);
|
|
64
|
+
await command.execute(args || '', logger);
|
|
65
65
|
} catch (error) {
|
|
66
66
|
logger.error(`Command '${commandName}' failed:`, error);
|
|
67
67
|
}
|
|
@@ -23,6 +23,11 @@ function parseArguments(args: string): { filters: ExportFilters; options: Export
|
|
|
23
23
|
for (let i = 0; i < argParts.length; i++) {
|
|
24
24
|
const arg = argParts[i];
|
|
25
25
|
|
|
26
|
+
// Skip if arg is null/undefined
|
|
27
|
+
if (!arg) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
|
|
26
31
|
// Format (first argument without --)
|
|
27
32
|
if (i === 0 && !arg.startsWith('--') && arg in EXPORT_FORMATS) {
|
|
28
33
|
format = arg as ExportFormat;
|
|
@@ -14,16 +14,17 @@ export class StatusCommand implements ICommand {
|
|
|
14
14
|
usage = '/status';
|
|
15
15
|
|
|
16
16
|
execute(_args: string, logger: Logger): void {
|
|
17
|
+
const config = logger.getConfig();
|
|
17
18
|
const statusData = {
|
|
18
|
-
theme:
|
|
19
|
-
verbosity:
|
|
20
|
-
colors:
|
|
21
|
-
timestamps:
|
|
22
|
-
stackTrace:
|
|
23
|
-
globalPrefix:
|
|
24
|
-
bannerType:
|
|
19
|
+
theme: config.theme ? config.theme : 'default',
|
|
20
|
+
verbosity: config.verbosity,
|
|
21
|
+
colors: config.enableColors,
|
|
22
|
+
timestamps: config.enableTimestamps,
|
|
23
|
+
stackTrace: config.enableStackTrace,
|
|
24
|
+
globalPrefix: config.globalPrefix ? config.globalPrefix : 'none',
|
|
25
|
+
bannerType: config.bannerType ? config.bannerType : 'simple',
|
|
25
26
|
handlers: logger.getHandlers().length,
|
|
26
|
-
bufferSize:
|
|
27
|
+
bufferSize: config.bufferSize ? config.bufferSize : 1000
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
logger.group('âī¸ Logger Configuration');
|
|
@@ -38,8 +39,8 @@ export class StatusCommand implements ICommand {
|
|
|
38
39
|
logger.table({
|
|
39
40
|
size: `${bufferStats.size}/${bufferStats.maxSize}`,
|
|
40
41
|
usage: `${bufferStats.usage.toFixed(1)}%`,
|
|
41
|
-
oldestLog: bufferStats.oldestLog
|
|
42
|
-
newestLog: bufferStats.newestLog
|
|
42
|
+
oldestLog: bufferStats.oldestLog ? bufferStats.oldestLog.toISOString() : 'None',
|
|
43
|
+
newestLog: bufferStats.newestLog ? bufferStats.newestLog.toISOString() : 'None',
|
|
43
44
|
errorCount: bufferStats.levelCounts.error + bufferStats.levelCounts.critical,
|
|
44
45
|
warningCount: bufferStats.levelCounts.warn
|
|
45
46
|
});
|