@janiscommerce/log
Advanced tools
Comparing version 5.0.11 to 5.0.12
@@ -89,2 +89,4 @@ 'use strict'; | ||
this.start(); | ||
if(!Array.isArray(logs)) | ||
@@ -100,2 +102,12 @@ logs = [logs]; | ||
static start() { | ||
// this method is called in janiscommerce packages handlers to ensure end layer extension (even when no logs loaded in function) | ||
if(this.traceExtensionIsEnabled() && shouldAddEndedListener()) { | ||
Events.on('janiscommerce.ended', this.flushLogsOnEnded); | ||
endedListenerWasAdded(); | ||
} | ||
} | ||
static addClientAndDateCreated(logs, client) { | ||
@@ -118,6 +130,10 @@ | ||
static shouldAddLogsLocally(logs) { | ||
return process.env.JANIS_TRACE_EXTENSION_ENABLED | ||
return this.traceExtensionIsEnabled() | ||
&& logs.length < MAX_LOGS_PER_LOCAL_BATCH; | ||
} | ||
static traceExtensionIsEnabled() { | ||
return !!process.env.JANIS_TRACE_EXTENSION_ENABLED; | ||
} | ||
/** | ||
@@ -146,7 +162,2 @@ * Send multiple logs directly to Firehose. If you're implementing a Janis Service, you should be using the add() method | ||
if(shouldAddEndedListener()) { | ||
Events.on('janiscommerce.ended', this.flushLogsOnEnded); | ||
endedListenerWasAdded(); | ||
} | ||
} catch(err) { | ||
@@ -153,0 +164,0 @@ |
{ | ||
"name": "@janiscommerce/log", | ||
"version": "5.0.11", | ||
"version": "5.0.12", | ||
"description": "A package for creating logs in Janis Trace Service", | ||
@@ -5,0 +5,0 @@ "main": "lib/log.js", |
@@ -32,4 +32,6 @@ export = Log; | ||
static add(client: string, logs: LogData | Array<LogData>): Promise<void>; | ||
static start(): void; | ||
static addClientAndDateCreated(logs: any, client: any): any; | ||
static shouldAddLogsLocally(logs: any): boolean; | ||
static traceExtensionIsEnabled(): boolean; | ||
/** | ||
@@ -36,0 +38,0 @@ * Send multiple logs directly to Firehose. If you're implementing a Janis Service, you should be using the add() method |
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
29498
687