mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-29 22:06:38 +08:00
43dc97e48c
- Moved cmd/, core/, plugins/, pkg/, downstream/, and main.go into backend/ directory - Batch updated all Go source files to import github.com/Rain-kl/Wavelet/backend/... - Updated Makefile, scripts/swagger.sh, architecture guards, and platform skills - Passed all quality gates (100% tests, 0 lint issues, clean build)
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package logger_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/Rain-kl/Wavelet/backend/core"
|
|
"github.com/Rain-kl/Wavelet/backend/core/contracts"
|
|
"github.com/Rain-kl/Wavelet/backend/plugins/infra/logger"
|
|
)
|
|
|
|
func TestLoggerPluginOperations(t *testing.T) {
|
|
p := logger.New()
|
|
assert.Equal(t, "logger", p.Name())
|
|
|
|
ctx := core.NewContext(context.Background())
|
|
require.NoError(t, p.Apply(ctx))
|
|
|
|
svc, err := core.Inject[contracts.LoggerService](ctx)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, svc)
|
|
|
|
testCtx := context.Background()
|
|
|
|
svc.Debug(testCtx, "debug msg", "key", "val")
|
|
svc.Info(testCtx, "info msg", "user", 1)
|
|
svc.Warn(testCtx, "warn msg", "odd_field")
|
|
svc.Error(testCtx, "error msg")
|
|
|
|
svc.Debugf(testCtx, "debug %s", "formatted")
|
|
svc.Infof(testCtx, "info %d", 100)
|
|
svc.Warnf(testCtx, "warn %v", true)
|
|
svc.Errorf(testCtx, "error %s", "fail")
|
|
|
|
withLogger := svc.With("trace", "t-123", "span", "s-456")
|
|
require.NotNil(t, withLogger)
|
|
withLogger.Info(testCtx, "enriched message")
|
|
}
|