How to use the splunk-logging.Logger.prototype function in splunk-logging

To help you get started, we’ve selected a few splunk-logging examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github splunk / splunk-aws-serverless-apps / src / lib / splunklogger-lambda.js View on Github external
// 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;
github splunk / splunk-aws-serverless-apps / src / lib / splunklogger-lambda.js View on Github external
* 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') {
github splunk / splunk-aws-serverless-apps / src / lib / splunklogger-lambda.js View on Github external
*/

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;
        }

splunk-logging

Splunk HTTP Event Collector logging interface

Apache-2.0
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis