Skip to content

Change Datastore.logger type to *logging.Logger#39938

Merged
getvictor merged 4 commits intomainfrom
victor/38889-mysql
Feb 17, 2026
Merged

Change Datastore.logger type to *logging.Logger#39938
getvictor merged 4 commits intomainfrom
victor/38889-mysql

Conversation

@getvictor
Copy link
Copy Markdown
Member

@getvictor getvictor commented Feb 16, 2026

Related issue: Resolves #38889

This is preparatory work before incrementally converting datastore/mysql files to directly use *slog.Logger.
This will be done by using logger.SlogLogger() to get the underlying *slog.Logger

Checklist for submitter

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
    • Changes file already exists from previous PR

Testing

  • Added/updated automated tests
  • QA'd all new/changed functionality manually

Summary by CodeRabbit

  • Chores
    • Updated internal logging infrastructure to use a standardized platform logging package across database and utility components. This consolidates logging dependencies and improves system consistency without affecting user-facing functionality.

@getvictor
Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 16, 2026

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 16, 2026

Walkthrough

This PR migrates the logger dependency across the MySQL datastore layer and related tooling from go-kit/log to an internal logging package located at server/platform/logging. Changes include updating struct fields from log.Logger to *logging.Logger, modifying function signatures in constructors and option builders, replacing imports, and updating logger initialization calls from log.NewNopLogger() and log.NewLogfmtLogger() to their logging package equivalents throughout the MySQL datastore, tests, utilities, and command-line tools.

Possibly related PRs

  • PR 39527: Performs similar logger migration across the codebase, replacing go-kit/log types and usages with *logging.Logger and new constructor methods
  • PR 39729: Switches datastore code to use the server/platform/logging types introduced by the slog migration effort
  • PR 32233: Modifies the Android Datastore struct and constructor, which are also updated in this PR with the logger type change
🚥 Pre-merge checks | ✅ 4 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (14 files):

⚔️ server/datastore/mysql/android_mysql.go (content)
⚔️ server/datastore/mysql/config.go (content)
⚔️ server/datastore/mysql/mysql.go (content)
⚔️ server/datastore/mysql/mysql_test.go (content)
⚔️ server/datastore/mysql/software_test.go (content)
⚔️ server/datastore/mysql/testing_utils.go (content)
⚔️ server/platform/mysql/common.go (content)
⚔️ tools/dbutils/schema_generator.go (content)
⚔️ tools/mdm/apple/applebmapi/main.go (content)
⚔️ tools/mdm/apple/setupexperience/main.go (content)
⚔️ tools/mysql-tests/rds/iam_auth.go (content)
⚔️ website/assets/js/pages/handbook/basic-handbook.page.js (content)
⚔️ website/assets/styles/pages/handbook/basic-handbook.less (content)
⚔️ website/views/pages/handbook/basic-handbook.ejs (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly summarizes the main change: updating the Datastore.logger type from log.Logger to *logging.Logger, which is the core objective of this PR.
Linked Issues check ✅ Passed The PR successfully changes the Datastore.logger type to *logging.Logger across multiple files as preparatory work for slog migration [#38889], fulfilling the stated objective of incrementally converting datastore/mysql to use the new logging package.
Out of Scope Changes check ✅ Passed All changes are directly aligned with converting from go-kit/log to *logging.Logger type. No out-of-scope refactoring or unrelated modifications are present in the changeset.
Description check ✅ Passed The PR description is concise and contains all essential information: related issue number, clear purpose as preparatory work, and checklist items marking completed tasks and non-applicable items.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch victor/38889-mysql
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch victor/38889-mysql
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🤖 Fix all issues with AI agents
Before applying any fix, first verify the finding against the current code and
decide whether a code change is actually needed. If the finding is not valid or
no change is required, do not modify code for that item and briefly explain why
it was skipped.

In `@server/datastore/mysql/testing_utils.go`:
- Line 1024: The test currently passes go-kit's log.NewNopLogger into
activity_bootstrap.New (svc, _ := activity_bootstrap.New(...,
log.NewNopLogger())), which prevents removing the go-kit/log import; in a
follow-up migrate activity_bootstrap.New to accept the project's new logger
type/interface and update this call site to pass the new nop logger (or adapter)
from the project's logging package instead of log.NewNopLogger so you can remove
go-kit/log from testing_utils.go; update the activity_bootstrap.New signature
and any callers (or add a small adapter function) to bridge the old go-kit
logger to the new logger interface.

In `@server/platform/mysql/common.go`:
- Around line 164-177: WithTxx and WithReadOnlyTxx still accept log.Logger while
DBOptions.Logger is now *logging.Logger, creating a mixed-type surface; update
these functions' signatures to accept *logging.Logger (and update any internal
logging calls to use the logging.Logger API) and propagate the type change to
all callers (or add a small adapter that converts *logging.Logger -> log.Logger
if you need incremental rollout); ensure DBOptions.Logger is used consistently
and run tests to catch any mismatched call sites.
🧹 Nitpick comments (2)
🤖 Fix all nitpicks with AI agents
Before applying any fix, first verify the finding against the current code and
decide whether a code change is actually needed. If the finding is not valid or
no change is required, do not modify code for that item and briefly explain why
it was skipped.

In `@server/datastore/mysql/testing_utils.go`:
- Line 1024: The test currently passes go-kit's log.NewNopLogger into
activity_bootstrap.New (svc, _ := activity_bootstrap.New(...,
log.NewNopLogger())), which prevents removing the go-kit/log import; in a
follow-up migrate activity_bootstrap.New to accept the project's new logger
type/interface and update this call site to pass the new nop logger (or adapter)
from the project's logging package instead of log.NewNopLogger so you can remove
go-kit/log from testing_utils.go; update the activity_bootstrap.New signature
and any callers (or add a small adapter function) to bridge the old go-kit
logger to the new logger interface.

In `@server/platform/mysql/common.go`:
- Around line 164-177: WithTxx and WithReadOnlyTxx still accept log.Logger while
DBOptions.Logger is now *logging.Logger, creating a mixed-type surface; update
these functions' signatures to accept *logging.Logger (and update any internal
logging calls to use the logging.Logger API) and propagate the type change to
all callers (or add a small adapter that converts *logging.Logger -> log.Logger
if you need incremental rollout); ensure DBOptions.Logger is used consistently
and run tests to catch any mismatched call sites.
server/platform/mysql/common.go (1)

