Skip to content

feat(log): support installing a custom logger via SetLogger#436

Open
Kybxd wants to merge 1 commit into
masterfrom
feat/custom-logger
Open

feat(log): support installing a custom logger via SetLogger#436
Kybxd wants to merge 1 commit into
masterfrom
feat/custom-logger

Conversation

@Kybxd

@Kybxd Kybxd commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

What

Add log.SetLogger / tableau.SetLogger to let callers plug in their own Printf-style logger (e.g. *zap.SugaredLogger, or a thin adapter around slog/logrus) as tableau's log destination, via a new customdriver.

Details

  • New log/driver/customdriver package: wraps a minimal Logger interface (Debugf/Infof/Warnf/Errorf/DPanicf/Panicf/Fatalf) as a driver.Driver, normalizing Xxx/Xxxf/Xxxw calls into a single formatted message.
  • log.SetLogger(logger): installs the custom driver and marks that a custom logger is active.
  • log.Init(opts): once a custom logger has been installed via SetLogger, subsequent Init calls (triggered internally by GenProto/GenConf) no longer override the custom driver; they only update the log level used for LevelEnabled.
  • Rename the built-in Logger struct to sugaredLogger to avoid a naming collision with the new exported Logger interface.
  • tableau.SetLogger exposes the same capability at the top-level package.
  • Trim a debug log in load.go that previously printed the entire patched message via %s, which could produce excessive output for large messages.

Tests

  • Added log/setlogger_test.go covering SetLogger behavior.
  • Updated log/log_test.go / log/logger_test.go for the Logger -> sugaredLogger rename.

Add log.SetLogger / tableau.SetLogger to let callers plug in their own
Printf-style logger (e.g. *zap.SugaredLogger, or a thin adapter around
slog/logrus) as tableau's log destination, via a new customdriver.

Once installed, subsequent log.Init calls (triggered internally by
GenProto/GenConf) no longer override the custom driver, only updating
the log level used for LevelEnabled.

Also rename the built-in Logger struct to sugaredLogger to avoid
naming collision with the new exported Logger interface, and trim a
debug log in load.go that printed the entire patched message via %s.
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedJul 9, 2026, 12:46 PM

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 8.64198% with 74 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.19%. Comparing base (75844f4) to head (01c3012).

Files with missing lines Patch % Lines
log/driver/customdriver/customdriver.go 0.00% 44 Missing ⚠️
log/logger.go 13.63% 19 Missing ⚠️
log/log.go 30.76% 7 Missing and 2 partials ⚠️
tableau.go 0.00% 2 Missing ⚠️

❌ Your project check has failed because the head coverage (60.19%) is below the target coverage (63.00%). You can increase the head coverage or adjust the target coverage.

❗ There is a different number of reports uploaded between BASE (75844f4) and HEAD (01c3012). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (75844f4) HEAD (01c3012)
4 2
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #436       +/-   ##
===========================================
- Coverage   75.57%   60.19%   -15.39%     
===========================================
  Files          88       83        -5     
  Lines        9515     9089      -426     
===========================================
- Hits         7191     5471     -1720     
- Misses       1749     2949     +1200     
- Partials      575      669       +94     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant