Registry / devops / alpha-lambda-bunyan

alpha-lambda-bunyan

JSON →
library1.5.0jsnpmunverified

Middleware for alpha-lambda that adds Bunyan logging to the AWS Lambda context object. Version 1.5.0 is stable; no recent releases. It injects `context.log` and `context.child` methods based on Bunyan, with automatic inclusion of request ID and function version. Unlike other logging libraries, it integrates tightly with alpha-lambda's middleware pipeline and supports custom serializers and level configuration via environment variables.

npm install alpha-lambda-bunyan
INSTALL
IMPORT
SIG · ALPHA-LAMBDA-BUNYA
A
alpha-lambda-bunyan
devopsjavascriptv1.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const bunyan = require('alpha-lambda-bunyan');
import bunyan from 'alpha-lambda-bunyan';
CommonJS only; no ESM exports. Use require() or dynamic import().
extend
const { extend } = require('alpha-lambda-bunyan');
const extend = require('alpha-lambda-bunyan/extend');
Named export via destructuring; no subpath export.
bunyan (alias)
const bunyan = require('alpha-lambda-bunyan');
Default export is the middleware function; also has extend attached as a property.

Set up alpha-lambda handler with Bunyan logging middleware, demonstrating context.log and context.child usage.

const bunyan = require('alpha-lambda-bunyan'); const handler = require('alpha-lambda'); module.exports = handler() .use(bunyan({ level: 'debug', serializers: { event(data) { return { id: data.id }; } } })) .use((event, context) => { context.log({ event }, 'event received'); const childContext = context.child({ customField: 'value' }); return doSomething(childContext, event); });
Debug
Known issues
gotchacontext.log is a Bunyan instance, not a standard console.log. Calling it with only a string will log at INFO level.
fix
Use context.log.info('message') or context.log({}, 'message') for object logging.
affects: >=1.0.0
gotchacontext.child clones the context deeply, but in Node.js 16+ deep cloning large contexts may cause performance issues.
fix
Use refProps option to mark properties that should be shallow copied instead.
affects: >=1.0.0
gotchaThe default serializers include a custom err serializer that may not handle all error shapes correctly.
fix
Override serializers option with your own if you need different error serialization.
affects: >=1.0.0
gotchaThe LOG_LEVEL environment variable takes precedence over options.level if set.
fix
Clear LOG_LEVEL env or set options.level explicitly to override.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: bunyan is not a function
Using import instead of require (ESM vs CJS mismatch).
fix
Change import statement to const bunyan = require('alpha-lambda-bunyan');
Cannot find module 'alpha-lambda-bunyan'
Package not installed or module path incorrect.
fix
Run npm install alpha-lambda-bunyan and verify package.json.
context.child is not a function
Using the library incorrectly, e.g., calling child before middleware runs.
fix
Ensure bunyan() middleware is used before handlers that call context.child.
Upgrade
Version history
1.5.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
29 hits · last 30 days
node
26
OpenAI (training)
1
Resources
alpha-lambda-bunyan — npm install alpha-lambda-bunyan · libregistry