feat(hub): add ForkableHub WithLogger option#56
Merged
maoueh merged 2 commits intoJun 11, 2026
Conversation
ForkableHub previously logged everything under the package-level `bstream` logger, so lines such as `processing block` were indistinguishable across components running their own hub (relayer, firehose, tier1, ...). Add a `logger` field and `WithLogger` option. The logger is propagated to the inner forkable by default so its block-level lines are attributed too. Receiver methods now log through `h.logger`; the two nil-safe sites (SOURCE_CHAN_SIZE parse warning and "forkable hub not ready") keep using the package logger.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ForkableHubhad no per-instance logger — every line (includingprocessing block) used the package-levelbstreamlogger. Components running their own hub (relayer, firehose, tier1, ...) all logged under the samebstreamidentifier, making it impossible to tell which component emitted a given line.Change
logger *zap.Loggerfield toForkableHub, defaulting to the packagezlog.WithLogger(logger)hub option. The logger is propagated to the inner forkable by default, so its block-level lines are attributed to the same component (callers can still override viaforkable.WithLoggerinextraForkableOptions).zlog.toh.logger.. Two nil-safe sites kept on the package logger: theSOURCE_CHAN_SIZEparse warning (hub not yet built) andforkable hub not ready(reachable whenh == nil).Downstream
Callers should pass their component logger:
substreamstier1firehose-corerelayer + firehose app(separate PRs)
Test
go test ./hub/... ./forkable/...✅