vloggo 1.0.2 → 1.0.3

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.
@@ -8,16 +8,6 @@ import FormatService from "../internal/formatService";
8
8
  * @class Config
9
9
  */
10
10
  class Config {
11
- _client;
12
- _json;
13
- _debug;
14
- _console;
15
- _filecount;
16
- _directory;
17
- _notify;
18
- _throttle;
19
- _smtp = undefined;
20
- format = new FormatService();
21
11
  /**
22
12
  * Creates a new Config instance.
23
13
  * Loads configuration from options or environment variables.
@@ -37,6 +27,8 @@ class Config {
37
27
  * ```
38
28
  */
39
29
  constructor(options) {
30
+ this._smtp = undefined;
31
+ this.format = new FormatService();
40
32
  this._client = options?.client || process.env.CLIENT_NAME || "VLoggo";
41
33
  this._json = options?.json ?? false;
42
34
  this._debug = options?.debug ?? false;
@@ -8,11 +8,6 @@ import FormatService from "./formatService";
8
8
  * @class EmailService
9
9
  */
10
10
  class EmailService {
11
- config;
12
- format = new FormatService();
13
- transporter = null;
14
- _ready = false;
15
- lastEmailSent = 0;
16
11
  /**
17
12
  * Creates an instance of EmailService and initializes the SMTP transport.
18
13
  *
@@ -20,6 +15,10 @@ class EmailService {
20
15
  */
21
16
  constructor(config) {
22
17
  this.config = config;
18
+ this.format = new FormatService();
19
+ this.transporter = null;
20
+ this._ready = false;
21
+ this.lastEmailSent = 0;
23
22
  this.initialize();
24
23
  }
25
24
  /**
@@ -10,12 +10,6 @@ import FormatService from "./formatService";
10
10
  * @class FileService
11
11
  */
12
12
  class FileService {
13
- config;
14
- _txtFilename = "";
15
- _jsonFilename = "";
16
- _currentDay = 0;
17
- _initialized = false;
18
- format;
19
13
  /**
20
14
  * Creates an instance of FileService.
21
15
  *
@@ -23,6 +17,10 @@ class FileService {
23
17
  */
24
18
  constructor(config) {
25
19
  this.config = config;
20
+ this._txtFilename = "";
21
+ this._jsonFilename = "";
22
+ this._currentDay = 0;
23
+ this._initialized = false;
26
24
  this.format = new FormatService(this.config.client);
27
25
  }
28
26
  /**
@@ -5,7 +5,6 @@
5
5
  * @class FormatService
6
6
  */
7
7
  class FormatService {
8
- client;
9
8
  constructor(client) {
10
9
  this.client = client;
11
10
  if (!client) {
@@ -91,7 +90,7 @@ class FormatService {
91
90
  separator() {
92
91
  const separator = "\n" + "_".repeat(50) + "\n\n";
93
92
  const timestamp = this.date();
94
- return `${separator}[${this.client}] [${timestamp}] [INIT] : VLoggo initialized successfully \n`;
93
+ return `${separator}[${this.client}] [${timestamp}] [INIT] : vloggo initialized \n`;
95
94
  }
96
95
  /**
97
96
  * Creates a JSON separator for log file initialization.
@@ -125,7 +125,7 @@ export declare class VLoggo {
125
125
  /**
126
126
  * Logs a fatal error message and sends an email notification.
127
127
  * Used for severe error events that might cause the application to abort.
128
- * Automatically triggers email notification if email service is configured and ready.
128
+ * Automatically triggers asynchronous email notification if email service is configured and ready.
129
129
  *
130
130
  * @param {string} code - Log code identifier
131
131
  * @param {string} text - Log message
@@ -136,6 +136,6 @@ export declare class VLoggo {
136
136
  * logger.fatal('DB_CONN_FAIL', 'Unable to connect to database after 5 retries');
137
137
  * ```
138
138
  */
139
- fatal(code: string, text: string): void;
139
+ fatal(code: string, text: string): Promise<void>;
140
140
  }
141
141
  //# sourceMappingURL=logService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logService.d.ts","sourceRoot":"","sources":["../../src/services/logService.ts"],"names":[],"mappings":"AAKA,OAAO,MAAyB,MAAM,kBAAkB,CAAC;AAEzD;;;;;;GAMG;AAEH,qBAAa,MAAM;IACjB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,aAAa,CAAgB;IAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;gBAES,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC;IAarC;;;;;OAKG;IAEH,IAAI,MAAM,IAAI,QAAQ,CAAC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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;IAEG,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAoBvD"}
@@ -10,10 +10,6 @@ import Config, { defaultConfig } from "../config/config";
10
10
  * @class VLoggo
11
11
  */
12
12
  export class VLoggo {
13
- _config;
14
- fileService;
15
- emailService;
16
- formatService;
17
13
  /**
18
14
  * Creates a new VLoggo instance with the specified configuration.
19
15
  * Initializes file service, format service, and email service.
@@ -185,7 +181,7 @@ export class VLoggo {
185
181
  /**
186
182
  * Logs a fatal error message and sends an email notification.
187
183
  * Used for severe error events that might cause the application to abort.
188
- * Automatically triggers email notification if email service is configured and ready.
184
+ * Automatically triggers asynchronous email notification if email service is configured and ready.
189
185
  *
190
186
  * @param {string} code - Log code identifier
191
187
  * @param {string} text - Log message
@@ -196,7 +192,7 @@ export class VLoggo {
196
192
  * logger.fatal('DB_CONN_FAIL', 'Unable to connect to database after 5 retries');
197
193
  * ```
198
194
  */
199
- fatal(code, text) {
195
+ async fatal(code, text) {
200
196
  this.log("FATAL", code, text);
201
197
  if (!this.emailService.ready) {
202
198
  if (this._config.debug) {
@@ -204,8 +200,11 @@ export class VLoggo {
204
200
  }
205
201
  return;
206
202
  }
207
- this.emailService
208
- .sendErrorNotification(this._config.client, code, text)
209
- .catch((error) => console.error(`[VLoggo] > [${this._config.client}] [${this.formatService.date()}] [ERROR] : failed to send error message > ${error.message}`));
203
+ try {
204
+ await this.emailService.sendErrorNotification(this._config.client, code, text);
205
+ }
206
+ catch (error) {
207
+ console.error(`[VLoggo] > [${this._config.client}] [${this.formatService.date()}] [ERROR] : failed to send error message > ${error.message}`);
208
+ }
210
209
  }
211
210
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vloggo",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "private": false,
5
5
  "description": "Logging library for Node.js and Bun with file rotation, SMTP notifications, and JSON output support.",
6
6
  "homepage": "https://github.com/vinialx/vloggo#readme",
@@ -21,11 +21,11 @@
21
21
  "main": "build/index.js",
22
22
  "types": "build/index.d.ts",
23
23
  "dependencies": {
24
- "nodemailer": "^7.0.10"
24
+ "nodemailer": "^7.0.12"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/bun": "latest",
28
- "@types/nodemailer": "^7.0.2"
28
+ "@types/nodemailer": "^7.0.5"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "typescript": "^5.9.3"