Transitioned activity bounded context to slog. (#39773)

<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #38889 

# Checklist for submitter

- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
  - Changes file already exists

## Testing

- [x] Added/updated automated tests
- [x] QA'd all new/changed functionality manually


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
* Updated internal logging infrastructure across activity service
modules to enhance code consistency and maintainability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Victor Lyuboslavsky
2026-02-16 14:23:36 -06:00
committed by GitHub
parent 0e729604ed
commit 988f0bbcc6
9 changed files with 29 additions and 22 deletions
@@ -3,12 +3,14 @@ package testutils
import (
"encoding/json"
"log/slog"
"testing"
"time"
"github.com/fleetdm/fleet/v4/server/platform/logging"
common_mysql "github.com/fleetdm/fleet/v4/server/platform/mysql"
mysql_testing_utils "github.com/fleetdm/fleet/v4/server/platform/mysql/testing_utils"
"github.com/go-kit/log"
kitlog "github.com/go-kit/log"
"github.com/jmoiron/sqlx"
"github.com/stretchr/testify/require"
)
@@ -16,7 +18,7 @@ import (
// TestDB holds the database connection for tests.
type TestDB struct {
DB *sqlx.DB
Logger log.Logger
Logger *slog.Logger
}
// SetupTestDB creates a test database with the Fleet schema loaded.
@@ -36,7 +38,7 @@ func SetupTestDB(t *testing.T, testNamePrefix string) *TestDB {
return &TestDB{
DB: db,
Logger: log.NewNopLogger(),
Logger: slog.New(logging.DiscardHandler{}),
}
}
@@ -48,7 +50,7 @@ func (tdb *TestDB) Conns() *common_mysql.DBConnections {
// TruncateTables clears the tables used by activity bounded context.
func (tdb *TestDB) TruncateTables(t *testing.T) {
t.Helper()
mysql_testing_utils.TruncateTables(t, tdb.DB, tdb.Logger, nil, "host_activities", "activities", "hosts", "users")
mysql_testing_utils.TruncateTables(t, tdb.DB, kitlog.NewNopLogger(), nil, "host_activities", "activities", "hosts", "users")
}
// InsertUser creates a user in the database and returns the user ID.