{"id":40560,"library":"alpha-lambda-bunyan","title":"alpha-lambda-bunyan","description":"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.","status":"active","version":"1.5.0","language":"javascript","source_language":"en","source_url":"https://github.com/AntonBazhal/alpha-lambda-bunyan","tags":["javascript","aws","aws lambda","bunyan","lambda","log","logger","middleware","serverless"],"install":[{"cmd":"npm install alpha-lambda-bunyan","lang":"bash","label":"npm"},{"cmd":"yarn add alpha-lambda-bunyan","lang":"bash","label":"yarn"},{"cmd":"pnpm add alpha-lambda-bunyan","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"CommonJS only; no ESM exports. Use require() or dynamic import().","wrong":"import bunyan from 'alpha-lambda-bunyan';","symbol":"default","correct":"const bunyan = require('alpha-lambda-bunyan');"},{"note":"Named export via destructuring; no subpath export.","wrong":"const extend = require('alpha-lambda-bunyan/extend');","symbol":"extend","correct":"const { extend } = require('alpha-lambda-bunyan');"},{"note":"Default export is the middleware function; also has extend attached as a property.","symbol":"bunyan (alias)","correct":"const bunyan = require('alpha-lambda-bunyan');"}],"quickstart":{"code":"const bunyan = require('alpha-lambda-bunyan');\nconst handler = require('alpha-lambda');\n\nmodule.exports = handler()\n  .use(bunyan({\n    level: 'debug',\n    serializers: {\n      event(data) { return { id: data.id }; }\n    }\n  }))\n  .use((event, context) => {\n    context.log({ event }, 'event received');\n    const childContext = context.child({ customField: 'value' });\n    return doSomething(childContext, event);\n  });","lang":"javascript","description":"Set up alpha-lambda handler with Bunyan logging middleware, demonstrating context.log and context.child usage."},"warnings":[{"fix":"Use context.log.info('message') or context.log({}, 'message') for object logging.","message":"context.log is a Bunyan instance, not a standard console.log. Calling it with only a string will log at INFO level.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use refProps option to mark properties that should be shallow copied instead.","message":"context.child clones the context deeply, but in Node.js 16+ deep cloning large contexts may cause performance issues.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Override serializers option with your own if you need different error serialization.","message":"The default serializers include a custom err serializer that may not handle all error shapes correctly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Clear LOG_LEVEL env or set options.level explicitly to override.","message":"The LOG_LEVEL environment variable takes precedence over options.level if set.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.5.0':21 'add':11 'alpha':2,8,54 'alpha-lambda':7,53 'alpha-lambda-bunyan':1 'automat':37 'aw':16,70,71 'base':33 'bunyan':4,12,35,73 'configur':65 'context':18 'context.child':31 'context.log':29 'custom':61 'environ':67 'function':43 'id':41 'inclus':38 'inject':28 'integr':50 'javascript':69 'lambda':3,9,17,55,72,74 'level':64 'librari':48 'log':13,47,75 'logger':76 'method':32 'middlewar':5,57,77 'object':19 'pipelin':58 'recent':25 'releas':26 'request':40 'serial':62 'serverless':78 'stabl':23 'support':60 'tight':51 'unlik':45 'variabl':68 'version':20,44 'via':66","created_at":"2026-06-04T18:48:09.460035+00:00","updated_at":"2026-06-04T18:48:09.460035+00:00","problems":[{"fix":"Change import statement to const bunyan = require('alpha-lambda-bunyan');","cause":"Using import instead of require (ESM vs CJS mismatch).","error":"TypeError: bunyan is not a function"},{"fix":"Run npm install alpha-lambda-bunyan and verify package.json.","cause":"Package not installed or module path incorrect.","error":"Cannot find module 'alpha-lambda-bunyan'"},{"fix":"Ensure bunyan() middleware is used before handlers that call context.child.","cause":"Using the library incorrectly, e.g., calling child before middleware runs.","error":"context.child is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/AntonBazhal/alpha-lambda-bunyan#readme","github":"https://github.com/AntonBazhal/alpha-lambda-bunyan","docs":null,"changelog":null,"pypi":null,"npm":"alpha-lambda-bunyan","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}