Skip to content

pambda/pambda-cwlogs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pambda-cwlogs

Pambda to output logs to CloudWatch Logs.

Installation

npm i pambda-cwlogs -S

Usage

import { compose, createLambda } from 'pambda';
import { cwlogs } from 'pambda-cwlogs';

export const handler = createLambda(
  compose(
    cwlogs({
      logGroupName: 'Sandbox',
      makeLogStreamName(event, context) {
        return event.userId;
      },
    }),

    // Subsequent pambdas can log messages.
    next => (event, context, callback) => {
      context.logEvent('Path: %s', event.path);
    }
  )
);

cwlogs(options)

Generate and return a pambda which adds the logger function to context.

  • options.logGroupName
    • The name of the log group.
  • options.makeLogStreamName(event, context)
    • The function makes the name of the log stream.
    • If this function returns falsy, logs are discarded.

context.logEvent(...args)

A function that is added by this pambda to context.

It outputs the message specified by argument args to CloudWatch Logs.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published