164-177: WithTxx and WithReadOnlyTxx still use log.Logger — intentional for incremental migration.

These two functions accept log.Logger while DBOptions.Logger was changed to *logging.Logger. This is consistent with the stated incremental migration approach but creates a mixed-type surface within the same file. Worth noting for the next migration phase.

Also applies to: 195-226

🤖 Prompt for AI Agents
Before applying any fix, first verify the finding against the current code and
decide whether a code change is actually needed. If the finding is not valid or
no change is required, do not modify code for that item and briefly explain why
it was skipped.
In `@server/platform/mysql/common.go` around lines 164 - 177, WithTxx and
WithReadOnlyTxx still accept log.Logger while DBOptions.Logger is now
*logging.Logger, creating a mixed-type surface; update these functions'
signatures to accept *logging.Logger (and update any internal logging calls to
use the logging.Logger API) and propagate the type change to all callers (or add
a small adapter that converts *logging.Logger -> log.Logger if you need
incremental rollout); ensure DBOptions.Logger is used consistently and run tests
to catch any mismatched call sites.
server/datastore/mysql/testing_utils.go (1)

1024-1024: Consider migrating activity_bootstrap.New logger parameter in a follow-up.

log.NewNopLogger() (go-kit) is still used here because activity_bootstrap.New hasn't been migrated yet. This is fine for now, but worth tracking so the go-kit/log import can eventually be removed from this file.

🤖 Prompt for AI Agents
Before applying any fix, first verify the finding against the current code and
decide whether a code change is actually needed. If the finding is not valid or
no change is required, do not modify code for that item and briefly explain why
it was skipped.
In `@server/datastore/mysql/testing_utils.go` at line 1024, The test currently
passes go-kit's log.NewNopLogger into activity_bootstrap.New (svc, _ :=
activity_bootstrap.New(..., log.NewNopLogger())), which prevents removing the
go-kit/log import; in a follow-up migrate activity_bootstrap.New to accept the
project's new logger type/interface and update this call site to pass the new
nop logger (or adapter) from the project's logging package instead of
log.NewNopLogger so you can remove go-kit/log from testing_utils.go; update the
activity_bootstrap.New signature and any callers (or add a small adapter
function) to bridge the old go-kit logger to the new logger interface.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR changes the type of the logger field in the MySQL datastore and related components from log.Logger (go-kit) to *logging.Logger (new slog-based logger). This is preparatory work for the incremental migration to slog as described in ADR-0008. The *logging.Logger type implements the log.Logger interface, allowing existing code that uses go-kit logging patterns to continue working unchanged.

