Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

metalog

Package Overview
Dependencies
Maintainers
4
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metalog - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

52

metalog.js
'use strict';
const fs = require('fs');
const { EventEmitter } = require('events');
const events = require('events');
const common = require('@metarhia/common');

@@ -63,3 +63,3 @@ const { WritableFileStream } = require('metastreams');

class Logger extends EventEmitter {
class Logger extends events.EventEmitter {
// path <string> log directory

@@ -95,6 +95,6 @@ // workerId <string> workwr process or thread id

this.toStdout = logTypes(toStdout);
this.open();
return this.open();
}
open() {
async open() {
if (this.active) return;

@@ -129,5 +129,7 @@ this.active = true;

});
await events.once(this, 'open');
return this;
}
close() {
async close() {
if (!this.active) return;

@@ -141,20 +143,24 @@ if (!this.fsEnabled) {

if (!stream || stream.destroyed || stream.closed) return;
this.flush(err => {
if (err) {
process.stdout.write(`${err.stack}\n`);
this.emit('error', err);
return;
}
this.active = false;
stream.end(() => {
clearInterval(this.flushTimer);
clearTimeout(this.reopenTimer);
this.flushTimer = null;
this.reopenTimer = null;
const fileName = this.file;
this.emit('close');
fs.stat(fileName, (err, stats) => {
if (err) return;
if (stats.size > 0) return;
fs.unlink(this.file, () => {});
return new Promise((resolve, reject) => {
this.flush(err => {
if (err) {
process.stdout.write(`${err.stack}\n`);
this.emit('error', err);
reject(err);
return;
}
this.active = false;
stream.end(() => {
clearInterval(this.flushTimer);
clearTimeout(this.reopenTimer);
this.flushTimer = null;
this.reopenTimer = null;
const fileName = this.file;
this.emit('close');
resolve();
fs.stat(fileName, (err, stats) => {
if (err) return;
if (stats.size > 0) return;
fs.unlink(this.file, () => {});
});
});

@@ -161,0 +167,0 @@ });

{
"name": "metalog",
"version": "2.0.1",
"version": "2.1.0",
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>",

@@ -47,5 +47,5 @@ "description": "Logger for Metarhia",

"devDependencies": {
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.1",
"eslint-plugin-prettier": "^3.1.2",
"eslint": "^7.1.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.3",
"metatests": "^0.7.1",

@@ -52,0 +52,0 @@ "prettier": "^1.19.1"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc