Documentation ¶
Index ¶
- Constants
- Variables
- func FieldCluster(cluster string) string
- func FieldComponent(component string) string
- func FieldCount(count int) string
- func FieldDumpPipeline(dumpPipeline string) string
- func FieldIngestorPipeline(ingestorPipeline string) string
- func FieldK8sType(k8sType string) string
- func FieldNodeType(nodeType string) string
- func FieldRunID(runID string) string
- func FieldService(service string) string
- func FieldTeam(team string) string
- func FieldVertexType(vertexType string) string
- func GetClusterFromContext(ctx context.Context) string
- func GetComponentFromContext(ctx context.Context) string
- func GetRunIDFromContext(ctx context.Context) string
- func InitLogger()
- func NewKeyValueEncoder(cfg zapcore.EncoderConfig) (zapcore.Encoder, error)
- func SpanSetDefaultField(ctx context.Context, span ddtrace.Span)
- type Field
- func Base64(key string, value []byte) Field
- func Bool(key string, value bool) Field
- func Byte(key string, value byte) Field
- func Bytes(key string, value []byte, limit int) Field
- func Dur(key string, value time.Duration, truncate ...time.Duration) Field
- func Duration(key string, value time.Duration) Field
- func ErrorField(err error) Field
- func ErrorWithStackField(err error) Field
- func Float(key string, val float64, fmt string) Field
- func Float32(key string, value float32) Field
- func Float64(key string, val float64) Field
- func Int(key string, value int) Field
- func Int32(key string, value int32) Field
- func Int32s(key string, value []int32) Field
- func Int64(key string, value int64) Field
- func Int64s(key string, value []int64) Field
- func Ints(key string, value []int) Field
- func Msec(key string, dur time.Duration) Field
- func NamedError(key string, err error) Field
- func Object(key string, value interface{}) Field
- func Percent(key string, part, whole float64) Field
- func PercentInt(key string, part, whole int) Field
- func RichError(err error) Field
- func Skip() Field
- func String(key, value string) Field
- func Stringer(key string, value fmt.Stringer) Field
- func Stringers[T fmt.Stringer](key string, value []T) Field
- func Stringf(key, format string, args ...interface{}) Field
- func Strings(key string, value []string) Field
- func StructuredObject(key string, value zapcore.ObjectMarshaler) Field
- func Time(key string, value time.Time) Field
- func Uint(key string, value uint) Field
- func Uint32(key string, value uint32) Field
- func Uint32s(key string, value []uint32) Field
- func Uint64(key string, value uint64) Field
- func Uint64s(key string, value []uint64) Field
- func Uints(key string, value []uint) Field
- type KubehoundLogger
- type Level
- type LoggerI
- type UnwrapJoin
- type UnwrapMultierror
Constants ¶
const ( FieldK8sTypeKey = "k8s_type" FieldCountKey = "count" FieldNodeTypeKey = "node_type" FieldVertexTypeKey = "vertex_type" FieldClusterKey = "cluster" FieldComponentKey = "component" FieldRunIDKey = "run_id" FieldTeamKey = "team" FieldServiceKey = "service" FieldAppKey = "app" FieldIngestorPipelineKey = "ingestor_pipeline" FieldDumpPipelineKey = "dump_pipeline" FieldPathKey = "path" FieldEntityKey = "entity" )
const ( ContextFieldRunID contextKey = iota ContextFieldCluster ContextFieldComponent )
const DefaultLevel = LevelInfo
DefaultLevel is the logging level if nothing is configured.
Variables ¶
var (
DefaultRemovedFields = []string{FieldTeamKey, FieldServiceKey, FieldAppKey, FieldRunIDKey, FieldClusterKey, FieldComponentKey, spanIDKey, traceIDKey}
)
Functions ¶
func FieldCluster ¶ added in v1.6.0
func FieldComponent ¶ added in v1.6.0
func FieldCount ¶ added in v1.6.0
func FieldDumpPipeline ¶ added in v1.6.0
func FieldIngestorPipeline ¶ added in v1.6.0
func FieldK8sType ¶ added in v1.6.0
func FieldNodeType ¶ added in v1.6.0
func FieldRunID ¶ added in v1.6.0
func FieldService ¶ added in v1.6.0
func FieldVertexType ¶ added in v1.6.0
func GetClusterFromContext ¶ added in v1.6.0
func GetComponentFromContext ¶ added in v1.6.0
func GetRunIDFromContext ¶ added in v1.6.0
func InitLogger ¶ added in v1.6.0
func InitLogger()
func NewKeyValueEncoder ¶ added in v1.6.0
func NewKeyValueEncoder(cfg zapcore.EncoderConfig) (zapcore.Encoder, error)
NewKeyValueEncoder creates a key/value encoder that emits logs with a very basic "key=value" formatting.
Types ¶
type Field ¶ added in v1.6.0
Field aliased here to make it easier to adopt this package
func ErrorWithStackField ¶ added in v1.6.0
ErrorWithStackField writes an error. Prints message and stack if available.
func Msec ¶ added in v1.6.0
Msec writes a duration in milliseconds. If the time is <10msec, it is given to one decimal point.
func NamedError ¶ added in v1.6.0
NamedError writes an error with a custom name.
func PercentInt ¶ added in v1.6.0
PercentInt writes out a percent out of 100%.
func RichError ¶ added in v1.6.0
RichError writes an error in the standard format expected by Datadog:
- type of error in `error.kind`
- `err.Error()` in `error.message`
- stack trace from the first error that has one in the chain of wrapped errors starting from err in `error.stack`, or RichError caller stack trace if no such stack trace was found.
- RichError caller stack trace in `error.handling_stack` if a stack trace was found from err.
func Stringer ¶ added in v1.6.0
Stringer writes the output of the value's String method. The Stringer's String method is called lazily.
func Stringers ¶ added in v1.6.0
Stringers writes the output of the value's String methods. The Stringer's String methods are called lazily.
func Stringf ¶ added in v1.6.0
Stringf writes fmt.Sprintf(format, args...). It is evaluated lazily, only if the log message is going to be emitted.
func StructuredObject ¶ added in v1.6.0
func StructuredObject(key string, value zapcore.ObjectMarshaler) Field
StructuredObject adds value as a structured object. value must implement zap.MarshalLogObject. Examples of such implementations can be found here: https://github.com/uber-go/zap/blob/9b86a50a3e27e0e12ccb6b47288de27df7fd3d5b/example_test.go#L176-L186
type KubehoundLogger ¶
type KubehoundLogger struct {
LoggerI
}
type Level ¶ added in v1.6.0
type Level byte
Level of log emission. A logger at any level will ignore all levels below it in value.
Logging levels
func LevelFromString ¶ added in v1.6.0
LevelFromString returns the level for the given string. If the string is not valid, an error is returned.
func (Level) MarshalText ¶ added in v1.6.0
MarshalText implements encoding.TextMarshaler for Level.
func (*Level) UnmarshalText ¶ added in v1.6.0
UnmarshalText implements encoding.TextUnmarshaler for Level.
type LoggerI ¶ added in v1.6.0
type LoggerI interface { // With returns a child logger structured with the provided fields. // Fields added to the child don't affect the parent, and vice versa. With(fields ...Field) LoggerI Debug(msg string, fields ...Field) Info(msg string, fields ...Field) Warn(msg string, fields ...Field) Error(msg string, fields ...Field) Panic(msg string, fields ...Field) Fatal(msg string, fields ...Field) Debugf(msg string, params ...interface{}) Infof(msg string, params ...interface{}) Warnf(msg string, params ...interface{}) Errorf(msg string, params ...interface{}) Panicf(msg string, params ...interface{}) Fatalf(msg string, params ...interface{}) }
func DefaultLogger ¶ added in v1.6.0
func DefaultLogger() LoggerI
DefaultLogger returns the global logger
type UnwrapJoin ¶ added in v1.6.0
type UnwrapJoin interface {
Unwrap() []error
}
Interface to unwrap joined errors.Join https://pkg.go.dev/errors#Join
type UnwrapMultierror ¶ added in v1.6.0
type UnwrapMultierror interface {
WrappedErrors() []error
}
Interface to unwrap joined multierror.Append https://pkg.go.dev/github.com/hashicorp/go-multierror#Error.WrappedErrors