mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-04-22 08:09:13 -04:00
tidy
This commit is contained in:
parent
d80383d993
commit
972f832a6e
@ -11,12 +11,12 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
"log/slog"
|
||||
|
||||
"github.com/edgelesssys/constellation/v2/bootstrapper/initproto"
|
||||
"github.com/edgelesssys/constellation/v2/internal/atls"
|
||||
|
@ -9,12 +9,12 @@ package joinclient
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"net"
|
||||
"strconv"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
"log/slog"
|
||||
|
||||
"github.com/edgelesssys/constellation/v2/internal/cloud/metadata"
|
||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||
|
@ -9,10 +9,10 @@ package kubernetes
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"net"
|
||||
"strconv"
|
||||
"testing"
|
||||
"log/slog"
|
||||
|
||||
"github.com/edgelesssys/constellation/v2/bootstrapper/internal/kubernetes/k8sapi"
|
||||
"github.com/edgelesssys/constellation/v2/bootstrapper/internal/kubernetes/kubewaiter"
|
||||
|
@ -10,10 +10,10 @@ package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"math"
|
||||
"os"
|
||||
"testing"
|
||||
"log/slog"
|
||||
"os"
|
||||
|
||||
"github.com/edgelesssys/constellation/v2/disk-mapper/internal/diskencryption"
|
||||
"github.com/martinjungblut/go-cryptsetup"
|
||||
|
@ -12,13 +12,13 @@ import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
"testing"
|
||||
"log/slog"
|
||||
|
||||
"github.com/bazelbuild/rules_go/go/runfiles"
|
||||
"github.com/edgelesssys/constellation/v2/disk-mapper/internal/diskencryption"
|
||||
|
@ -5,6 +5,7 @@ go_library(
|
||||
srcs = [
|
||||
"cmdline.go",
|
||||
"grpclogger.go",
|
||||
"levelhandler.go",
|
||||
"log.go",
|
||||
],
|
||||
importpath = "github.com/edgelesssys/constellation/v2/internal/logger",
|
||||
|
@ -26,14 +26,14 @@ func replaceGRPCLogger(log *slog.Logger) {
|
||||
}
|
||||
|
||||
func (l *grpcLogger) log(level slog.Level, args ...interface{}) {
|
||||
var pcs [1]uintptr
|
||||
var pcs [1]uintptr
|
||||
runtime.Callers(3, pcs[:])
|
||||
r := slog.NewRecord(time.Now(), slog.LevelInfo, fmt.Sprint(args...), pcs[0])
|
||||
_ = l.logger.Handler().Handle(context.Background(), r)
|
||||
}
|
||||
|
||||
func (l *grpcLogger) logf(level slog.Level, format string, args ...interface{}) {
|
||||
var pcs [1]uintptr
|
||||
var pcs [1]uintptr
|
||||
runtime.Callers(3, pcs[:])
|
||||
r := slog.NewRecord(time.Now(), slog.LevelInfo, fmt.Sprintf(format, args...), pcs[0])
|
||||
_ = l.logger.Handler().Handle(context.Background(), r)
|
||||
@ -45,53 +45,53 @@ type grpcLogger struct {
|
||||
}
|
||||
|
||||
func (l *grpcLogger) Info(args ...interface{}) {
|
||||
l.log(slog.LevelInfo, args...)
|
||||
l.log(slog.LevelInfo, args...)
|
||||
}
|
||||
|
||||
func (l *grpcLogger) Infoln(args ...interface{}) {
|
||||
l.log(slog.LevelInfo, args...)
|
||||
l.log(slog.LevelInfo, args...)
|
||||
}
|
||||
|
||||
func (l *grpcLogger) Infof(format string, args ...interface{}) {
|
||||
l.logf(slog.LevelInfo, format, args...)
|
||||
l.logf(slog.LevelInfo, format, args...)
|
||||
}
|
||||
|
||||
func (l *grpcLogger) Warning(args ...interface{}) {
|
||||
l.log(slog.LevelWarn, args...)
|
||||
l.log(slog.LevelWarn, args...)
|
||||
}
|
||||
|
||||
func (l *grpcLogger) Warningln(args ...interface{}) {
|
||||
l.log(slog.LevelWarn, args...)
|
||||
l.log(slog.LevelWarn, args...)
|
||||
}
|
||||
|
||||
func (l *grpcLogger) Warningf(format string, args ...interface{}) {
|
||||
l.logf(slog.LevelWarn, format, args...)
|
||||
l.logf(slog.LevelWarn, format, args...)
|
||||
}
|
||||
|
||||
func (l *grpcLogger) Error(args ...interface{}) {
|
||||
l.log(slog.LevelError, args...)
|
||||
l.log(slog.LevelError, args...)
|
||||
}
|
||||
|
||||
func (l *grpcLogger) Errorln(args ...interface{}) {
|
||||
l.log(slog.LevelError, args...)
|
||||
l.log(slog.LevelError, args...)
|
||||
}
|
||||
|
||||
func (l *grpcLogger) Errorf(format string, args ...interface{}) {
|
||||
l.logf(slog.LevelError, format, args...)
|
||||
l.logf(slog.LevelError, format, args...)
|
||||
}
|
||||
|
||||
func (l *grpcLogger) Fatal(args ...interface{}) {
|
||||
l.log(slog.LevelError, args...)
|
||||
l.log(slog.LevelError, args...)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (l *grpcLogger) Fatalln(args ...interface{}) {
|
||||
l.log(slog.LevelError, args...)
|
||||
l.log(slog.LevelError, args...)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (l *grpcLogger) Fatalf(format string, args ...interface{}) {
|
||||
l.logf(slog.LevelError, format, args...)
|
||||
l.logf(slog.LevelError, format, args...)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
@ -4,12 +4,11 @@ Copyright (c) Edgeless Systems GmbH
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
|
||||
package logger
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"context"
|
||||
"context"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
// LevelHandler copied from the official LevelHandler example in the slog package documentation.
|
||||
|
@ -19,7 +19,7 @@ You can create a new logger with a new log level by creating a new slog.Logger w
|
||||
and passing the handler of the other logger. As an example, if you have a slog.Logger named `log` you can create a
|
||||
new logger with an increased log level (here slog.LevelWarn) like this:
|
||||
|
||||
slog.New(logger.NewLevelHandler(slog.LevelWarn, log.Handler()))
|
||||
slog.New(logger.NewLevelHandler(slog.LevelWarn, log.Handler()))
|
||||
*/
|
||||
package logger
|
||||
|
||||
@ -90,13 +90,13 @@ func middlewareLogger(l *slog.Logger) logging.Logger {
|
||||
|
||||
var pcs [1]uintptr
|
||||
runtime.Callers(2, pcs[:]) // skip [Callers, LoggerFunc]
|
||||
level := slog.LevelDebug
|
||||
level := slog.LevelDebug
|
||||
|
||||
switch lvl {
|
||||
case logging.LevelDebug:
|
||||
break
|
||||
break
|
||||
case logging.LevelInfo:
|
||||
level = slog.LevelInfo
|
||||
level = slog.LevelInfo
|
||||
case logging.LevelWarn:
|
||||
level = slog.LevelWarn
|
||||
case logging.LevelError:
|
||||
@ -105,13 +105,13 @@ func middlewareLogger(l *slog.Logger) logging.Logger {
|
||||
panic(fmt.Sprintf("unknown level %v", lvl))
|
||||
}
|
||||
|
||||
r := slog.NewRecord(time.Now(), level, fmt.Sprintf(msg, fields...), pcs[0])
|
||||
r := slog.NewRecord(time.Now(), level, fmt.Sprintf(msg, fields...), pcs[0])
|
||||
_ = l.Handler().Handle(context.Background(), r)
|
||||
})
|
||||
}
|
||||
|
||||
func NewTest(t * testing.T) *slog.Logger {
|
||||
return slog.New(slog.NewTextHandler(testWriter{t: t}, nil))
|
||||
func NewTest(t *testing.T) *slog.Logger {
|
||||
return slog.New(slog.NewTextHandler(testWriter{t: t}, nil))
|
||||
}
|
||||
|
||||
// TestWriter is a writer to a testing.T used in tests for logging with slog.
|
||||
|
@ -8,8 +8,8 @@ package amdkds
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"testing"
|
||||
"log/slog"
|
||||
|
||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||
"github.com/edgelesssys/constellation/v2/joinservice/internal/certcache/amdkds/testdata"
|
||||
|
Loading…
x
Reference in New Issue
Block a user