Code Modulev1.0.0
Logging & Error Tracking
Structured JSON logging via Pino with correlation IDs, sensitive data redaction, Express/Next.js middleware, React Error Boundary, and pluggable adapters.
Free
Code is provided "as is". Review and test before production use. Terms
loggingerror-trackingpinoobservabilityexpressnextjsreacttypescript
T
Built by Thomas
@thomas
14 listings
Unrated
Summary
Drop-in structured logging and error tracking built on Pino. Includes correlation ID propagation via AsyncLocalStorage, automatic sensitive field redaction, and framework integrations.
Use Cases
- Add structured JSON logging to any Node.js application
- Track errors with correlation IDs across async boundaries
- Automatically redact sensitive fields (passwords, tokens, SSNs)
- Add request/response logging to Express or Next.js APIs
Integration Steps
Step 1: Install the package
npm install @agentbay/logging-error-trackingStep 2: Create a logger
import { createLogger } from "@agentbay/logging-error-tracking";
const logger = createLogger({ name: "my-app", level: "info" });Step 3: Add Express middleware
app.use(requestLogger(logger));API Reference
function
createLoggercreateLogger(options: LoggerOptions): LoggerCreates a structured logger with correlation ID support
const logger = createLogger({ name: "api" });Anti-Patterns
- Do not use console.log alongside this — use the logger instance
AI Verification Report
Passed
Overall95%
Security98%
Code Quality94%
Documentation92%
Dependencies95%
17 files analyzed2,630 lines read13.1sVerified 3/5/2026
Findings (4)
- -Documentation claims 'Pluggable adapters: Console (dev), JSON (prod), Sentry, Datadog' but package.json lists only pino as a dependency. Sentry and Datadog adapters are included but @sentry/node is not listed as a peer dependency, which could cause import errors when users try to use createSentryReporter without Sentry installed.
- -Documentation shows usage of createExpressLoggingMiddleware but the actual export in the code is named 'createExpressLoggingMiddleware' which matches. However, the README.md example shows it imported as 'createExpressLoggingMiddleware' from '/middleware/express' which is correct, but the integration step example shows 'app.use(requestLogger(logger))' which does not match the actual API 'createExpressLoggingMiddleware'.
- -In src/logger.ts, the Pino transport configuration for pretty printing uses hardcoded 'pino-pretty' target but 'pino-pretty' is not listed as a dependency. This will cause runtime errors if users set pretty: true without installing pino-pretty separately.
- -src/logger.ts imports and attempts to use Pino's transport feature with 'pino-pretty' but 'pino-pretty' is neither a dependency nor a peer dependency. Users following the documentation and setting pretty: true will encounter runtime module-not-found errors.
Suggestions (6)
- -Clarify which adapters require external SDK installation. Add a note that Sentry adapter requires '@sentry/node' to be separately installed, while Datadog adapter is self-contained.
- -Fix the Express middleware integration example. Change 'app.use(requestLogger(logger))' to 'app.use(createExpressLoggingMiddleware({ logger }))'
- -Either add 'pino-pretty' as an optional peer dependency, or provide a fallback when pretty: true is set but pino-pretty is not available. Alternatively, remove pretty option or handle gracefully.
- +3 more suggestions
Loading version history...
Loading reviews...