@composer-js/core
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -7,10 +7,21 @@ "use strict"; | ||
const Transport = require('winston-transport'); | ||
const worker_threads_1 = require("worker_threads"); | ||
const { MESSAGE } = require('triple-beam'); | ||
/** | ||
* Provides a Winston transport for forwarding logs from this thread to the parent's logger instance. | ||
* | ||
* Constructor requires two properties to be set in the `opts` argument: | ||
* - `parentPort` | ||
* - `threadId` | ||
*/ | ||
class ThreadWinstonTransport extends Transport { | ||
/** | ||
* Creates a new instance with any defaults. | ||
* | ||
* @param opts The default options to initialize with. Requires two properties, `parentPort` and `threadId`, that | ||
* must be provided from the thread worker script. | ||
*/ | ||
constructor(opts) { | ||
super(opts); | ||
this.parentPort = opts.parentPort; | ||
this.threadId = opts.threadId; | ||
} | ||
@@ -20,6 +31,6 @@ log(info, callback) { | ||
// Prefix the thread ID to the message | ||
info[MESSAGE] = `[Thread-${worker_threads_1.threadId}]: ${info[MESSAGE]}`; | ||
info[MESSAGE] = `[Thread-${this.threadId}]: ${info[MESSAGE]}`; | ||
// Forward the log to the parent thread | ||
if (worker_threads_1.parentPort) { | ||
worker_threads_1.parentPort.postMessage({ | ||
if (this.parentPort) { | ||
this.parentPort.postMessage({ | ||
type: "winston-log", | ||
@@ -26,0 +37,0 @@ info |
declare const Transport: any; | ||
/** | ||
* Provides a Winston transport for forwarding logs from this thread to the parent's logger instance. | ||
* | ||
* Constructor requires two properties to be set in the `opts` argument: | ||
* - `parentPort` | ||
* - `threadId` | ||
*/ | ||
export default class ThreadWinstonTransport extends Transport { | ||
private parentPort; | ||
private threadId; | ||
/** | ||
* Creates a new instance with any defaults. | ||
* | ||
* @param opts The default options to initialize with. Requires two properties, `parentPort` and `threadId`, that | ||
* must be provided from the thread worker script. | ||
*/ | ||
constructor(opts: any); | ||
@@ -7,0 +19,0 @@ log(info: any, callback: Function): void; |
{ | ||
"name": "@composer-js/core", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "A collection of common utilities and core functionality for composerjs applications.", | ||
@@ -5,0 +5,0 @@ "author": "AcceleratXR, Inc. <info@acceleratxr.com>", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102312
1642