mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-07 15:50:28 +00:00
refactor(logging): use the logging package in internal (#1302)
Move the log calls in `internal` onto `logging`, and add what the process-wide logger setup and its tests need: `SetTextFormat` with a line filter for secret masking (replacing `report.MaskingFormatter`), `SetReportCaller`, `SetDefault` and `logtest.SetDefault`. After this only the `logging` package imports logrus. Stacked on https://gitea.com/gitea/runner/pulls/1301. Assisted-by: Codet Co-authored-by: bircni <[email protected]> Reviewed-on: https://gitea.com/gitea/runner/pulls/1302 Reviewed-by: bircni <[email protected]>
This commit is contained in:
1 parent
76110557ab
commit
4e8037a93b
25 files changed
+308
-246
No files matched your search
@@ -12,12 +12,12 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gitea.com/gitea/runner/act/common/logging"
|
||||
"gitea.com/gitea/runner/internal/pkg/metrics"
|
||||
|
||||
"gitea.dev/actionslib/runner/v1/runnerv1connect"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
dto "github.com/prometheus/client_model/go"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/sdk/resource"
|
||||
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
|
||||
@@ -61,7 +61,7 @@ func pushMetrics(exporter *client, res *resource.Resource, gatherer prometheus.G
|
||||
return
|
||||
case <-ticker.C:
|
||||
if err := push(ctx); err != nil && ctx.Err() == nil {
|
||||
log.WithError(err).Warn("OTLP metrics export failed, set OTEL_METRICS_EXPORTER=none to disable it")
|
||||
logging.WithError(err).Warn("OTLP metrics export failed, set OTEL_METRICS_EXPORTER=none to disable it")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gitea.com/gitea/runner/act/common/logging"
|
||||
"gitea.com/gitea/runner/internal/pkg/ver"
|
||||
|
||||
"gitea.dev/actionslib/pkg/model"
|
||||
@@ -28,7 +29,6 @@ import (
|
||||
"github.com/avast/retry-go/v5"
|
||||
"github.com/docker/go-connections/tlsconfig"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
|
||||
@@ -90,7 +90,7 @@ func Setup(ctx context.Context, uuid, name string, gatherer prometheus.Gatherer)
|
||||
compressionKey := otlpKey(signal, "COMPRESSION")
|
||||
compression := os.Getenv(compressionKey)
|
||||
if !slices.Contains([]string{"", "none", "gzip"}, strings.ToLower(compression)) {
|
||||
log.Warnf("ignoring unsupported %s=%q", compressionKey, compression)
|
||||
logging.Warnf("ignoring unsupported %s=%q", compressionKey, compression)
|
||||
}
|
||||
httpClient, err := newHTTPClient(signal)
|
||||
if err != nil {
|
||||
@@ -144,7 +144,7 @@ func exportsOTLP(signal string) bool {
|
||||
case "none":
|
||||
known = true
|
||||
default:
|
||||
log.Warnf("ignoring unsupported %s value %q", key, value)
|
||||
logging.Warnf("ignoring unsupported %s value %q", key, value)
|
||||
}
|
||||
}
|
||||
return otlp || !known
|
||||
@@ -166,7 +166,7 @@ func millis(key string, fallback, zero time.Duration) time.Duration {
|
||||
}
|
||||
ms, err := strconv.ParseInt(value, 10, 32)
|
||||
if err != nil || ms < 0 {
|
||||
log.Warnf("ignoring %s=%q, it must be a non-negative number of milliseconds", key, value)
|
||||
logging.Warnf("ignoring %s=%q, it must be a non-negative number of milliseconds", key, value)
|
||||
return fallback
|
||||
}
|
||||
return cmp.Or(time.Duration(ms)*time.Millisecond, zero)
|
||||
|
||||
Reference in new issue
Block a user