vloggo 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 +293 -274
- package/build/config/config.d.ts +2 -1
- package/build/config/config.d.ts.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -0
- package/build/interfaces/interfaces.d.ts +1 -0
- package/build/interfaces/interfaces.d.ts.map +1 -0
- package/build/internal/emailService.d.ts +1 -0
- package/build/internal/emailService.d.ts.map +1 -0
- package/build/internal/emailService.js +9 -8
- package/build/internal/fileService.d.ts +1 -0
- package/build/internal/fileService.d.ts.map +1 -0
- package/build/internal/fileService.js +2 -0
- package/build/internal/formatService.d.ts +2 -1
- package/build/internal/formatService.d.ts.map +1 -0
- package/build/services/logService.d.ts +1 -0
- package/build/services/logService.d.ts.map +1 -0
- package/package.json +52 -52
package/README.md
CHANGED
|
@@ -1,274 +1,293 @@
|
|
|
1
|
-
# VLoggo
|
|
2
|
-
|
|
3
|
-
Logging library for Node.js and Bun with file rotation, SMTP notifications, and JSON output support.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **Multiple log levels**: INFO, WARN, DEBUG, ERROR, FATAL
|
|
8
|
-
- **Automatic file rotation**: Daily rotation with configurable retention
|
|
9
|
-
- **SMTP notifications**: Email alerts for fatal errors with throttling
|
|
10
|
-
- **JSON output**: Optional structured logging in JSONL format
|
|
11
|
-
- **Caller tracking**: Automatic source file and line number tracking
|
|
12
|
-
- **TypeScript support**: Full type definitions included
|
|
13
|
-
- **Zero configuration**: Works out of the box with sensible defaults
|
|
14
|
-
|
|
15
|
-
## Installation
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npm install
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
bun add
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Quick Start
|
|
26
|
-
|
|
27
|
-
```typescript
|
|
28
|
-
import { VLoggo } from "
|
|
29
|
-
|
|
30
|
-
const logger = new VLoggo({ client: "MyApp" });
|
|
31
|
-
|
|
32
|
-
logger.info("APP_START", "Application started");
|
|
33
|
-
logger.warn("HIGH_MEMORY", "Memory usage above 80%");
|
|
34
|
-
logger.error("API_FAIL", "External API request failed");
|
|
35
|
-
logger.fatal("DB_DOWN", "Database connection lost");
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Configuration
|
|
39
|
-
|
|
40
|
-
### Basic Configuration
|
|
41
|
-
|
|
42
|
-
```typescript
|
|
43
|
-
const logger = new VLoggo({
|
|
44
|
-
client: "MyApp",
|
|
45
|
-
console: true,
|
|
46
|
-
debug: false,
|
|
47
|
-
json: false,
|
|
48
|
-
});
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### File Configuration
|
|
52
|
-
|
|
53
|
-
```typescript
|
|
54
|
-
const logger = new VLoggo({
|
|
55
|
-
client: "MyApp",
|
|
56
|
-
directory: {
|
|
57
|
-
txt: "/var/log/myapp",
|
|
58
|
-
json: "/var/log/myapp/json", // JSON log directory
|
|
59
|
-
},
|
|
60
|
-
filecount: {
|
|
61
|
-
txt: 31,
|
|
62
|
-
json: 7,
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### SMTP Configuration
|
|
68
|
-
|
|
69
|
-
```typescript
|
|
70
|
-
const logger = new VLoggo({
|
|
71
|
-
client: "MyApp",
|
|
72
|
-
smtp: {
|
|
73
|
-
host: "smtp.gmail.com",
|
|
74
|
-
port: 465,
|
|
75
|
-
secure: true,
|
|
76
|
-
username: "your-email@gmail.com",
|
|
77
|
-
password: "your-password",
|
|
78
|
-
from: "logs@myapp.com",
|
|
79
|
-
to: "admin@myapp.com",
|
|
80
|
-
},
|
|
81
|
-
throttle: 300000,
|
|
82
|
-
});
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### Environment Variables
|
|
86
|
-
|
|
87
|
-
SMTP can be configured via environment variables:
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
SMTP_HOST=smtp.gmail.com
|
|
91
|
-
SMTP_PORT=465
|
|
92
|
-
SMTP_USERNAME=your-email@gmail.com
|
|
93
|
-
SMTP_PASSWORD=your-password
|
|
94
|
-
SMTP_FROM=logs@myapp.com
|
|
95
|
-
SMTP_TO=admin@myapp.com
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
## API Reference
|
|
99
|
-
|
|
100
|
-
### Constructor
|
|
101
|
-
|
|
102
|
-
```typescript
|
|
103
|
-
new VLoggo(options?: Partial<VLoggoConfig>)
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
**Options:**
|
|
107
|
-
|
|
108
|
-
- `client`: Application name (default: 'VLoggo')
|
|
109
|
-
- `console`: Enable console output (default: true)
|
|
110
|
-
- `debug`: Enable debug mode (default: false)
|
|
111
|
-
- `json`: Enable JSON output (default: false)
|
|
112
|
-
- `directory`: Log directories (default:
|
|
113
|
-
- `filecount`: Retention days (default: { txt: 31, json: 31 })
|
|
114
|
-
- `smtp`: SMTP configuration (optional)
|
|
115
|
-
- `
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
logger.
|
|
122
|
-
logger.
|
|
123
|
-
logger.
|
|
124
|
-
logger.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
- `
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
logger.config.
|
|
138
|
-
logger.config.
|
|
139
|
-
logger.config.
|
|
140
|
-
logger.config.
|
|
141
|
-
logger.config.
|
|
142
|
-
logger.config.
|
|
143
|
-
logger.config.
|
|
144
|
-
logger.config.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
###
|
|
162
|
-
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
-
|
|
184
|
-
-
|
|
185
|
-
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
1
|
+
# VLoggo
|
|
2
|
+
|
|
3
|
+
Logging library for Node.js and Bun with file rotation, SMTP notifications, and JSON output support.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Multiple log levels**: INFO, WARN, DEBUG, ERROR, FATAL
|
|
8
|
+
- **Automatic file rotation**: Daily rotation with configurable retention
|
|
9
|
+
- **SMTP notifications**: Email alerts for fatal errors with throttling
|
|
10
|
+
- **JSON output**: Optional structured logging in JSONL format
|
|
11
|
+
- **Caller tracking**: Automatic source file and line number tracking
|
|
12
|
+
- **TypeScript support**: Full type definitions included
|
|
13
|
+
- **Zero configuration**: Works out of the box with sensible defaults
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install vloggo
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
bun add vloggo
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { VLoggo } from "vloggo";
|
|
29
|
+
|
|
30
|
+
const logger = new VLoggo({ client: "MyApp" });
|
|
31
|
+
|
|
32
|
+
logger.info("APP_START", "Application started");
|
|
33
|
+
logger.warn("HIGH_MEMORY", "Memory usage above 80%");
|
|
34
|
+
logger.error("API_FAIL", "External API request failed");
|
|
35
|
+
logger.fatal("DB_DOWN", "Database connection lost");
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Configuration
|
|
39
|
+
|
|
40
|
+
### Basic Configuration
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
const logger = new VLoggo({
|
|
44
|
+
client: "MyApp", // Application name
|
|
45
|
+
console: true, // Enable console output
|
|
46
|
+
debug: false, // Enable debug logs
|
|
47
|
+
json: false, // Enable JSON output
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### File Configuration
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
const logger = new VLoggo({
|
|
55
|
+
client: "MyApp",
|
|
56
|
+
directory: {
|
|
57
|
+
txt: "/var/log/myapp", // Text log directory
|
|
58
|
+
json: "/var/log/myapp/json", // JSON log directory
|
|
59
|
+
},
|
|
60
|
+
filecount: {
|
|
61
|
+
txt: 31, // Keep 31 days of text logs
|
|
62
|
+
json: 7, // Keep 7 days of JSON logs
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### SMTP Configuration
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
const logger = new VLoggo({
|
|
71
|
+
client: "MyApp",
|
|
72
|
+
smtp: {
|
|
73
|
+
host: "smtp.gmail.com",
|
|
74
|
+
port: 465,
|
|
75
|
+
secure: true,
|
|
76
|
+
username: "your-email@gmail.com",
|
|
77
|
+
password: "your-password",
|
|
78
|
+
from: "logs@myapp.com",
|
|
79
|
+
to: "admin@myapp.com", // Can be string or array
|
|
80
|
+
},
|
|
81
|
+
throttle: 300000, // Min 5 minutes between emails
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Environment Variables
|
|
86
|
+
|
|
87
|
+
SMTP can be configured via environment variables:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
SMTP_HOST=smtp.gmail.com
|
|
91
|
+
SMTP_PORT=465
|
|
92
|
+
SMTP_USERNAME=your-email@gmail.com
|
|
93
|
+
SMTP_PASSWORD=your-password
|
|
94
|
+
SMTP_FROM=logs@myapp.com
|
|
95
|
+
SMTP_TO=admin@myapp.com
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## API Reference
|
|
99
|
+
|
|
100
|
+
### Constructor
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
new VLoggo(options?: Partial<VLoggoConfig>)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Options:**
|
|
107
|
+
|
|
108
|
+
- `client`: Application name (default: 'VLoggo')
|
|
109
|
+
- `console`: Enable console output (default: true)
|
|
110
|
+
- `debug`: Enable debug mode (default: false)
|
|
111
|
+
- `json`: Enable JSON output (default: false)
|
|
112
|
+
- `directory`: Log directories (default: `~/[client]/logs` for txt, `~/[client]/json` for json)
|
|
113
|
+
- `filecount`: Retention days (default: `{ txt: 31, json: 31 }`)
|
|
114
|
+
- `smtp`: SMTP configuration (optional)
|
|
115
|
+
- `notify`: Enable notifications (default: false, automatically set to true if smtp is configured)
|
|
116
|
+
- `throttle`: Email throttle in ms (default: 30000)
|
|
117
|
+
|
|
118
|
+
### Logging Methods
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
logger.info(code: string, message: string): void
|
|
122
|
+
logger.warn(code: string, message: string): void
|
|
123
|
+
logger.debug(code: string, message: string): void
|
|
124
|
+
logger.error(code: string, message: string): void
|
|
125
|
+
logger.fatal(code: string, message: string): void
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Parameters:**
|
|
129
|
+
|
|
130
|
+
- `code`: Short identifier for the log entry
|
|
131
|
+
- `message`: Detailed log message
|
|
132
|
+
|
|
133
|
+
### Configuration Access
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
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
|
|
146
|
+
|
|
147
|
+
// Clone configuration
|
|
148
|
+
const newLogger = new VLoggo(
|
|
149
|
+
logger.config.clone({ client: "NewApp" })
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
// Update configuration
|
|
153
|
+
logger.config.update({
|
|
154
|
+
debug: true,
|
|
155
|
+
throttle: 60000
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Log Format
|
|
160
|
+
|
|
161
|
+
### Text Format
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
[MyApp] [04/11/2025 14:30:45] [INFO] [APP_START] [server.ts:15]: Application started
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### JSON Format (JSONL)
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"client": "MyApp",
|
|
172
|
+
"timestamp": "2025-11-04T14:30:45.123Z",
|
|
173
|
+
"level": "INFO",
|
|
174
|
+
"code": "APP_START",
|
|
175
|
+
"caller": "server.ts:15",
|
|
176
|
+
"message": "Application started"
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## File Rotation
|
|
181
|
+
|
|
182
|
+
- Logs rotate daily at midnight
|
|
183
|
+
- Old logs are automatically deleted based on `filecount` setting
|
|
184
|
+
- Separate rotation for text and JSON logs
|
|
185
|
+
- Rotation happens asynchronously without blocking logging
|
|
186
|
+
|
|
187
|
+
## Email Notifications
|
|
188
|
+
|
|
189
|
+
- Only sent for `fatal()` logs
|
|
190
|
+
- Throttled to prevent spam (configurable via `throttle`)
|
|
191
|
+
- Includes timestamp, code, caller location, and message
|
|
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
|
+
```
|
|
222
|
+
|
|
223
|
+
## Examples
|
|
224
|
+
|
|
225
|
+
### Express.js Integration
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
import express from "express";
|
|
229
|
+
import { VLoggo } from "vloggo";
|
|
230
|
+
|
|
231
|
+
const app = express();
|
|
232
|
+
const logger = new VLoggo({ client: "API" });
|
|
233
|
+
|
|
234
|
+
app.use((req, res, next) => {
|
|
235
|
+
logger.info("REQUEST", `${req.method} ${req.path}`);
|
|
236
|
+
next();
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
app.use((err, req, res, next) => {
|
|
240
|
+
logger.error("ERROR", err.message);
|
|
241
|
+
res.status(500).json({ error: "Internal Server Error" });
|
|
242
|
+
});
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Database Connection Monitoring
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
async function connectDatabase() {
|
|
249
|
+
try {
|
|
250
|
+
await db.connect();
|
|
251
|
+
logger.info("DB_CONNECT", "Database connected successfully");
|
|
252
|
+
} catch (error) {
|
|
253
|
+
logger.fatal("DB_CONNECT_FAIL", error.message);
|
|
254
|
+
process.exit(1);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Scheduled Task Logging
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
import cron from "node-cron";
|
|
263
|
+
|
|
264
|
+
cron.schedule("0 0 * * *", () => {
|
|
265
|
+
logger.info("CRON_START", "Daily cleanup task started");
|
|
266
|
+
|
|
267
|
+
try {
|
|
268
|
+
performCleanup();
|
|
269
|
+
logger.info("CRON_SUCCESS", "Daily cleanup completed");
|
|
270
|
+
} catch (error) {
|
|
271
|
+
logger.error("CRON_FAIL", error.message);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## Performance Considerations
|
|
277
|
+
|
|
278
|
+
- File writes are synchronous for data integrity
|
|
279
|
+
- Rotation is asynchronous to avoid blocking
|
|
280
|
+
- Email sending is asynchronous with error handling
|
|
281
|
+
- Minimal overhead for disabled features
|
|
282
|
+
|
|
283
|
+
## License
|
|
284
|
+
|
|
285
|
+
MIT
|
|
286
|
+
|
|
287
|
+
## Support
|
|
288
|
+
|
|
289
|
+
For issues and feature requests, visit: https://github.com/vinialx/vloggo/issues
|
|
290
|
+
|
|
291
|
+
## Author
|
|
292
|
+
|
|
293
|
+
Email: vini.aloise.silva@gmail.com
|
package/build/config/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VLoggoConfig, VLoggoSMTPConfig, VLoggoDirectory, VLoggoFilecount } from "../interfaces/interfaces";
|
|
1
|
+
import type { VLoggoConfig, VLoggoSMTPConfig, VLoggoDirectory, VLoggoFilecount } from "../interfaces/interfaces";
|
|
2
2
|
/**
|
|
3
3
|
* Configuration manager for VLoggo.
|
|
4
4
|
* Manages all settings including SMTP, file rotation and debugging.
|
|
@@ -157,3 +157,4 @@ declare class Config {
|
|
|
157
157
|
}
|
|
158
158
|
export declare const defaultConfig: VLoggoConfig;
|
|
159
159
|
export default Config;
|
|
160
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@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e,CAE/B;IAED;;;;;OAKG;IAEH,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED;;;;;OAKG;IAEH,IAAI,IAAI,IAAI,gBAAgB,GAAG,SAAS,CAEvC;IAED;;;;;OAKG;IAEH,IAAI,QAAQ,IAAI,MAAM,CAErB;CACF;AAED,eAAO,MAAM,aAAa,EAAE,YAa3B,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/build/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/interfaces/interfaces.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,SAAS,CAAC,EAAE,eAAe,CAAC;IAE5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAErE,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,QAAQ,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emailService.d.ts","sourceRoot":"","sources":["../../src/internal/emailService.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAGtC;;;;;GAKG;AAEH,cAAM,YAAY;IAaJ,OAAO,CAAC,MAAM;IAZ1B,OAAO,CAAC,MAAM,CAAsC;IACpD,OAAO,CAAC,WAAW,CAAuC;IAE1D,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,aAAa,CAAa;IAElC;;;;OAIG;gBAEiB,MAAM,EAAE,MAAM;IAIlC;;;;;;;OAOG;IAEH,OAAO,CAAC,UAAU;IAwClB;;;;;;;;;;;;;;;;;;OAkBG;IAEG,qBAAqB,CACzB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC;IAyDhB;;;;;OAKG;IAEH,IAAI,KAAK,IAAI,OAAO,CAEnB;CACF;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import nodemailer from "nodemailer";
|
|
2
|
+
import Config from "../config/config";
|
|
2
3
|
import FormatService from "./formatService";
|
|
3
4
|
/**
|
|
4
5
|
* Service responsible for sending email notifications via SMTP.
|
|
@@ -99,14 +100,14 @@ class EmailService {
|
|
|
99
100
|
from: `"${client}" <${this.config.smtp.from}>`,
|
|
100
101
|
to: recipients,
|
|
101
102
|
subject: `[${client}] Error Alert - ${code}`,
|
|
102
|
-
html: `
|
|
103
|
-
<h2>Error Report</h2>
|
|
104
|
-
<p><strong>Client:</strong> ${client}</p>
|
|
105
|
-
<p><strong>Error Code:</strong> ${code}</p>
|
|
106
|
-
<p><strong>Caller:</strong> ${caller}</p>
|
|
107
|
-
<p><strong>Error Message:</strong> ${error}</p>
|
|
108
|
-
<p><strong>Timestamp:</strong> ${new Date().toLocaleString("pt-BR")}</p>
|
|
109
|
-
<hr>
|
|
103
|
+
html: `
|
|
104
|
+
<h2>Error Report</h2>
|
|
105
|
+
<p><strong>Client:</strong> ${client}</p>
|
|
106
|
+
<p><strong>Error Code:</strong> ${code}</p>
|
|
107
|
+
<p><strong>Caller:</strong> ${caller}</p>
|
|
108
|
+
<p><strong>Error Message:</strong> ${error}</p>
|
|
109
|
+
<p><strong>Timestamp:</strong> ${new Date().toLocaleString("pt-BR")}</p>
|
|
110
|
+
<hr>
|
|
110
111
|
`,
|
|
111
112
|
};
|
|
112
113
|
try {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileService.d.ts","sourceRoot":"","sources":["../../src/internal/fileService.ts"],"names":[],"mappings":"AAIA,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAGtC;;;;;GAKG;AAEH,cAAM,WAAW;IAcH,OAAO,CAAC,MAAM;IAb1B,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,aAAa,CAAc;IACnC,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,YAAY,CAAkB;IAEtC,OAAO,CAAC,MAAM,CAAgB;IAE9B;;;;OAIG;gBAEiB,MAAM,EAAE,MAAM;IAIlC;;;;;;OAMG;IAEH,UAAU,IAAI,IAAI;IAmClB;;;;;;;;;;;OAWG;IAEH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAqBxC;;;;;;OAMG;IAEH,MAAM,IAAI,IAAI;IA0Cd;;;;;;;;OAQG;YAEW,MAAM;IAgFpB;;;;;OAKG;IAEH,IAAI,WAAW,IAAI,OAAO,CAEzB;CACF;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import * as path from "path";
|
|
3
3
|
import * as fsp from "fs/promises";
|
|
4
|
+
import Config from "../config/config";
|
|
4
5
|
import FormatService from "./formatService";
|
|
5
6
|
/**
|
|
6
7
|
* Service responsible for managing log file operations.
|
|
@@ -92,6 +93,7 @@ class FileService {
|
|
|
92
93
|
if (today === this._currentDay) {
|
|
93
94
|
return;
|
|
94
95
|
}
|
|
96
|
+
this._currentDay = today;
|
|
95
97
|
try {
|
|
96
98
|
fs.mkdirSync(this.config.directory.txt, { recursive: true });
|
|
97
99
|
this._txtFilename = path.resolve(this.config.directory.txt, this.format.filename());
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LogEntry } from "../interfaces/interfaces";
|
|
1
|
+
import type { LogEntry } from "../interfaces/interfaces";
|
|
2
2
|
/**
|
|
3
3
|
* Service responsible for formatting log-related strings.
|
|
4
4
|
* Provides utilities for date formatting, filename generation, separators, and caller traceability.
|
|
@@ -62,3 +62,4 @@ declare class FormatService {
|
|
|
62
62
|
caller(skip?: number): string;
|
|
63
63
|
}
|
|
64
64
|
export default FormatService;
|
|
65
|
+
//# sourceMappingURL=formatService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatService.d.ts","sourceRoot":"","sources":["../../src/internal/formatService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD;;;;;GAKG;AAEH,cAAM,aAAa;IACL,OAAO,CAAC,MAAM,CAAC;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IAEH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAItC;;;;;;;;;;;;OAYG;IAEH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAIvC;;;;;;;;;;;;OAYG;IAEH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAIvC;;;;;;;;;;;;;OAaG;IAEH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CAoBxC"}
|
package/package.json
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "vloggo",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"private": false,
|
|
5
|
-
"description": "Logging library for Node.js and Bun with file rotation, SMTP notifications, and JSON output support.",
|
|
6
|
-
"homepage": "https://github.com/vinialx/vloggo#readme",
|
|
7
|
-
"bugs": {
|
|
8
|
-
"url": "https://github.com/vinialx/vloggo/issues"
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/vinialx/vloggo.git"
|
|
13
|
-
},
|
|
14
|
-
"files": [
|
|
15
|
-
"build",
|
|
16
|
-
"README.md"
|
|
17
|
-
],
|
|
18
|
-
"license": "ISC",
|
|
19
|
-
"author": "vinialx",
|
|
20
|
-
"type": "module",
|
|
21
|
-
"main": "build/index.js",
|
|
22
|
-
"types": "build/index.d.ts",
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"nodemailer": "^7.0.10"
|
|
25
|
-
},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@types/bun": "latest",
|
|
28
|
-
"@types/nodemailer": "^7.0.2"
|
|
29
|
-
},
|
|
30
|
-
"peerDependencies": {
|
|
31
|
-
"typescript": "^5.9.3"
|
|
32
|
-
},
|
|
33
|
-
"exports": {
|
|
34
|
-
".": {
|
|
35
|
-
"import": "./build/index.js",
|
|
36
|
-
"types": "./build/index.d.ts"
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
"scripts": {
|
|
40
|
-
"build": "tsc",
|
|
41
|
-
"prepublishOnly": "npm run build",
|
|
42
|
-
"preversion": "npm run build"
|
|
43
|
-
},
|
|
44
|
-
"keywords": [
|
|
45
|
-
"logger",
|
|
46
|
-
"logging",
|
|
47
|
-
"typescript",
|
|
48
|
-
"nodemailer",
|
|
49
|
-
"file-logging",
|
|
50
|
-
"email-notifications"
|
|
51
|
-
]
|
|
52
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "vloggo",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Logging library for Node.js and Bun with file rotation, SMTP notifications, and JSON output support.",
|
|
6
|
+
"homepage": "https://github.com/vinialx/vloggo#readme",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://github.com/vinialx/vloggo/issues"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/vinialx/vloggo.git"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"build",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"author": "vinialx",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "build/index.js",
|
|
22
|
+
"types": "build/index.d.ts",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"nodemailer": "^7.0.10"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/bun": "latest",
|
|
28
|
+
"@types/nodemailer": "^7.0.2"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"typescript": "^5.9.3"
|
|
32
|
+
},
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"import": "./build/index.js",
|
|
36
|
+
"types": "./build/index.d.ts"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc",
|
|
41
|
+
"prepublishOnly": "npm run build",
|
|
42
|
+
"preversion": "npm run build"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"logger",
|
|
46
|
+
"logging",
|
|
47
|
+
"typescript",
|
|
48
|
+
"nodemailer",
|
|
49
|
+
"file-logging",
|
|
50
|
+
"email-notifications"
|
|
51
|
+
]
|
|
52
|
+
}
|