@codemod/replace-console-log-with-vivid-trail-rj9w
Replace console.log with OTel logger
What It Does
This codemod rewrites standalone console.log(...) statement calls in the server-side parts of codemod/codemod-app to the repository's existing OpenTelemetry logger API from @codemod.com/otel.
It uses the repo's established shape:
ts
Target Paths
apps/worker/src/**packages/api/src/**apps/nextjs/src/instrumentation.*apps/nextjs/src/instrumentation-node.*apps/nextjs/src/middleware.*
Skips
- comments and string literals that merely mention
console.log console.logcalls used inside larger expressions instead of standalone statements- client-side Next.js files with a top-level
"use client"directive apps/nextjs/src/app/(studio)/studio/_hooks/_data/default/**apps/nextjs/scripts/**apps/website/**apps/promotional-videos/**- files outside the repo areas that already show
@codemod.com/otelusage conventions
Rewrite Rules
Single message
ts
becomes:
ts
String or template message with extra args
ts
becomes:
ts
No leading string-ish message
ts
becomes:
ts
Import Handling
- reuses an existing
loggerimport from@codemod.com/otel - extends an existing
@codemod.com/otelnamed import whenloggeris missing - adds a new
@codemod.com/otelimport when needed - aliases to
logger as otelLoggerwhen the file already bindslogger
Assumptions
- The codemod is intentionally repository-aware, not a generic
console.logmigration. - It only rewrites files where using
@codemod.com/otelis consistent with the repo's current server-side logging conventions. - For Next.js, it stays conservative and only targets clearly server-side entry files.
Installation
bash
Usage
bash
Development
bash
License
MIT