metalog 3.1.4 → 3.1.7

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/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  ## [Unreleased][unreleased]
4
4
 
5
+ ## [3.1.7][] - 2022-03-17
6
+
7
+ - Fix unlink empty files
8
+ - Improve error handling
9
+ - Update dependencies and package maintenance
10
+
11
+ ## [3.1.6][] - 2021-12-08
12
+
13
+ - Fix typings
14
+ - Remove useless code from tests
15
+ - Fix unlink file bug
16
+
17
+ ## [3.1.5][] - 2021-10-11
18
+
19
+ - Update dependencies and npm audit fix
20
+
5
21
  ## [3.1.4][] - 2021-09-10
6
22
 
7
23
  - Update dependencies
@@ -48,7 +64,10 @@
48
64
 
49
65
  First generation of Metarhia Logger
50
66
 
51
- [unreleased]: https://github.com/metarhia/metalog/compare/v3.1.4...HEAD
67
+ [unreleased]: https://github.com/metarhia/metalog/compare/v3.1.7...HEAD
68
+ [3.1.7]: https://github.com/metarhia/metalog/compare/v3.1.6...v3.1.7
69
+ [3.1.6]: https://github.com/metarhia/metalog/compare/v3.1.5...v3.1.6
70
+ [3.1.5]: https://github.com/metarhia/metalog/compare/v3.1.4...v3.1.5
52
71
  [3.1.4]: https://github.com/metarhia/metalog/compare/v3.1.3...v3.1.4
53
72
  [3.1.3]: https://github.com/metarhia/metalog/compare/v3.1.2...v3.1.3
54
73
  [3.1.2]: https://github.com/metarhia/metalog/compare/v3.1.1...v3.1.2
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017-2021 Metarhia
3
+ Copyright (c) 2017-2022 Metarhia
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Meta Logger for Metarhia
2
2
 
