mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #40054 # Checklist for submitter - [ ] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. - Changes present in previous PR ## 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 ## Release Notes * **Refactor** * Updated internal logging infrastructure to use context-aware logging methods throughout the system, improving context propagation for better debugging and observability while maintaining existing log coverage and behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
36 lines
730 B
Go
36 lines
730 B
Go
package logging
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
|
|
nanodep_log "github.com/fleetdm/fleet/v4/server/mdm/nanodep/log"
|
|
)
|
|
|
|
// NanoDEPLogger is a logger adapter for nanodep.
|
|
type NanoDEPLogger struct {
|
|
ctx context.Context
|
|
logger *slog.Logger
|
|
}
|
|
|
|
func NewNanoDEPLogger(ctx context.Context, logger *slog.Logger) *NanoDEPLogger {
|
|
return &NanoDEPLogger{
|
|
ctx: ctx,
|
|
logger: logger,
|
|
}
|
|
}
|
|
|
|
func (l *NanoDEPLogger) Info(keyvals ...any) {
|
|
l.logger.InfoContext(l.ctx, "", keyvals...)
|
|
}
|
|
|
|
func (l *NanoDEPLogger) Debug(keyvals ...any) {
|
|
l.logger.DebugContext(l.ctx, "", keyvals...)
|
|
}
|
|
|
|
func (l *NanoDEPLogger) With(keyvals ...any) nanodep_log.Logger {
|
|
return &NanoDEPLogger{
|
|
ctx: l.ctx,
|
|
logger: l.logger.With(keyvals...),
|
|
}
|
|
}
|