Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Add Lambda metadata if available
if (typeof context !== 'undefined') {
var reqId = context.awsRequestId;
if (typeof reqId !== 'undefined') {
payload.message.awsRequestId = context.awsRequestId;
}
payload.metadata.source = context.functionName;
}
payload.metadata.time = new Date(time).getTime() / 1000;
this.send(payload);
};
SplunkLogger.prototype.flushAsync = function(callback) {
if (this.serializedContextQueue.length > 0) {
this.flush(callback);
} else {
callback();
}
};
module.exports = SplunkLogger;
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
var SplunkLogger = require("splunk-logging").Logger;
// Override default built-in eventFormatter function
function _defaultEventFormatterForLambda(message, severity) {
var event = message;
return event;
};
// Extend SplunkLogger with simple Lambda logging API
SplunkLogger.prototype.log = function(message, context) {
this.logWithTime(Date.now(), message, context);
};
SplunkLogger.prototype.logWithTime = function(time, message, context) {
var payload = {
message: {},
metadata: {}
};
if (Object.prototype.toString.call(message) === '[object Array]') {
throw new Error("message argument must be a string or a JSON object.");
}
payload.message = message;
// Add Lambda metadata if available
if (typeof context !== 'undefined') {
*/
var SplunkLogger = require("splunk-logging").Logger;
// Override default built-in eventFormatter function
function _defaultEventFormatterForLambda(message, severity) {
var event = message;
return event;
};
// Extend SplunkLogger with simple Lambda logging API
SplunkLogger.prototype.log = function(message, context) {
this.logWithTime(Date.now(), message, context);
};
SplunkLogger.prototype.logWithTime = function(time, message, context) {
var payload = {
message: {},
metadata: {}
};
if (Object.prototype.toString.call(message) === '[object Array]') {
throw new Error("message argument must be a string or a JSON object.");
}
payload.message = message;
// Add Lambda metadata if available
if (typeof context !== 'undefined') {
var reqId = context.awsRequestId;
if (typeof reqId !== 'undefined') {
payload.message.awsRequestId = context.awsRequestId;
}