vloggo 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 +65 -46
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,17 +15,17 @@ Logging library for Node.js and Bun with file rotation, SMTP notifications, and
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
npm install
|
|
18
|
+
npm install vloggo
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
bun add
|
|
22
|
+
bun add vloggo
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## Quick Start
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
28
|
-
import { VLoggo } from "
|
|
28
|
+
import { VLoggo } from "vloggo";
|
|
29
29
|
|
|
30
30
|
const logger = new VLoggo({ client: "MyApp" });
|
|
31
31
|
|
|
@@ -41,10 +41,10 @@ logger.fatal("DB_DOWN", "Database connection lost");
|
|
|
41
41
|
|
|
42
42
|
```typescript
|
|
43
43
|
const logger = new VLoggo({
|
|
44
|
-
client: "MyApp",
|
|
45
|
-
console: true,
|
|
46
|
-
debug: false,
|
|
47
|
-
json: false,
|
|
44
|
+
client: "MyApp", // Application name
|
|
45
|
+
console: true, // Enable console output
|
|
46
|
+
debug: false, // Enable debug logs
|
|
47
|
+
json: false, // Enable JSON output
|
|
48
48
|
});
|
|
49
49
|
```
|
|
50
50
|
|
|
@@ -54,12 +54,12 @@ const logger = new VLoggo({
|
|
|
54
54
|
const logger = new VLoggo({
|
|
55
55
|
client: "MyApp",
|
|
56
56
|
directory: {
|
|
57
|
-
txt: "/var/log/myapp",
|
|
57
|
+
txt: "/var/log/myapp", // Text log directory
|
|
58
58
|
json: "/var/log/myapp/json", // JSON log directory
|
|
59
59
|
},
|
|
60
60
|
filecount: {
|
|
61
|
-
txt: 31,
|
|
62
|
-
json: 7,
|
|
61
|
+
txt: 31, // Keep 31 days of text logs
|
|
62
|
+
json: 7, // Keep 7 days of JSON logs
|
|
63
63
|
},
|
|
64
64
|
});
|
|
65
65
|
```
|
|
@@ -76,9 +76,9 @@ const logger = new VLoggo({
|
|
|
76
76
|
username: "your-email@gmail.com",
|
|
77
77
|
password: "your-password",
|
|
78
78
|
from: "logs@myapp.com",
|
|
79
|
-
to: "admin@myapp.com",
|
|
79
|
+
to: "admin@myapp.com", // Can be string or array
|
|
80
80
|
},
|
|
81
|
-
throttle: 300000,
|
|
81
|
+
throttle: 300000, // Min 5 minutes between emails
|
|
82
82
|
});
|
|
83
83
|
```
|
|
84
84
|
|
|
@@ -109,9 +109,10 @@ new VLoggo(options?: Partial<VLoggoConfig>)
|
|
|
109
109
|
- `console`: Enable console output (default: true)
|
|
110
110
|
- `debug`: Enable debug mode (default: false)
|
|
111
111
|
- `json`: Enable JSON output (default: false)
|
|
112
|
-
- `directory`: Log directories (default:
|
|
113
|
-
- `filecount`: Retention days (default: { txt: 31, json: 31 })
|
|
112
|
+
- `directory`: Log directories (default: `~/[client]/logs` for txt, `~/[client]/json` for json)
|
|
113
|
+
- `filecount`: Retention days (default: `{ txt: 31, json: 31 }`)
|
|
114
114
|
- `smtp`: SMTP configuration (optional)
|
|
115
|
+
- `notify`: Enable notifications (default: false, automatically set to true if smtp is configured)
|
|
115
116
|
- `throttle`: Email throttle in ms (default: 30000)
|
|
116
117
|
|
|
117
118
|
### Logging Methods
|
|
@@ -132,22 +133,27 @@ logger.fatal(code: string, message: string): void
|
|
|
132
133
|
### Configuration Access
|
|
133
134
|
|
|
134
135
|
```typescript
|
|
135
|
-
// Read configuration
|
|
136
|
-
logger.config.client;
|
|
137
|
-
logger.config.debug;
|
|
138
|
-
logger.config.console;
|
|
139
|
-
logger.config.json;
|
|
140
|
-
logger.config.directory;
|
|
141
|
-
logger.config.filecount;
|
|
142
|
-
logger.config.notify;
|
|
143
|
-
logger.config.smtp;
|
|
144
|
-
logger.config.throttle;
|
|
136
|
+
// Read configuration (readonly)
|
|
137
|
+
logger.config.client; // string
|
|
138
|
+
logger.config.debug; // boolean
|
|
139
|
+
logger.config.console; // boolean
|
|
140
|
+
logger.config.json; // boolean
|
|
141
|
+
logger.config.directory; // VLoggoDirectory
|
|
142
|
+
logger.config.filecount; // VLoggoFilecount
|
|
143
|
+
logger.config.notify; // boolean
|
|
144
|
+
logger.config.smtp; // VLoggoSMTPConfig | undefined
|
|
145
|
+
logger.config.throttle; // number
|
|
145
146
|
|
|
146
147
|
// Clone configuration
|
|
147
|
-
const
|
|
148
|
+
const newLogger = new VLoggo(
|
|
149
|
+
logger.config.clone({ client: "NewApp" })
|
|
150
|
+
);
|
|
148
151
|
|
|
149
152
|
// Update configuration
|
|
150
|
-
logger.config.update({
|
|
153
|
+
logger.config.update({
|
|
154
|
+
debug: true,
|
|
155
|
+
throttle: 60000
|
|
156
|
+
});
|
|
151
157
|
```
|
|
152
158
|
|
|
153
159
|
## Log Format
|
|
@@ -155,7 +161,7 @@ logger.config.update({ debug: true, throttle: 60000 });
|
|
|
155
161
|
### Text Format
|
|
156
162
|
|
|
157
163
|
```
|
|
158
|
-
[MyApp] [
|
|
164
|
+
[MyApp] [04/11/2025 14:30:45] [INFO] [APP_START] [server.ts:15]: Application started
|
|
159
165
|
```
|
|
160
166
|
|
|
161
167
|
### JSON Format (JSONL)
|
|
@@ -163,7 +169,7 @@ logger.config.update({ debug: true, throttle: 60000 });
|
|
|
163
169
|
```json
|
|
164
170
|
{
|
|
165
171
|
"client": "MyApp",
|
|
166
|
-
"timestamp": "2025-11-
|
|
172
|
+
"timestamp": "2025-11-04T14:30:45.123Z",
|
|
167
173
|
"level": "INFO",
|
|
168
174
|
"code": "APP_START",
|
|
169
175
|
"caller": "server.ts:15",
|
|
@@ -184,6 +190,35 @@ logger.config.update({ debug: true, throttle: 60000 });
|
|
|
184
190
|
- Throttled to prevent spam (configurable via `throttle`)
|
|
185
191
|
- Includes timestamp, code, caller location, and message
|
|
186
192
|
- HTML formatted emails
|
|
193
|
+
- Requires SMTP configuration via options or environment variables
|
|
194
|
+
|
|
195
|
+
## TypeScript Types
|
|
196
|
+
|
|
197
|
+
The library exports the following types:
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
import {
|
|
201
|
+
VLoggo,
|
|
202
|
+
VLoggoConfig,
|
|
203
|
+
VLoggoSMTPConfig,
|
|
204
|
+
VLoggoDirectory,
|
|
205
|
+
VLoggoFilecount,
|
|
206
|
+
LogLevel,
|
|
207
|
+
LogEntry
|
|
208
|
+
} from "vloggo";
|
|
209
|
+
|
|
210
|
+
// LogLevel type
|
|
211
|
+
type LogLevel = "INFO" | "WARN" | "ERROR" | "FATAL" | "DEBUG";
|
|
212
|
+
|
|
213
|
+
// LogEntry interface
|
|
214
|
+
interface LogEntry {
|
|
215
|
+
level: LogLevel;
|
|
216
|
+
timestamp: string;
|
|
217
|
+
code: string;
|
|
218
|
+
caller: string;
|
|
219
|
+
message: string;
|
|
220
|
+
}
|
|
221
|
+
```
|
|
187
222
|
|
|
188
223
|
## Examples
|
|
189
224
|
|
|
@@ -191,7 +226,7 @@ logger.config.update({ debug: true, throttle: 60000 });
|
|
|
191
226
|
|
|
192
227
|
```typescript
|
|
193
228
|
import express from "express";
|
|
194
|
-
import { VLoggo } from "
|
|
229
|
+
import { VLoggo } from "vloggo";
|
|
195
230
|
|
|
196
231
|
const app = express();
|
|
197
232
|
const logger = new VLoggo({ client: "API" });
|
|
@@ -238,21 +273,6 @@ cron.schedule("0 0 * * *", () => {
|
|
|
238
273
|
});
|
|
239
274
|
```
|
|
240
275
|
|
|
241
|
-
## TypeScript Support
|
|
242
|
-
|
|
243
|
-
Full TypeScript definitions are included:
|
|
244
|
-
|
|
245
|
-
```typescript
|
|
246
|
-
import { VLoggo, VLoggoConfig, LogLevel, LogEntry } from "vloggo";
|
|
247
|
-
|
|
248
|
-
const config: Partial<VLoggoConfig> = {
|
|
249
|
-
client: "TypeScriptApp",
|
|
250
|
-
debug: true,
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
const logger = new VLoggo(config);
|
|
254
|
-
```
|
|
255
|
-
|
|
256
276
|
## Performance Considerations
|
|
257
277
|
|
|
258
278
|
- File writes are synchronous for data integrity
|
|
@@ -268,7 +288,6 @@ MIT
|
|
|
268
288
|
|
|
269
289
|
For issues and feature requests, visit: https://github.com/vinialx/vloggo/issues
|
|
270
290
|
|
|
271
|
-
|
|
272
291
|
## Author
|
|
273
292
|
|
|
274
|
-
Email: vini.aloise.silva@gmail.com
|
|
293
|
+
Email: vini.aloise.silva@gmail.com
|
package/package.json
CHANGED