UNPKG

ton-logger

Version:

Logger set and configurations for datadog

19 lines (18 loc) 659 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = (event) => { var _a, _b; const { headers } = event; const sourceIp = (_b = (_a = event.requestContext) === null || _a === void 0 ? void 0 : _a.identity) === null || _b === void 0 ? void 0 : _b.sourceIp; if (!headers) { return sourceIp; } const ip = headers['CF-Connecting-IP'] || headers['cf-connecting-ip'] || headers['X-Real-IP'] || headers['x-real-ip'] || headers['X-Forwarded-For'] || headers['x-forwarded-for'] || sourceIp; if (!ip) { return undefined; } return ip.split(',')[0]; };