Skip to content

Commit b809b33

Browse files
authored
🚀 release: v1.2.1 - merge pull request #7 from wgtechlabs/dev
2 parents ed66134 + da35e53 commit b809b33

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,11 @@ Log messages are beautifully formatted with colorized timestamps, levels, and sm
255255

256256
```bash
257257
# Example colorized output (colors visible in terminal)
258-
[2025-05-29T16:57:45.678Z][4:57 PM][DEBUG]: Debugging application flow
259-
[2025-05-29T16:57:46.123Z][4:57 PM][INFO]: Server started successfully
260-
[2025-05-29T16:57:47.456Z][4:57 PM][WARN]: API rate limit approaching
261-
[2025-05-29T16:57:48.789Z][4:57 PM][ERROR]: Database connection failed
262-
[2025-05-29T16:57:49.012Z][4:57 PM][LOG]: Application startup complete
258+
[2025-05-29T16:57:45.678Z][4:57PM][DEBUG]: Debugging application flow
259+
[2025-05-29T16:57:46.123Z][4:57PM][INFO]: Server started successfully
260+
[2025-05-29T16:57:47.456Z][4:57PM][WARN]: API rate limit approaching
261+
[2025-05-29T16:57:48.789Z][4:57PM][ERROR]: Database connection failed
262+
[2025-05-29T16:57:49.012Z][4:57PM][LOG]: Application startup complete
263263
```
264264

265265
**Color Scheme:**

src/__tests__/formatter.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('LogFormatter', () => {
1515
const cleanFormatted = formatted.replace(/\x1b\[[0-9;]*m/g, '');
1616

1717
// Verify format: [ISO_TIMESTAMP][LOCAL_TIME][LEVEL]: message
18-
expect(cleanFormatted).toMatch(/^\[\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z\]\[\d{1,2}:\d{2} [AP]M\]\[INFO\]: Test message$/);
18+
expect(cleanFormatted).toMatch(/^\[\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z\]\[\d{1,2}:\d{2}[AP]M\]\[INFO\]: Test message$/);
1919
});
2020

2121
it('should format different log levels correctly', () => {
@@ -50,7 +50,7 @@ describe('LogFormatter', () => {
5050
const cleanFormatted = formatted.replace(/\x1b\[[0-9;]*m/g, '');
5151

5252
// Should have timestamps and level but empty message at end
53-
expect(cleanFormatted).toMatch(/^\[\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z\]\[\d{1,2}:\d{2} [AP]M\]\[INFO\]: $/);
53+
expect(cleanFormatted).toMatch(/^\[\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z\]\[\d{1,2}:\d{2}[AP]M\]\[INFO\]: $/);
5454
});
5555

5656
it('should handle special characters in messages', () => {
@@ -95,7 +95,7 @@ describe('LogFormatter', () => {
9595

9696
// Should contain timestamp components
9797
expect(formatted).toMatch(/\[\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z\]/); // ISO timestamp
98-
expect(formatted).toMatch(/\[\d{1,2}:\d{2} [AP]M\]/); // Local time
98+
expect(formatted).toMatch(/\[\d{1,2}:\d{2}[AP]M\]/); // Local time
9999
});
100100

101101
it('should format system messages with colors', () => {

src/formatter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class LogFormatter {
3838
hour: 'numeric',
3939
minute: '2-digit',
4040
hour12: true
41-
});
41+
}).replace(/\s+/g, '');
4242

4343
const levelName = this.getLevelName(level);
4444
const levelColor = this.getLevelColor(level);
@@ -64,7 +64,7 @@ export class LogFormatter {
6464
hour: 'numeric',
6565
minute: '2-digit',
6666
hour12: true
67-
});
67+
}).replace(/\s+/g, '');
6868

6969
// Apply colors to each component for better readability
7070
const coloredTimestamp = `${LogFormatter.colors.gray}[${isoTimestamp}]${LogFormatter.colors.reset}`;

0 commit comments

Comments
 (0)