New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@baileyherbert/logging

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@baileyherbert/logging - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

9

dist/core/Logger.d.ts
import { EventEmitter } from '@baileyherbert/events';
import { LogLevel } from '../enums/LogLevel';
import { Transport } from '../main';
import { ConsoleTransport, ConsoleTransportOptions } from '../transports/ConsoleTransport';

@@ -21,2 +22,6 @@ import { FileTransport, FileTransportOptions } from '../transports/FileTransport';

/**
* An array of all transports that have been attached to this logger.
*/
private _transports;
/**
* Constructs a new `Logger` instance.

@@ -148,2 +153,6 @@ *

createFileTransport(options: FileTransportOptions): FileTransport;
/**
* Returns an array of all active transports that are listening to this logger.
*/
get transports(): Transport[];
}

@@ -150,0 +159,0 @@ declare type LoggerEvents = {

@@ -27,2 +27,6 @@ "use strict";

this.parent = parent;
/**
* An array of all transports that have been attached to this logger.
*/
this._transports = new Set();
this.name = name;

@@ -185,4 +189,25 @@ this.level = level;

}
/**
* @internal
*/
_attachTransport(transport) {
this._transports.add(transport);
}
/**
* @internal
*/
_detachTransport(transport) {
this._transports.delete(transport);
}
/**
* Returns an array of all active transports that are listening to this logger.
*/
get transports() {
if (this.parent) {
return [...this._transports, ...this.parent.transports];
}
return [...this._transports];
}
}
exports.Logger = Logger;
//# sourceMappingURL=Logger.js.map

@@ -19,2 +19,4 @@ /// <reference types="node" />

protected queue: Array<LoggerOutput>;
protected available: boolean;
protected rotating: boolean;
constructor(level: LogLevel, options: FileTransportOptions);

@@ -57,2 +59,6 @@ constructor(options: FileTransportOptions);

get fileName(): string;
/**
* Returns a promise that resolves when the transport is done writing log data to its destination.
*/
close(): Promise<void>;
}

@@ -122,2 +128,6 @@ export interface FileTransportOptions {

cleaned: [RotationArchive];
/**
* Emitted when the internal write queue is empty.
*/
empty: [];
};

@@ -124,0 +134,0 @@ export interface RotationFile {

@@ -56,2 +56,4 @@ "use strict";

});
this.available = true;
this.rotating = false;
this.currentFileSize = 0;

@@ -69,2 +71,5 @@ this.writing = false;

return __awaiter(this, void 0, void 0, function* () {
if (!this.available) {
return;
}
if (this.writing) {

@@ -94,2 +99,5 @@ this.queue.push(...lines);

}
else {
this.emit('empty');
}
});

@@ -160,5 +168,7 @@ }

this.currentFileSize = 0;
this.rotating = false;
// Resolve
source.setResult();
}));
this.rotating = true;
// Write the text chunk

@@ -268,4 +278,23 @@ stream.end(content);

}
/**
* Returns a promise that resolves when the transport is done writing log data to its destination.
*/
close() {
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
this.detachAll();
// Wait for rotations
if (this.rotating) {
yield new Promise(r => this.once('rotated', r));
}
// Wait to finish writing the queue
if (this.queue.length > 0) {
yield new Promise(r => this.once('empty', r));
}
this.stream.on('finish', resolve);
this.stream.end();
this.available = false;
}));
}
}
exports.FileTransport = FileTransport;
//# sourceMappingURL=FileTransport.js.map

@@ -51,2 +51,10 @@ import { EventEmitter, EventEmitterSchema } from '@baileyherbert/events';

protected onLoggerDetached(logger: Logger): Promisable<void>;
/**
* Closes the transport. Returns a promise that resolves when complete.
*/
close(): Promise<void>;
/**
* Detaches the transport from all loggers.
*/
detachAll(): void;
}

@@ -53,0 +61,0 @@ declare type Promisable<T> = T | Promise<T>;

@@ -41,2 +41,3 @@ "use strict";

logger.on('output', listener);
logger._attachTransport(this);
// @ts-ignore

@@ -57,2 +58,3 @@ this.emit('loggerAttached', logger);

logger.removeListener('output', listener);
logger._detachTransport(this);
// @ts-ignore

@@ -77,4 +79,19 @@ this.emit('loggerDetached', logger);

}
/**
* Closes the transport. Returns a promise that resolves when complete.
*/
close() {
this.detachAll();
return Promise.resolve();
}
/**
* Detaches the transport from all loggers.
*/
detachAll() {
for (const logger of this._listeners.keys()) {
this.detach(logger);
}
}
}
exports.Transport = Transport;
//# sourceMappingURL=Transport.js.map

2

package.json
{
"name": "@baileyherbert/logging",
"version": "1.0.2",
"version": "1.1.0",
"description": "Just another logging solution.",

@@ -5,0 +5,0 @@ "author": "Bailey Herbert <hello+npm@bailey.sh> (https://bailey.sh)",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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