Documentation
¶
Overview ¶
* @license * Copyright 2025 Dynatrace LLC * 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.
Index ¶
- Constants
- func CoordinateAttr(coordinate coordinate.Coordinate) slog.Attr
- func Debug(msg string, a ...interface{})
- func DebugContext(ctx context.Context, msg string, a ...interface{})
- func EnvironmentAttr(environment, group string) slog.Attr
- func Error(msg string, a ...interface{})
- func ErrorAttr(err error) slog.Attr
- func ErrorContext(ctx context.Context, msg string, a ...interface{})
- func ErrorFilePath() string
- func Fatal(msg string, a ...interface{})
- func FatalContext(ctx context.Context, msg string, a ...interface{})
- func Info(msg string, a ...interface{})
- func InfoContext(ctx context.Context, msg string, a ...interface{})
- func LogFilePath() string
- func MemStatFilePath() string
- func PrepareLogFiles(ctx context.Context, fs afero.Fs, enableMemstatLogging bool) (logFile afero.File, errFile afero.File, err error)
- func PrepareLogging(ctx context.Context, fs afero.Fs, verbose bool, loggerSpy io.Writer, ...)
- func TypeAttr[X ~string](t X) slog.Attr
- func Warn(msg string, a ...interface{})
- func WarnContext(ctx context.Context, msg string, a ...interface{})
- type ContextHandler
- type CtxGraphComponentId
- type CtxKeyAccount
- type CtxKeyCoord
- type CtxKeyEnv
- type CtxValEnv
- type CtxValGraphComponentId
- type Slogger
- func (w *Slogger) Debug(msg string, a ...interface{})
- func (w *Slogger) DebugContext(ctx context.Context, msg string, a ...interface{})
- func (w *Slogger) Error(msg string, a ...interface{})
- func (w *Slogger) ErrorContext(ctx context.Context, msg string, a ...interface{})
- func (w *Slogger) Fatal(msg string, a ...any)
- func (w *Slogger) FatalContext(ctx context.Context, msg string, a ...any)
- func (w *Slogger) Info(msg string, a ...interface{})
- func (w *Slogger) InfoContext(ctx context.Context, msg string, a ...interface{})
- func (w *Slogger) SLogger() *slog.Logger
- func (w *Slogger) Warn(msg string, a ...interface{})
- func (w *Slogger) WarnContext(ctx context.Context, msg string, a ...interface{})
- func (w *Slogger) With(attributes ...any) *Slogger
- type TeeHandler
Constants ¶
const ( LogDirectory = ".logs" LogFileTimestampPrefixFormat = "20060102-150405" )
Variables ¶
This section is empty.
Functions ¶
func CoordinateAttr ¶ added in v2.24.0
func CoordinateAttr(coordinate coordinate.Coordinate) slog.Attr
CoordinateAttr returns an attribute containing information taken from the provided coordinate.
func DebugContext ¶ added in v2.24.0
func EnvironmentAttr ¶ added in v2.24.0
EnvironmentAttr returns an attribute containing environment information for structured logging.
func ErrorAttr ¶ added in v2.24.0
ErrorAttr returns an attribute containing error information for structured logging.
func ErrorContext ¶ added in v2.24.0
func ErrorFilePath ¶ added in v2.8.1
func ErrorFilePath() string
ErrorFilePath returns the path of an error logfile for the current execution time - depending on when this function is called such a file may not yet exist
func FatalContext ¶ added in v2.24.0
func InfoContext ¶ added in v2.24.0
func LogFilePath ¶ added in v2.8.1
func LogFilePath() string
LogFilePath returns the path of a logfile for the current execution time - depending on when this function is called such a file may not yet exist
func MemStatFilePath ¶ added in v2.16.0
func MemStatFilePath() string
MemStatFilePath returns the full path of an memory statistics log file for the current execution time - if no stats are written (yet) no file may exist at this path.
func PrepareLogFiles ¶ added in v2.24.0
func PrepareLogFiles(ctx context.Context, fs afero.Fs, enableMemstatLogging bool) (logFile afero.File, errFile afero.File, err error)
prepareLogFiles tries to create a LogDirectory (if none exists) and a file each to write all logs and filtered error logs to. As errors in preparing log files are viewed as optional for the logger setup using this method, partial data may be returned in case of errors. If log directory or logFile creation fails, no log files are returned. If errLog creation fails, a valid logFile is still being returned with an error.
func PrepareLogging ¶
func PrepareLogging(ctx context.Context, fs afero.Fs, verbose bool, loggerSpy io.Writer, fileLogging bool, enableMemstatLogging bool)
PrepareLogging sets up the default slog.Logger using the specified options.
func TypeAttr ¶ added in v2.24.0
TypeAttr returns an attribute containing information about a config type. This is used in cases where no full coordinate exists, but only a config type is known - for example in download or deletion.
func WarnContext ¶ added in v2.24.0
Types ¶
type ContextHandler ¶ added in v2.24.0
type ContextHandler struct {
// contains filtered or unexported fields
}
ContextHandler is an implementation of slog.Handler that extracts attributes from the context provided in a log calls, adds them to the record and delegates to the specified handler.
func NewContextHandler ¶ added in v2.24.0
func NewContextHandler(h slog.Handler) *ContextHandler
NewContextHandler creates a new ContextHandler wrapping the specified handler.
func (*ContextHandler) Enabled ¶ added in v2.24.0
Enabled returns true iff the wrapped handler in enabled for the specified level.
func (*ContextHandler) Handle ¶ added in v2.24.0
Handle adds attributes extracted from the context before calling Handle on the wrapped Handler.
type CtxGraphComponentId ¶ added in v2.6.0
type CtxGraphComponentId struct{}
CtxGraphComponentId context key used for correlating logs that belong to deployment of a sub graph
type CtxKeyAccount ¶ added in v2.10.0
type CtxKeyAccount struct{}
CtxKeyAccount context key used for contextual account information
type CtxKeyCoord ¶
type CtxKeyCoord struct{}
CtxKeyCoord context key used for contextual coordinate information
type CtxKeyEnv ¶
type CtxKeyEnv struct{}
CtxKeyEnv context key used for contextual environment information
type CtxValGraphComponentId ¶ added in v2.6.0
type CtxValGraphComponentId int
CtxValGraphComponentId context value used for correlating logs that belong to deployment of a sub graph
type Slogger ¶ added in v2.24.0
Slogger is a simple logger that wraps an `slog.Logger`.
func With ¶ added in v2.24.0
With adds additional [attribute.Attr] for structured logs It accepts vararg attributes and should not be called more than once per log call
func (*Slogger) DebugContext ¶ added in v2.24.0
func (*Slogger) ErrorContext ¶ added in v2.24.0
func (*Slogger) FatalContext ¶ added in v2.24.0
func (*Slogger) InfoContext ¶ added in v2.24.0
func (*Slogger) WarnContext ¶ added in v2.24.0
type TeeHandler ¶ added in v2.24.0
type TeeHandler struct {
// contains filtered or unexported fields
}
TeeHandler implements the Handler interface by delegating to one or more handlers.
func NewTeeHandler ¶ added in v2.24.0
func NewTeeHandler(h ...slog.Handler) *TeeHandler
NewTeeHandler creates a new TeeHandler that delegates handling to the specified handlers.
func (*TeeHandler) Enabled ¶ added in v2.24.0
Enabled returns true if one or more handlers is enabled for the given log level.