Skip to content

chore(log4js): shim _log instead of log #2672

Merged
aryamohanan merged 1 commit into
mainfrom
refactor-log4js
Jul 23, 2026
Merged

chore(log4js): shim _log instead of log #2672
aryamohanan merged 1 commit into
mainfrom
refactor-log4js

Conversation

@aryamohanan

Copy link
Copy Markdown
Contributor

The old shim wrapped log(), which received the raw value passed by the user (for example, "ERROR" or 3). So we needed getLevel() to convert it into a Level object.

Now we're wrapping _log(), which log4js calls after it has already resolved the level. That means level is always a Level object, so getLevel() is no longer needed.

This also lets us remove the extra mapping logic (LEVEL_MAP, LOG_LEVEL, shouldCaptureLogSpan, and resolveLogLevel), since we can use the resolved Level object directly.

@aryamohanan
aryamohanan requested a review from a team as a code owner July 23, 2026 09:34

function instrumentLog4jsLogger(loggerModule) {
shimmer.wrap(loggerModule.prototype, 'log', shimLog);
shimmer.wrap(loggerModule.prototype, '_log', shimLog);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aryamohanan aryamohanan changed the title fix(log4js): shim _log instead of log chore(log4js): shim _log instead of log Jul 23, 2026
Comment thread packages/core/src/tracing/instrumentation/logging/log4js.js

@kirrg001 kirrg001 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@aryamohanan
aryamohanan merged commit b952339 into main Jul 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants