@meshwatch/logging
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -124,3 +124,3 @@ 'use strict'; | ||
sampleRate = DEFAULT_SAMPLE_RATE | ||
}) => { | ||
} = {}) => { | ||
let oldLogLevel; | ||
@@ -127,0 +127,0 @@ return { |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(){return(e=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var s=arguments[r];for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(e[o]=s[o])}return e}).apply(this,arguments)}const r=global;let s=()=>r.CONTEXT||{};const o={DEBUG:0,INFO:1,WARN:2,ERROR:3},n={awsRegion:process.env.AWS_REGION||process.env.AWS_DEFAULT_REGION,functionName:process.env.AWS_LAMBDA_FUNCTION_NAME,functionVersion:process.env.AWS_LAMBDA_FUNCTION_VERSION,functionMemorySize:process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE,stage:process.env.ENVIRONMENT||process.env.STAGE},t=(r,s={})=>r?e({},s,{errorName:r.name,errorMessage:r.message,stackTrace:r.stack}):s,c=(r,t,c={})=>{const a=(e=>e>=o[(()=>process.env.LOG_LEVEL||"INFO")()])(o[r]),E=(()=>{const e=s();return"true"===process.env.DEBUG_LOG||"true"===e["Debug-Log-Enabled"]})();if(a||E)if((()=>!(!process.env.LAMBDA_TASK_ROOT||!process.env.AWS_EXECUTION_ENV))()){const o=(()=>{const r=s();return e({},n,{},r)})(),a=e({},o,{},c);a.level=r,a.message=t,console.log(JSON.stringify(a))}else console.log(r,t,c)},a={info:(e,r)=>{c("INFO",e,r)},debug:(e,r)=>{c("DEBUG",e,r)},warn:(e,r,s)=>{c("WARN",e,t(r,s))},error:(e,r,s)=>{c("ERROR",e,t(r,s))}};exports.debuggy=(({sampleRate:e=.05})=>{let r;return{before:(s,o)=>{Math.random()<=e&&(r=process.env.LOG_LEVEL,process.env.LOG_LEVEL="DEBUG"),o()},after:(e,s)=>{r&&(process.env.LOG_LEVEL=void 0),s()},onError:(e,r)=>{const{awsRequestId:s}=e.context,o=JSON.stringify(e.event);a.error("invocation failed",e.error,{awsRequestId:s,invocationEvent:o}),r(e.error)}}}),exports.logger=a; | ||
"use strict";function e(){return(e=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var s=arguments[r];for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(e[o]=s[o])}return e}).apply(this,arguments)}const r=global;let s=()=>r.CONTEXT||{};const o={DEBUG:0,INFO:1,WARN:2,ERROR:3},n={awsRegion:process.env.AWS_REGION||process.env.AWS_DEFAULT_REGION,functionName:process.env.AWS_LAMBDA_FUNCTION_NAME,functionVersion:process.env.AWS_LAMBDA_FUNCTION_VERSION,functionMemorySize:process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE,stage:process.env.ENVIRONMENT||process.env.STAGE},t=(r,s={})=>r?e({},s,{errorName:r.name,errorMessage:r.message,stackTrace:r.stack}):s,c=(r,t,c={})=>{const a=(e=>e>=o[(()=>process.env.LOG_LEVEL||"INFO")()])(o[r]),E=(()=>{const e=s();return"true"===process.env.DEBUG_LOG||"true"===e["Debug-Log-Enabled"]})();if(a||E)if((()=>!(!process.env.LAMBDA_TASK_ROOT||!process.env.AWS_EXECUTION_ENV))()){const o=(()=>{const r=s();return e({},n,{},r)})(),a=e({},o,{},c);a.level=r,a.message=t,console.log(JSON.stringify(a))}else console.log(r,t,c)},a={info:(e,r)=>{c("INFO",e,r)},debug:(e,r)=>{c("DEBUG",e,r)},warn:(e,r,s)=>{c("WARN",e,t(r,s))},error:(e,r,s)=>{c("ERROR",e,t(r,s))}};exports.debuggy=(({sampleRate:e=.05}={})=>{let r;return{before:(s,o)=>{Math.random()<=e&&(r=process.env.LOG_LEVEL,process.env.LOG_LEVEL="DEBUG"),o()},after:(e,s)=>{r&&(process.env.LOG_LEVEL=void 0),s()},onError:(e,r)=>{const{awsRequestId:s}=e.context,o=JSON.stringify(e.event);a.error("invocation failed",e.error,{awsRequestId:s,invocationEvent:o}),r(e.error)}}}),exports.logger=a; | ||
//# sourceMappingURL=logging.cjs.production.min.js.map |
@@ -122,3 +122,3 @@ function _extends() { | ||
sampleRate = DEFAULT_SAMPLE_RATE | ||
}) => { | ||
} = {}) => { | ||
let oldLogLevel; | ||
@@ -125,0 +125,0 @@ return { |
@@ -5,3 +5,3 @@ import { MiddlewareObject } from 'middy'; | ||
}; | ||
declare const _default: <T = any, R = any>({ sampleRate, }: Config) => MiddlewareObject<T, R>; | ||
declare const _default: <T = any, R = any>({ sampleRate, }?: Config) => MiddlewareObject<T, R>; | ||
export default _default; |
{ | ||
"name": "@meshwatch/logging", | ||
"description": "NodeJS serverless logging", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"license": "UNLICENSED", | ||
@@ -6,0 +6,0 @@ "source": "src/index.ts", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
43812
0