3
3
  [![ci status](https://github.com/metarhia/metalog/workflows/Testing%20CI/badge.svg)](https://github.com/metarhia/metalog/actions?query=workflow%3A%22Testing+CI%22+branch%3Amaster)
4
- [![codacy](https://api.codacy.com/project/badge/Grade/7aaad5ed17c74634855fa6202a03a56e)](https://www.codacy.com/app/metarhia/metalog)
5
4
  [![snyk](https://snyk.io/test/github/metarhia/impress/badge.svg)](https://snyk.io/test/github/metarhia/impress)
6
5
  [![npm version](https://img.shields.io/npm/v/metalog.svg?style=flat)](https://www.npmjs.com/package/metalog)
7
6
  [![npm downloads/month](https://img.shields.io/npm/dm/metalog.svg)](https://www.npmjs.com/package/metalog)
@@ -31,6 +30,6 @@ await logger.close();
31
30
 
32
31
  ## License & Contributors
33
32
 
34
- Copyright (c) 2017-2021 [Metarhia contributors](https://github.com/metarhia/metalog/graphs/contributors).
33
+ Copyright (c) 2017-2022 [Metarhia contributors](https://github.com/metarhia/metalog/graphs/contributors).
35
34
  Metalog is [MIT licensed](./LICENSE).\
36
35
  Metalog is a part of [Metarhia](https://github.com/metarhia) technology stack.
package/metalog.d.ts CHANGED
@@ -3,13 +3,13 @@ import EventEmitter = require('events');
3
3
  interface LoggerOptions {
4
4
  path: string;
5
5
  home: string;
6
- workerId: number;
7
- createStream: () => NodeJS.WritableStream;
6
+ workerId?: number;
7
+ createStream?: () => NodeJS.WritableStream;
8
8
  writeInterval: number;
9
9
  writeBuffer: number;
10
10
  keepDays: number;
11
- toFile: Array<string>;
12
- toStdout: Array<string>;
11
+ toFile?: Array<string>;
12
+ toStdout?: Array<string>;
13
13
  }
14
14
 
15
15
  export class Logger extends EventEmitter {
@@ -27,9 +27,9 @@ export class Logger extends EventEmitter {
27
27
  lock: boolean;
28
28
  buffer: Array<Buffer>;
29
29
  file: string;
30
- toFile: Array<string>;
30
+ toFile: Record<string, boolean>;
31
31
  fsEnabled: boolean;
32
- toStdout: Array<string>;
32
+ toStdout: Record<string, boolean>;
33
33
  console: Console;
34
34
  constructor(args: LoggerOptions);
35
35
  createLogDir(): Promise<void>;
package/metalog.js CHANGED
@@ -224,7 +224,8 @@ class Logger extends events.EventEmitter {
224
224
  resolve();
225
225
  return;
226
226
  }
227
- this.emit(new Error(`Can not create directory: ${this.path}\n`));
227
+ const error = new Error(`Can not create directory: ${this.path}\n`);
228
+ this.emit('error', error);
228
229
  reject();
229
230
  });
230
231
  });
@@ -246,7 +247,10 @@ class Logger extends events.EventEmitter {
246
247
  this.once('close', () => {
247
248
  this.open();
248
249
  });
249
- this.close();
250
+ this.close().catch((err) => {
251
+ process.stdout.write(`${err.stack}\n`);
252
+ this.emit('error', err);
253
+ });
250
254
  }, nextReopen);
251
255
  if (this.keepDays) await this.rotate();
252
256
  const options = { flags: 'a', bufferSize: this.writeBuffer };
@@ -278,8 +282,6 @@ class Logger extends events.EventEmitter {
278
282
  return new Promise((resolve, reject) => {
279
283
  this.flush((err) => {
280
284
  if (err) {
281
- process.stdout.write(`${err.stack}\n`);
282
- this.emit('error', err);
283
285
  reject(err);
284
286
  return;
285
287
  }
@@ -291,11 +293,11 @@ class Logger extends events.EventEmitter {
291
293
  this.reopenTimer = null;
292
294
  const fileName = this.file;
293
295
  this.emit('close');
294
- resolve();
295
296
  fs.stat(fileName, (err, stats) => {
296
297
  if (!err && stats.size === 0) {
297
- fsp.unlink(this.file);
298
+ fsp.unlink(fileName).catch(() => {});
298
299
  }
300
+ resolve();
299
301
  });
300
302
  });
301
303
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metalog",
3
- "version": "3.1.4",
3
+ "version": "3.1.7",
4
4
  "author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>",
5
5
  "description": "Logger for Metarhia",
6
6
  "license": "MIT",
@@ -49,21 +49,21 @@
49
49
  "fmt": "prettier --write \"**/*.js\" \"**/*.json\" \"**/*.md\" \"**/.*rc\" \"**/*.ts\""
50
50
  },
51
51
  "engines": {
52
- "node": "^12.10 || 14 || 16"
52
+ "node": "^12.10 || 14 || 16 || 17"
53
53
  },
54
54
  "dependencies": {
55
55
  "concolor": "^1.0.2",
56
- "metautil": "^3.5.11"
56
+ "metautil": "^3.5.19"
57
57
  },
58
58
  "devDependencies": {
59
- "@types/node": "^16.9.1",
60
- "eslint": "^7.32.0",
59
+ "@types/node": "^17.0.21",
60
+ "eslint": "^8.11.0",
61
61
  "eslint-config-metarhia": "^7.0.0",
62
- "eslint-config-prettier": "^8.3.0",
63
- "eslint-plugin-import": "^2.24.2",
62
+ "eslint-config-prettier": "^8.5.0",
63
+ "eslint-plugin-import": "^2.25.4",
64
64
  "eslint-plugin-prettier": "^4.0.0",
65
- "metatests": "^0.7.2",
66
- "prettier": "^2.4.0",
67
- "typescript": "^4.4.2"
65
+ "metatests": "^0.8.2",
66
+ "prettier": "^2.6.0",
67
+ "typescript": "^4.6.2"
68
68
  }
69
69
  }