hb-smart-logger 1.0.0 โ 1.0.1
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 +69 -45
- 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
|
|
87
|
+
```
|
|
76
88
|
|
|
77
|
-
What
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
89
|
+
## ๐ What Goes Where?
|
|
90
|
+
|
|
91
|
+
## Log Level ## Files Written
|
|
92
|
+
**log() / info()**
|
|
93
|
+
logs/info/ + logs/combined/
|
|
94
|
+
**warn()**
|
|
95
|
+
logs/warn/ + logs/combined/
|
|
96
|
+
**error()**
|
|
97
|
+
logs/error/ + logs/combined/
|
|
98
|
+
**debug()**
|
|
99
|
+
logs/debug/ + logs/combined/
|
|
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,36 @@ 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
|
-
โ Serverless (file logging disabled environments excluded)
|
|
111
132
|
|
|
112
|
-
|
|
113
|
-
|
|
133
|
+
โ Long-running Node.js services
|
|
134
|
+
|
|
135
|
+
## ๐ฅ Why HB Smart Logger?
|
|
136
|
+
Feature console.log Winston HB Smart Logger
|
|
114
137
|
Daily rotation โ โ โ
|
|
115
138
|
Circular JSON safe โ โ โ
|
|
116
139
|
Per-level files โ โ ๏ธ โ
|
|
117
140
|
Combined logs โ โ ๏ธ โ
|
|
118
141
|
logger.log() alias โ โ โ
|
|
119
142
|
Ready-to-use โ โ ๏ธ โ
|
|
120
|
-
|
|
143
|
+
|
|
144
|
+
## ๐ Requirements
|
|
121
145
|
|
|
122
146
|
Node.js >= 14
|
|
123
147
|
|
|
124
148
|
CommonJS environment
|
|
125
149
|
|
|
126
|
-
๐งญ Roadmap
|
|
150
|
+
## ๐งญ Roadmap
|
|
127
151
|
|
|
128
152
|
Planned enhancements:
|
|
129
153
|
|
|
@@ -137,6 +161,6 @@ TypeScript typings
|
|
|
137
161
|
|
|
138
162
|
Cloud logging support (AWS / GCP)
|
|
139
163
|
|
|
140
|
-
๐ License
|
|
164
|
+
## ๐ License
|
|
141
165
|
|
|
142
|
-
MIT ยฉ 2026 Hafiz Bilal
|
|
166
|
+
MIT ยฉ 2026 Hafiz Bilal
|
package/package.json
CHANGED