How to use the lambda-log.error function in lambda-log

To help you get started, we’ve selected a few lambda-log 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 NativeDocuments / docx-to-pdf-on-AWS-Lambda / lambda / index.js View on Github external
mimeType = Format.DOC.toString();
    } else if (outputAs==Format.PDF) {
        mimeType = Format.PDF.toString();
    } else {
        log.error("Unsupported output format " + outputAs);
        return;
    }

    // initialise engine.
    // This is inside the handler since we need to read memoryLimitInMB from context
    if (!INITIALISED) {
        try {
            config.init(context.memoryLimitInMB);
            INITIALISED = true;
        } catch (e) {
            log.error(e);
            return;
        }
    }
    var sqsQueueUrl = process.env.SQS_WRITE_QUEUE_URL;

    // Actually execute the steps  
    var data;
    try {
        // get the docx
        data = await s3.getObject( {Bucket: srcBucket, Key: srcKey}).promise();

        // convert it
        var output = await helper.convert(srcKey, data.Body, outputAs );

        // save the result
        log.debug("uploading to s3 " + dstBucket);
github NativeDocuments / docx-to-pdf-on-AWS-Lambda / lambda / index.js View on Github external
mimeType = "application/octet-stream";
        }
        
        dstKey    = "BROKEN/" + srcKey +  "-" + (new Date).getTime() +  "." + ext;
        log.error("RESULT: Failed " + dstKey ); /* Log analysis regex matching */

        // save this bug doc
        try {
            await s3.putObject({
                    Bucket: dstBucket,
                    Key: dstKey,
                    Body: new Buffer(data.Body) /* arrayBuffer to Buffer  */,
                    ContentType: mimeType
                }).promise(); 
        } catch (putErr) {
            log.error(putErr);
            log.error("Problem saving bug doc " + dstKey );
        }
        
    }
};
github NativeDocuments / docx-to-pdf-on-AWS-Lambda / lambda / index.js View on Github external
// Return a result (step function can catch this)
            throw e;
        }
        if (sqsQueueUrl) { 
            // TODO: write SQS message on failure?
        }
        
        /* For S3 trigger, broken documents saved to dstBucket/BROKEN
           To get help, please note the contents of the assertion,
           together with the document which caused it.
        */
        
        // save broken documents to dstBucket/BROKEN
        /* unless */ 
        if (dstBucket == srcBucket) /* to avoid repetitively processing the same document */ {
            log.error("RESULT: Failed " + srcKey);
            log.debug("cowardly refusing to write broken document to srcBucket!");
            return;
        }
        var ext = srcKey.substr(srcKey.lastIndexOf('.') + 1);
        var mimeType;
        if (ext=="docx") {
            mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
        } else if (ext=="doc") {
            mimeType = Format.DOC.toString();
        } else {
            mimeType = "application/octet-stream";
        }
        
        dstKey    = "BROKEN/" + srcKey +  "-" + (new Date).getTime() +  "." + ext;
        log.error("RESULT: Failed " + dstKey ); /* Log analysis regex matching */
github DefinitelyTyped / DefinitelyTyped / types / lambda-log / lambda-log-tests.ts View on Github external
import * as log from "lambda-log";

const logMessage: log.LogMessage = log.log("customLevel", "custom", {
    key: "value"
});
logMessage.level;
logMessage.meta;
logMessage.tags;
logMessage.msg;
logMessage.value;
logMessage.log;
logMessage.toJSON(true);

log.info("info", { key: "value" });
log.warn("warn", { key: "value" });
log.error(new Error("This is an error"), { key: "value" });
log.debug("debug", { key: "value" });
log.assert(true, "this will print");

const logInstance = new log.LambdaLog({
    dynamicMeta: (logMessage: log.LogMessage) => {
        return {
            value: logMessage.value
        };
    }
});
logInstance.log("customLevel", "custom", { key: "value" });
logInstance.info("info", { key: "value" });
logInstance.warn("warn", { key: "value" });
logInstance.error(new Error("This is an error"), { key: "value" });
logInstance.debug("debug", { key: "value" });
logInstance.assert(true, "this will print");
github smithclay / lambdium / src / index.js View on Github external
sandbox.executeScript(opts, function(err) {
    if (process.env.LOG_DEBUG) {
      log.debug(child.execSync('ps aux').toString());
      log.debug(child.execSync('cat /tmp/chromedriver.log').toString())
    }
    if (err) {
      log.error(err);
      return callback(err, null);
    }

    callback(null, 'Finished executing script');
  });
};
github NativeDocuments / docx-to-pdf-on-AWS-Lambda / lambda / index.js View on Github external
sqs.sendMessage(params, function(err, data) {
                if (err) {
                    log.error("Error", err);
                } else {
                    //log.debug("Success", data.MessageId);
                }
            });
        }

lambda-log

Lightweight logging library for any Node 10+ applications

MIT
Latest version published 3 years ago

Package Health Score

50 / 100
Full package analysis