hb-smart-logger 1.0.0 โ 1.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/README.md +78 -53
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,67 +1,78 @@
|
|
|
1
|
-
HB Smart Logger ๐
|
|
1
|
+
# HB Smart Logger ๐
|
|
2
2
|
|
|
3
|
-
HB Smart Logger is a production-ready logging solution for Node.js built on top of Winston
|
|
3
|
+
**HB Smart Logger** is a **production-ready logging solution for Node.js** built on top of **Winston**, designed to be **simple to use**, **safe by default**, and **scalable for real-world applications**.
|
|
4
4
|
|
|
5
|
-
It works out of the box with zero configuration
|
|
5
|
+
It works out of the box with **zero configuration**, yet provides advanced features like **daily log rotation**, **safe JSON logging**, and **structured multi-argument logging**.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
---
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
Just install and start logging โ no boilerplate required.
|
|
9
|
+
## โจ Key Benefits
|
|
11
10
|
|
|
12
|
-
โ
|
|
13
|
-
|
|
11
|
+
- โ
**Zero-Config Setup**
|
|
12
|
+
Just install and start logging โ no boilerplate required.
|
|
14
13
|
|
|
15
|
-
โ
|
|
16
|
-
|
|
14
|
+
- โ
**Safe Object Logging**
|
|
15
|
+
Handles **circular JSON** safely (no crashes, no `[object Object]`).
|
|
17
16
|
|
|
18
|
-
โ
|
|
19
|
-
|
|
17
|
+
- โ
**Daily Log Rotation**
|
|
18
|
+
Automatically rotates logs by day and size, with compression and retention.
|
|
20
19
|
|
|
21
|
-
โ
|
|
22
|
-
|
|
20
|
+
- โ
**Separate & Combined Logs**
|
|
21
|
+
Keeps **per-level logs** (`error`, `warn`, `info`, `debug`) **and** a full **combined log**.
|
|
23
22
|
|
|
24
|
-
โ
|
|
25
|
-
|
|
23
|
+
- โ
**Multi-Argument Support**
|
|
24
|
+
Log multiple values like `console.log()` โ strings, objects, and errors.
|
|
26
25
|
|
|
27
|
-
โ
|
|
28
|
-
|
|
26
|
+
- โ
**`logger.log()` Alias**
|
|
27
|
+
Drop-in replacement for `console.log()` โ routes to `info` level internally.
|
|
29
28
|
|
|
30
|
-
โ
|
|
31
|
-
|
|
29
|
+
- โ
**Error Stack Traces Included**
|
|
30
|
+
Errors automatically log full stack traces.
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
- โ
**Production-Ready Defaults**
|
|
33
|
+
Designed for APIs, microservices, background workers, and cron jobs.
|
|
34
|
+
|
|
35
|
+
---
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
## ๐ฆ Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install hb-smart-logger
|
|
41
|
+
```
|
|
42
|
+
## ๐ Quick Start
|
|
43
|
+
```bash
|
|
37
44
|
const logger = require("hb-smart-logger");
|
|
38
45
|
|
|
39
46
|
logger.log("Application started");
|
|
40
47
|
logger.info("Server listening", { port: 3000 });
|
|
41
48
|
logger.warn("Slow response", { endpoint: "/users", timeMs: 1420 });
|
|
42
49
|
logger.error("Database connection failed", new Error("ECONNREFUSED"));
|
|
43
|
-
|
|
44
|
-
๐ง Smart Logging Examples
|
|
50
|
+
```
|
|
51
|
+
## ๐ง Smart Logging Examples
|
|
45
52
|
Log multiple arguments (like console.log)
|
|
53
|
+
```bash
|
|
46
54
|
logger.log("User login", userId, { role: "admin" });
|
|
55
|
+
```
|
|
47
56
|
|
|
48
57
|
Log objects safely (no crashes)
|
|
58
|
+
```bash
|
|
49
59
|
const obj = {};
|
|
50
60
|
obj.self = obj;
|
|
51
|
-
|
|
52
61
|
logger.info("Circular object test", obj);
|
|
53
|
-
|
|
62
|
+
```
|
|
54
63
|
Log errors with stack trace
|
|
64
|
+
```bash
|
|
55
65
|
try {
|
|
56
66
|
throw new Error("Something went wrong");
|
|
57
67
|
} catch (err) {
|
|
58
68
|
logger.error("Unhandled error", err);
|
|
59
69
|
}
|
|
70
|
+
```
|
|
60
71
|
|
|
61
|
-
๐ Log Output Structure
|
|
72
|
+
## ๐ Log Output Structure
|
|
62
73
|
|
|
63
74
|
HB Smart Logger automatically creates this structure:
|
|
64
|
-
|
|
75
|
+
```bash
|
|
65
76
|
logs/
|
|
66
77
|
combined/
|
|
67
78
|
combined-2026-01-05.log
|
|
@@ -73,14 +84,21 @@ logs/
|
|
|
73
84
|
info-2026-01-05.log
|
|
74
85
|
debug/
|
|
75
86
|
debug-2026-01-05.log
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## ๐ What Goes Where?
|
|
90
|
+
```bash
|
|
91
|
+
log() / info()
|
|
92
|
+
logs/info/ + logs/combined/
|
|
93
|
+
warn()
|
|
94
|
+
logs/warn/ + logs/combined/
|
|
95
|
+
error()
|
|
96
|
+
logs/error/ + logs/combined/
|
|
97
|
+
debug()
|
|
98
|
+
logs/debug/ + logs/combined/
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## ๐ Log Rotation (Built-In)
|
|
84
102
|
|
|
85
103
|
๐
Daily rotation
|
|
86
104
|
|
|
@@ -92,7 +110,7 @@ debug() logs/debug/ + logs/combined/
|
|
|
92
110
|
|
|
93
111
|
No extra setup required.
|
|
94
112
|
|
|
95
|
-
๐งช Environment Friendly
|
|
113
|
+
## ๐งช Environment Friendly
|
|
96
114
|
|
|
97
115
|
Works in development, staging, and production
|
|
98
116
|
|
|
@@ -100,30 +118,37 @@ Colorized console output for local development
|
|
|
100
118
|
|
|
101
119
|
File-based logging for production systems
|
|
102
120
|
|
|
103
|
-
๐ ๏ธ Use Cases
|
|
121
|
+
## ๐ ๏ธ Use Cases
|
|
104
122
|
|
|
105
123
|
โ REST APIs
|
|
124
|
+
|
|
106
125
|
โ Express / Fastify servers
|
|
126
|
+
|
|
107
127
|
โ Background workers
|
|
128
|
+
|
|
108
129
|
โ Cron jobs
|
|
130
|
+
|
|
109
131
|
โ Microservices
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
132
|
+
|
|
133
|
+
โ Long-running Node.js services
|
|
134
|
+
|
|
135
|
+
## ๐ฅ Why HB Smart Logger?
|
|
136
|
+
```bash
|
|
137
|
+
Feature console.log Winston HB Smart Logger
|
|
138
|
+
Daily rotation โ โ โ
|
|
139
|
+
Circular JSON safe โ โ โ
|
|
140
|
+
Per-level files โ โ ๏ธ โ
|
|
141
|
+
Combined logs โ โ ๏ธ โ
|
|
142
|
+
logger.log() alias โ โ โ
|
|
143
|
+
Ready-to-use โ โ ๏ธ โ
|
|
144
|
+
```
|
|
145
|
+
## ๐ Requirements
|
|
121
146
|
|
|
122
147
|
Node.js >= 14
|
|
123
148
|
|
|
124
149
|
CommonJS environment
|
|
125
150
|
|
|
126
|
-
๐งญ Roadmap
|
|
151
|
+
## ๐งญ Roadmap
|
|
127
152
|
|
|
128
153
|
Planned enhancements:
|
|
129
154
|
|
|
@@ -137,6 +162,6 @@ TypeScript typings
|
|
|
137
162
|
|
|
138
163
|
Cloud logging support (AWS / GCP)
|
|
139
164
|
|
|
140
|
-
๐ License
|
|
165
|
+
## ๐ License
|
|
141
166
|
|
|
142
|
-
MIT ยฉ 2026 Hafiz Bilal
|
|
167
|
+
MIT ยฉ 2026 Hafiz Bilal
|
package/package.json
CHANGED