Skip to content

feat(text-logger-slf4j): add structured log context injector hook#1366

Open
jpenilla wants to merge 3 commits into
PaperMC:main/4from
jpenilla:feat/slf4j-context-hook
Open

feat(text-logger-slf4j): add structured log context injector hook#1366
jpenilla wants to merge 3 commits into
PaperMC:main/4from
jpenilla:feat/slf4j-context-hook

Conversation

@jpenilla

@jpenilla jpenilla commented Feb 9, 2026

Copy link
Copy Markdown
Member
  • add internal ComponentLogContextInjector and ComponentLogRecord types for forwarding raw component log metadata
  • extend ComponentLoggerProvider.LoggerHelper with backward-compatible delegating(..., injector) overload
  • wire Handler.LoggerHelperImpl to construct WrappingComponentLoggerImpl with optional injector
  • wrap all enabled log paths in WrappingComponentLoggerImpl with injector scope begin/close, swallowing injector errors and preserving existing output behavior
  • add tests for raw record capture, throwable forwarding, scope close lifecycle, and injector failure tolerance

This will allow for Endermux to forward rich log messages over the socket.

 - add internal ComponentLogContextInjector and ComponentLogRecord types for forwarding raw component log metadata
 - extend ComponentLoggerProvider.LoggerHelper with backward-compatible delegating(..., injector) overload
 - wire Handler.LoggerHelperImpl to construct WrappingComponentLoggerImpl with optional injector
 - wrap all enabled log paths in WrappingComponentLoggerImpl with injector scope begin/close, swallowing injector errors and preserving existing output behavior
 - add tests for raw record capture, throwable forwarding, scope close lifecycle, and injector failure tolerance

This will allow for Endermux to forward rich log messages over the socket.
@zml2008

zml2008 commented Feb 9, 2026

Copy link
Copy Markdown
Member

How worried are we about the unconditional extra allocations from capturing new Runnable instances for every log method? I'm used to most logging libs being very concerned about allocations, but i'm not sure how real that impact is in modern JVMs

- inline context scope management in WrappingComponentLoggerImpl
- replace withContext(..., Runnable) lambdas with explicit beginContext + try/finally closeContext
- preserve injector error-swallowing behavior and existing logging semantics
- remove now-unused withContext helper method
@jpenilla

jpenilla commented Feb 9, 2026

Copy link
Copy Markdown
Member Author

I think it's a valid concern, I've inlined the scope management.

@jpenilla

Copy link
Copy Markdown
Member Author

I was able to get Endermux working with this PR:
image

@jpenilla jpenilla marked this pull request as ready for review February 19, 2026 16:58
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