metalog 3.1.17 → 3.1.18

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.
Files changed (2) hide show
  1. package/metalog.js +6 -3
  2. package/package.json +1 -1
package/metalog.js CHANGED
@@ -191,12 +191,13 @@ class Logger extends events.EventEmitter {
191
191
  const { toFile = LOG_TYPES, toStdout = LOG_TYPES, crash } = options;
192
192
  this.active = false;
193
193
  this.path = options.path;
194
+ this.path = path.resolve(options.path);
194
195
  this.workerId = `W${workerId}`;
195
196
  this.createStream = createStream;
196
197
  this.writeInterval = writeInterval || DEFAULT_WRITE_INTERVAL;
197
198
  this.writeBuffer = writeBuffer || DEFAULT_BUFFER_SIZE;
198
199
  this.keepDays = keepDays || DEFAULT_KEEP_DAYS;
199
- this.home = home;
200
+ this.home = home ? path.resolve(home) : undefined;
200
201
  this.json = Boolean(json);
201
202
  this.stream = null;
202
203
  this.reopenTimer = null;
@@ -305,9 +306,11 @@ class Logger extends events.EventEmitter {
305
306
  if (metautil.fileExt(fileName) !== 'log') continue;
306
307
  const fileAge = now - nameToDays(fileName);
307
308
  if (fileAge < this.keepDays) continue;
308
- finish.push(fsp.unlink(path.join(this.path, fileName)));
309
+ const filePath = path.join(this.path, fileName);
310
+ const promise = fsp.unlink(filePath).catch(() => {});
311
+ finish.push(promise);
309
312
  }
310
- await Promise.all(finish);
313
+ await Promise.allSettled(finish);
311
314
  } catch (err) {
312
315
  process.stdout.write(`${err.stack}\n`);
313
316
  this.emit('error', err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metalog",
3
- "version": "3.1.17",
3
+ "version": "3.1.18",
4
4
  "author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>",
5
5
  "description": "Logger for Metarhia",
6
6
  "license": "MIT",