@meshwatch/logging
Advanced tools
Comparing version 1.0.3 to 1.0.4
'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var util = _interopDefault(require('util')); | ||
function _extends() { | ||
@@ -93,3 +97,5 @@ _extends = Object.assign || function (target) { | ||
} else { | ||
console.log(levelName, message, params); | ||
console.log(levelName, message, util.inspect(params, { | ||
depth: Infinity | ||
})); | ||
} | ||
@@ -96,0 +102,0 @@ }; |
@@ -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";var e,r=(e=require("util"))&&"object"==typeof e&&"default"in e?e.default:e;function s(){return(s=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 o=global;let n=()=>o.CONTEXT||{};const t={DEBUG:0,INFO:1,WARN:2,ERROR:3},c={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},a=(e,r={})=>e?s({},r,{errorName:e.name,errorMessage:e.message,stackTrace:e.stack}):r,i=(e,o,a={})=>{const i=(e=>e>=t[(()=>process.env.LOG_LEVEL||"INFO")()])(t[e]),E=(()=>{const e=n();return"true"===process.env.DEBUG_LOG||"true"===e["Debug-Log-Enabled"]})();if(i||E)if((()=>!(!process.env.LAMBDA_TASK_ROOT||!process.env.AWS_EXECUTION_ENV))()){const r=(()=>{const e=n();return s({},c,{},e)})(),t=s({},r,{},a);t.level=e,t.message=o,console.log(JSON.stringify(t))}else console.log(e,o,r.inspect(a,{depth:Infinity}))},E={info:(e,r)=>{i("INFO",e,r)},debug:(e,r)=>{i("DEBUG",e,r)},warn:(e,r,s)=>{i("WARN",e,a(r,s))},error:(e,r,s)=>{i("ERROR",e,a(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);E.error("invocation failed",e.error,{awsRequestId:s,invocationEvent:o}),r(e.error)}}}),exports.logger=E; | ||
//# sourceMappingURL=logging.cjs.production.min.js.map |
@@ -0,1 +1,3 @@ | ||
import util from 'util'; | ||
function _extends() { | ||
@@ -91,3 +93,5 @@ _extends = Object.assign || function (target) { | ||
} else { | ||
console.log(levelName, message, params); | ||
console.log(levelName, message, util.inspect(params, { | ||
depth: Infinity | ||
})); | ||
} | ||
@@ -94,0 +98,0 @@ }; |
{ | ||
"name": "@meshwatch/logging", | ||
"description": "NodeJS serverless logging", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 11 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
44876
318
2
43