logger

package
v0.22.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DCP_DIAGNOSTICS_LOG_FOLDER = "DCP_DIAGNOSTICS_LOG_FOLDER" // Folder to write diagnostics logs to (defaults to a temp folder)
	DCP_DIAGNOSTICS_LOG_LEVEL  = "DCP_DIAGNOSTICS_LOG_LEVEL"  // Log level to include in diagnostics logs (defaults to none)
	DCP_LOG_SOCKET             = "DCP_LOG_SOCKET"             // Unix socket to write console logs to instead of stderr
	DCP_LOG_FILE_NAME_SUFFIX   = "DCP_LOG_FILE_NAME_SUFFIX"   // Suffix to append to the log file name (defaults to process ID)
	DCP_LOG_SESSION_ID         = "DCP_LOG_SESSION_ID"         // Session ID to include in log names

	DCP_EPOCH = 1665705600 // DCP epoch is the unix timestamp at the start of the day UTC time of the first commit to the DCP repo (2022-10-14T00:00:00.000Z)

	// The timestamp format used in logs (ISO8601)
	LogTimestampFormat = "2006-01-02T15:04:05.000Z0700"

	MacOsProcErrorLogFilter = "Could not get process start time, could not read \"/proc\": stat /proc: no such file or directory"
)
View Source
const (
	// This values acts as a special key for any logger that has a resource sink enabled. If the first argument to WithValues is this key, the second argument
	// will be treated as a resource log stream ID. In this case neither of the first two arguments will be included in the final log entries, but the resource
	// sink will track the resource ID value and use it to route a copy of log entries to a separate log file named based on the resource ID (i.e. resource-<resource_id>.log).
	// This log file will contain only the log entries partaining to that specific resource ID, allowing system logs pertaining to a given resource to be retrieved in isolation.
	RESOURCE_LOG_STREAM_ID = "resource_log_stream_id"
)

Variables

This section is empty.

Functions

func BoolPtrValToString

func BoolPtrValToString(p *bool) string

func EnsureDiagnosticsLogsFolder

func EnsureDiagnosticsLogsFolder() (string, error)

Returns the folder to write diagnostics logs and perf traces to.

func FriendlyErrorString

func FriendlyErrorString(err error) string

func FriendlyMetav1Timestamp

func FriendlyMetav1Timestamp(ts metav1.MicroTime) string

func FriendlyString

func FriendlyString(s string) string

func FriendlyStringMap

func FriendlyStringMap(m map[string]string) string

func FriendlyStringSlice

func FriendlyStringSlice(s []string) string

func FriendlyTimestamp

func FriendlyTimestamp(ts time.Time) string

func GetDiagnosticsLogFolder

func GetDiagnosticsLogFolder() string

Returns the folder for diagnostics logs (and perf traces).

func GetDiagnosticsLogLevel

func GetDiagnosticsLogLevel() (zapcore.Level, error)

func GetResourceLogPath

func GetResourceLogPath(resourceId string) string

func GetVerbosityArg

func GetVerbosityArg(fs *pflag.FlagSet) string

func IntPtrValToString

func IntPtrValToString[T int32 | int64, PT *T](p PT) string

func ProcessMomentHash

func ProcessMomentHash(flavor MomentHashFlavor) string

Computes a reasonably-unique, not-too-long value that represents "this moment in time, from the perspective of the current process". It is a hash of current timestamp and current process ID.

func ReleaseAllResourceLogs

func ReleaseAllResourceLogs()

func ReleaseResourceLog

func ReleaseResourceLog(resourceId string)

func SessionId

func SessionId() string

func StringToLevel

func StringToLevel(value string, defaultLevel zapcore.Level) (zapcore.Level, error)

func WithSessionId

func WithSessionId(cmd *exec.Cmd)

Types

type LevelFlagValue

type LevelFlagValue struct {
	// contains filtered or unexported fields
}

func GetLevelFlagValue

func GetLevelFlagValue(fs *pflag.FlagSet) (*LevelFlagValue, bool)

func NewLevelFlagValue

func NewLevelFlagValue(onLevelAvailable func(zapcore.Level)) LevelFlagValue

func (*LevelFlagValue) Set

func (lfv *LevelFlagValue) Set(flagValue string) error

func (*LevelFlagValue) String

func (lfv *LevelFlagValue) String() string

func (*LevelFlagValue) Type

func (_ *LevelFlagValue) Type() string

type Logger

type Logger struct {
	logr.Logger
	// contains filtered or unexported fields
}

func New

func New(name string) *Logger

New logger implementation to handle logging to stdout/debug log

func (*Logger) AddLevelFlag

func (l *Logger) AddLevelFlag(fs *pflag.FlagSet)

Add verbosity flag to enable setting stdout log levels

func (*Logger) Flush

func (l *Logger) Flush()

func (*Logger) SetLevel

func (l *Logger) SetLevel(level zapcore.Level)

func (*Logger) WithFilterSink

func (l *Logger) WithFilterSink(filter string, maxLife uint32) *Logger

func (*Logger) WithName

func (l *Logger) WithName(name string) *Logger

func (*Logger) WithResourceSink

func (l *Logger) WithResourceSink() *Logger

type MomentHashFlavor

type MomentHashFlavor int
const (
	PlainHash MomentHashFlavor = iota
	TimeSortableHash
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL