UNPKG

simple-leveled-log-methods

Version:

a simple and opinionated logging library. plays well with aws lambda + cloudwatch.

22 lines 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.identifyEnvironment = void 0; const constants_1 = require("./constants"); /** * identifies the supported environment that this is being run in, as best as possible * - defaults to LOCAL environment, as it has the most common settings and is not distinguishable otherwise */ const identifyEnvironment = () => { // check if its an aws-lambda runtime environment const isAwsLambdaEnvironment = !!process.env.AWS_LAMBDA_FUNCTION_NAME; // if this env var is defined, then its aws lambda env if (isAwsLambdaEnvironment) return constants_1.SupportedEnvironment.AWS_LAMBDA; // check if its a browser environment const isWebBrowserEnvironment = typeof window !== 'undefined' && typeof window.document !== 'undefined'; // if both are defined, then its a browser if (isWebBrowserEnvironment) return constants_1.SupportedEnvironment.WEB_BROWSER; // default to local env return constants_1.SupportedEnvironment.LOCAL; }; exports.identifyEnvironment = identifyEnvironment; //# sourceMappingURL=identifyEnvironment.js.map