How to use the lambda-log.warn 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
srcBucket = body.source_bucket;
        srcKey = body.source_key;    

        dstBucket = body.target_bucket;
        dstKey = body.target_key; 
        
        correlationId = event.Records[0].messageAttributes.correlationId;
        //.debug(correlationId);  
        

    } else {
        // see https://stackoverflow.com/questions/41814750/how-to-know-event-souce-of-lambda-function-in-itself
        // for other event sources
        
        // Modify to suit your usecase
        log.warn("Unexpected invocation");
        log.warn(event);
        return;
    }    

    if (!srcKey.endsWith('doc') && !srcKey.endsWith('docx') ) {
        log.warn('Unsupported file type ' + srcKey);
        return; // TODO: if step function, return error?
    }
    if (srcKey.endsWith("/")) {
        // assume this is a folder; event probably triggered by copy/pasting a folder
        log.debug("is folder; returning");
        return;
    }

     // Output input URL for ease of inspection
     log.info("https://s3.console.aws.amazon.com/s3/object/" + srcBucket + "/" + srcKey);
github NativeDocuments / docx-to-pdf-on-AWS-Lambda / lambda / index.js View on Github external
srcKey = body.source_key;    

        dstBucket = body.target_bucket;
        dstKey = body.target_key; 
        
        correlationId = event.Records[0].messageAttributes.correlationId;
        //.debug(correlationId);  
        

    } else {
        // see https://stackoverflow.com/questions/41814750/how-to-know-event-souce-of-lambda-function-in-itself
        // for other event sources
        
        // Modify to suit your usecase
        log.warn("Unexpected invocation");
        log.warn(event);
        return;
    }    

    if (!srcKey.endsWith('doc') && !srcKey.endsWith('docx') ) {
        log.warn('Unsupported file type ' + srcKey);
        return; // TODO: if step function, return error?
    }
    if (srcKey.endsWith("/")) {
        // assume this is a folder; event probably triggered by copy/pasting a folder
        log.debug("is folder; returning");
        return;
    }

     // Output input URL for ease of inspection
     log.info("https://s3.console.aws.amazon.com/s3/object/" + srcBucket + "/" + srcKey);
github NativeDocuments / docx-to-pdf-on-AWS-Lambda / lambda / index.js View on Github external
correlationId = event.Records[0].messageAttributes.correlationId;
        //.debug(correlationId);  
        

    } else {
        // see https://stackoverflow.com/questions/41814750/how-to-know-event-souce-of-lambda-function-in-itself
        // for other event sources
        
        // Modify to suit your usecase
        log.warn("Unexpected invocation");
        log.warn(event);
        return;
    }    

    if (!srcKey.endsWith('doc') && !srcKey.endsWith('docx') ) {
        log.warn('Unsupported file type ' + srcKey);
        return; // TODO: if step function, return error?
    }
    if (srcKey.endsWith("/")) {
        // assume this is a folder; event probably triggered by copy/pasting a folder
        log.debug("is folder; returning");
        return;
    }

     // Output input URL for ease of inspection
     log.info("https://s3.console.aws.amazon.com/s3/object/" + srcBucket + "/" + srcKey);


    // Compute mimeType
    var mimeType;
    if (outputAs==Format.DOCX) {
        mimeType = Format.DOC.toString();
github NativeDocuments / docx-to-pdf-on-AWS-Lambda / lambda / index.js View on Github external
dstBucket = event.target_bucket;
        dstKey = event.target_key;
        
    } else if (/* Lambda S3 trigger */ event.Records && event.Records[0].eventSource === 'aws:s3') {
        
        //log.debug("received an S3 event");
        //log.debug(event);
        
        // Object key may have spaces or unicode non-ASCII characters.
        srcBucket = event.Records[0].s3.bucket.name;
        srcKey = decodeURIComponent(event.Records[0].s3.object.key.replace(/\+/g, " "));  

        // Avoid identity conversion, especially srcbucket == dstbucket
        // where we'd cause an event loop 
        if (srcKey.endsWith('docx') && outputAs==Format.DOCX ) {
            log.warn('Identity conversion avoided');
            return;
        }

        // if dstBucket is undefined, we'll use source bucket.
        dstBucket = process.env.S3_BUCKET_OUTPUT;
        if (dstBucket === undefined) {
            dstBucket = srcBucket;
        }
        
        // dstKey is computed below
        if (outputAs==Format.DOCX) {
            dstKey    = srcKey + ".docx";
        } else if (outputAs==Format.PDF) {
            dstKey    = srcKey + ".pdf";
        } else {
            log.error("Unsupported output format " + outputAs);
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" });

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