metalog 4.0.0-prerelease → 4.0.1-prerelease

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 +7 -7
  2. package/package.json +1 -1
package/metalog.js CHANGED
@@ -358,8 +358,8 @@ class Logger extends EventEmitter {
358
358
  this.#options = options;
359
359
  const { workerId, createStream, keepDays, home, crash, json } = options;
360
360
  const { toFile = LOG_TAGS, toStdout = LOG_TAGS } = options;
361
- this.path = options.path;
362
- this.home = home;
361
+ this.path = path.resolve(options.path);
362
+ this.home = home ? path.resolve(home) : undefined;
363
363
  this.console = new Console(this);
364
364
  if (workerId) this.#worker = `W${workerId}`;
365
365
  if (toFile) this.#toFile = logTags(toFile);
@@ -369,7 +369,8 @@ class Logger extends EventEmitter {
369
369
  if (crash === 'flush') this.#setupCrashHandling();
370
370
  this.#fsEnabled = toFile.length !== 0;
371
371
  this.#buffer = null;
372
- this.#formatter = new Formatter({ json, worker: this.#worker, home });
372
+ const formatterOptions = { json, worker: this.#worker, home: this.home };
373
+ this.#formatter = new Formatter(formatterOptions);
373
374
  return this.open();
374
375
  }
375
376
 
@@ -449,12 +450,11 @@ class Logger extends EventEmitter {
449
450
  if (metautil.fileExt(fileName) !== 'log') continue;
450
451
  const fileAge = now - nameToDays(fileName);
451
452
  if (fileAge < this.#keepDays) continue;
452
- const promise = fsp
453
- .unlink(path.join(this.path, fileName))
454
- .catch(() => {});
453
+ const filePath = path.join(this.path, fileName);
454
+ const promise = fsp.unlink(filePath).catch(() => {});
455
455
  finish.push(promise);
456
456
  }
457
- await Promise.all(finish);
457
+ await Promise.allSettled(finish);
458
458
  } catch (error) {
459
459
  process.stdout.write(`${error.stack}\n`);
460
460
  this.emit('error', error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metalog",
3
- "version": "4.0.0-prerelease",
3
+ "version": "4.0.1-prerelease",
4
4
  "author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>",
5
5
  "description": "Logger for Metarhia",
6
6
  "license": "MIT",