mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-10-03 01:15:11 -04:00
Point the go-micro.dev/v4 replace at the latest main-v4 maintenance branch commit in butonic/go-micro (cd412c15) instead of the v4.11.3 tag. The new base is upstream v4.11.1 plus the registry cache node-TTL fixes (upstream #2715, #2736, #2740), the concurrent map access fix (upstream #2794), plus further dependency updates and test fixes on the maintenance branch. The branch also modernizes go-micro's own go.mod (go 1.26, lego, dario.cat/mergo v1, x/deque v2, ...), and MVS pulls the aligned versions into this module: lego v4.35.2 -> lego/v5 v5.5.2, go-jose/go-jose/v4 -> v4.1.5, gofrs/flock -> v0.13.1, mattn/go-isatty -> v0.0.24, go.uber.org/zap -> v1.28.0, x/net -> 0.59.0, miekg/dns -> 1.1.73, moby api/client, ProtonMail/go-crypto -> 1.5.2, klauspost/compress -> 1.20.1, gorilla/handlers -> 1.5.2, gobwas/ws -> 1.4.0, nxadm/tail -> 1.4.11, ... Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
/*
|
|
Copyright The containerd Authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package log
|
|
|
|
import (
|
|
"io"
|
|
"log/slog"
|
|
"sync"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
lslog "github.com/sirupsen/logrus/hooks/slog"
|
|
)
|
|
|
|
// slogOut is used to set the slog logger when setting output format.
|
|
var slogOut io.Writer
|
|
|
|
// slogOnce guards UseSlog so repeated calls do not stack up hooks or
|
|
// reset slogOut to the discard writer installed on the first call.
|
|
var slogOnce sync.Once
|
|
|
|
func UseSlog() {
|
|
slogOnce.Do(func() {
|
|
L.Logger.SetNoLock()
|
|
L.Logger.AddHook(slogHook{})
|
|
slogOut = L.Logger.Out
|
|
|
|
// Disable logrus formatting and output, as both are handled by slog.
|
|
L.Logger.SetFormatter(discardFormatter{})
|
|
L.Logger.SetOutput(io.Discard)
|
|
})
|
|
}
|
|
|
|
type slogHook struct{}
|
|
|
|
func (slogHook) Levels() []logrus.Level {
|
|
return logrus.AllLevels
|
|
}
|
|
|
|
func (slogHook) Fire(entry *logrus.Entry) error {
|
|
return lslog.NewHook(slog.Default(), nil).Fire(entry)
|
|
}
|
|
|
|
// loggerLevel exposes the current Logrus logger level as a slog.Leveler.
|
|
type loggerLevel struct{}
|
|
|
|
func (loggerLevel) Level() slog.Level {
|
|
return lslog.Level(L.Logger.GetLevel()).Level()
|
|
}
|
|
|
|
type discardFormatter struct{}
|
|
|
|
func (discardFormatter) Format(*logrus.Entry) ([]byte, error) { return nil, nil }
|