Changes:

  • Updated Datastore.logger field type from log.Logger to *logging.Logger
  • Updated DBOptions.Logger field type in server/platform/mysql/common.go
  • Updated AndroidDatastore.logger field type and constructor
  • Replaced all instances of log.NewNopLogger() and log.NewLogfmtLogger() with logging.NewNopLogger() and logging.NewLogfmtLogger() in test files and tools

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
server/datastore/mysql/mysql.go Changed Datastore.logger field type to *logging.Logger and updated default logger creation
server/datastore/mysql/config.go Updated Logger DBOption to accept *logging.Logger instead of log.Logger
server/datastore/mysql/android_mysql.go Changed AndroidDatastore.logger and constructor parameter to use *logging.Logger
server/platform/mysql/common.go Updated DBOptions.Logger field to *logging.Logger type
server/datastore/mysql/testing_utils.go Updated test logger creation to use logging.NewNopLogger() and logging.NewLogfmtLogger()
server/datastore/mysql/mysql_test.go Replaced log.NewNopLogger() with logging.NewNopLogger() in test mocks
server/datastore/mysql/software_test.go Updated test loggers to use new logging package functions
tools/mysql-tests/rds/iam_auth.go Updated logger creation to use logging.NewLogfmtLogger()
tools/mdm/apple/setupexperience/main.go Updated logger creation to use logging.NewLogfmtLogger()
tools/mdm/apple/applebmapi/main.go Updated logger creation to use logging.NewLogfmtLogger()
tools/dbutils/schema_generator.go Updated to use logging.NewNopLogger()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@getvictor getvictor marked this pull request as ready for review February 16, 2026 20:00
@getvictor getvictor requested a review from a team as a code owner February 16, 2026 20:01
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Feb 16, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Well hello there, neighbor! I took a nice careful look through all the changes in this PR, and I'm happy to report that everything looks just wonderful.

This PR cleanly migrates the MySQL datastore layer from go-kit/log to the project's own server/platform/logging package. The changes are mechanical and consistent:

  • log.NewNopLogger()logging.NewNopLogger()
  • kitlog.NewLogfmtLogger()logging.NewLogfmtLogger()
  • log.Logger type → *logging.Logger type ✅
  • platformlogging.DiscardHandler{}slog.DiscardHandler (available in Go 1.24+) ✅
  • level.NewFilter(..., level.AllowDebug())logging.NewLogfmtLogger() (which sets Debug: true) ✅

The architecture test in arch_test.go is properly updated to allow the new logging dependency.

Files Reviewed (11 files)
  • server/datastore/mysql/android_mysql.go
  • server/datastore/mysql/config.go
  • server/datastore/mysql/mysql.go
  • server/datastore/mysql/mysql_test.go
  • server/datastore/mysql/software_test.go
  • server/datastore/mysql/testing_utils.go
  • server/platform/arch_test.go
  • server/platform/mysql/common.go
  • tools/dbutils/schema_generator.go
  • tools/mdm/apple/applebmapi/main.go
  • tools/mdm/apple/setupexperience/main.go
  • tools/mysql-tests/rds/iam_auth.go

# Conflicts:
#	server/datastore/mysql/testing_utils.go
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 16, 2026

Codecov Report

❌ Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.27%. Comparing base (988f0bb) to head (512778f).
⚠️ Report is 28 commits behind head on main.

Files with missing lines Patch % Lines
server/datastore/mysql/testing_utils.go 66.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #39938   +/-   ##
=======================================
  Coverage   66.27%   66.27%           
=======================================
  Files        2439     2439           
  Lines      195476   195478    +2     
  Branches     8654     8654           
=======================================
+ Hits       129542   129559   +17     
+ Misses      54198    54188   -10     
+ Partials    11736    11731    -5     
Flag Coverage Δ
backend 68.07% <77.77%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@getvictor
Copy link
Copy Markdown
Member Author

Hi @iansltx can you take a look at this small cross-functional slog change? I'm trying to spread the slog reviews among other engineers since I'm making a lot of incremental PRs.

@iansltx
Copy link
Copy Markdown
Contributor

iansltx commented Feb 16, 2026

@getvictor There's First Impressions work ahead of this (#39572, #39847, #39873) that I need to review, so you'll want to assign this to someone else.

@getvictor
Copy link
Copy Markdown
Member Author

@dantecatalfamo assigning to you for review since Ian is not available right now

@getvictor getvictor merged commit abaeeec into main Feb 17, 2026
45 checks passed
@getvictor getvictor deleted the victor/38889-mysql branch February 17, 2026 21:29
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.

slog migration (1)

4 participants