log

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DebugLevelEtcd    uint64 = 1 << 0
	DebugLevelApi     uint64 = 1 << 1
	DebugLevelNotify  uint64 = 1 << 2
	DebugLevelDmedb   uint64 = 1 << 3
	DebugLevelDmereq  uint64 = 1 << 4
	DebugLevelLocapi  uint64 = 1 << 5
	DebugLevelInfra   uint64 = 1 << 6
	DebugLevelMetrics uint64 = 1 << 7
	DebugLevelUpgrade uint64 = 1 << 8
	DebugLevelInfo    uint64 = 1 << 9
	DebugLevelSampled uint64 = 1 << 10
	DebugLevelEvents  uint64 = 1 << 11
	DebugLevelFedapi  uint64 = 1 << 12
)

Variables

View Source
var DebugLevelStrings = []string{
	"etcd",
	"api",
	"notify",
	"dmedb",
	"dmereq",
	"locapi",
	"infra",
	"metrics",
	"upgrade",
	"info",
	"sampled",
	"events",
	"fedapi",
}
View Source
var DebugLevel_CamelName = map[int32]string{

	0: "Etcd",

	1: "Api",

	2: "Notify",

	3: "Dmedb",

	4: "Dmereq",

	5: "Locapi",

	6: "Infra",

	7: "Metrics",

	8: "Upgrade",

	9: "Info",

	10: "Sampled",

	11: "Events",

	12: "Fedapi",
}
View Source
var DebugLevel_CamelValue = map[string]int32{
	"Etcd":    0,
	"Api":     1,
	"Notify":  2,
	"Dmedb":   3,
	"Dmereq":  4,
	"Locapi":  5,
	"Infra":   6,
	"Metrics": 7,
	"Upgrade": 8,
	"Info":    9,
	"Sampled": 10,
	"Events":  11,
	"Fedapi":  12,
}
View Source
var DebugLevel_name = map[int32]string{
	0:  "etcd",
	1:  "api",
	2:  "notify",
	3:  "dmedb",
	4:  "dmereq",
	5:  "locapi",
	6:  "infra",
	7:  "metrics",
	8:  "upgrade",
	9:  "info",
	10: "sampled",
	11: "events",
	12: "fedapi",
}
View Source
var DebugLevel_value = map[string]int32{
	"etcd":    0,
	"api":     1,
	"notify":  2,
	"dmedb":   3,
	"dmereq":  4,
	"locapi":  5,
	"infra":   6,
	"metrics": 7,
	"upgrade": 8,
	"info":    9,
	"sampled": 10,
	"events":  11,
	"fedapi":  12,
}
View Source
var IgnoreLvl uint64 = 99999
View Source
var JaegerUnitTest bool
View Source
var ReporterMetrics *metricstest.Backend
View Source
var SamplingEnabled = true
View Source
var ShowMethodNames = map[string]struct{}{}
View Source
var SpanServiceName string

Functions

func AuditLogEnd

func AuditLogEnd(id uint64, err error)

func AuditLogStart

func AuditLogStart(id uint64, cmd, client, user string, keysAndValues ...interface{})

func ChildSpan

func ChildSpan(ctx context.Context, lvl uint64, operationName string) (opentracing.Span, context.Context)

func ClearDebugLevel

func ClearDebugLevel(lvl uint64)

func ClearDebugLevelEnum

func ClearDebugLevelEnum(val DebugLevel)

func ClearDebugLevelStrs

func ClearDebugLevelStrs(list string)

func ClearDebugLevels

func ClearDebugLevels(vals []DebugLevel)

func ContextWithSpan

func ContextWithSpan(ctx context.Context, span opentracing.Span) context.Context

func DebugLog deprecated

func DebugLog(lvl uint64, msg string, keysAndValues ...interface{})

Deprecated: you should use SpanLog instead.

func DebugSLog

func DebugSLog(slog *zap.SugaredLogger, lvl uint64, msg string, keysAndValues ...interface{})

func EnumDecodeHook

func EnumDecodeHook(from, to reflect.Type, data interface{}) (interface{}, error)

DecodeHook for use with the mapstructure package. Allows decoding to handle protobuf enums that are represented as strings.

func FatalLog

func FatalLog(msg string, keysAndValues ...interface{})

func FinishTracer

func FinishTracer()

func ForceLogSpan

func ForceLogSpan(span opentracing.Span)

func GetDebugLevel

func GetDebugLevel() uint64

func GetDebugLevelStrs

func GetDebugLevelStrs() string

func GetEnumParseHelp

func GetEnumParseHelp(t reflect.Type) (string, string, bool)

GetEnumParseHelp gets end-user specific messages for enum parse errors. It returns the enum type name, a help message with valid values, and a bool that indicates if a type was matched.

func GetLineno

func GetLineno(skip int) string

func GetTags

func GetTags(span opentracing.Span) map[string]interface{}

func IgnoreSpanTag

func IgnoreSpanTag(tag string) bool

func InfoLog

func InfoLog(msg string, keysAndValues ...interface{})

func InitTracer

func InitTracer(tlsConfig *tls.Config)

InitTracer configures the Jaeger OpenTracing client to log traces. Set JAEGER_ENDPOINT to http://<jaegerhost>:14268/api/traces to specify the Jaeger server.

func IsShow

func IsShow(cmd string) bool

func NewReporter

func NewReporter(serviceName string, tlsConfig *tls.Config, rc *config.ReporterConfig, logger jaeger.Logger) (jaeger.Reporter, io.Closer)

Adapted from config.NewReporter, in order to be able to pass in TLS config to http transport. If the jaeger client code could expose transport (or tls.Config) in their Configuration, then we could avoid this duplication of NewReporter.

func NewSpanFromGrpc

func NewSpanFromGrpc(ctx context.Context, lvl uint64, spanName string) opentracing.Span

NewSpanFromGrpc is used on server-side in controller/audit.go to extract span

func NewSpanFromString

func NewSpanFromString(lvl uint64, val, spanName string, opts ...opentracing.StartSpanOption) opentracing.Span

func NoLogSpan

func NoLogSpan(span opentracing.Span)

func NoTracingSpan

func NoTracingSpan() opentracing.Span

This span only logs to disk, and does not actually do any tracing. It is primarily for use during init for logging to disk before Jaeger is initialized, or for unit tests.

func SetContextTags

func SetContextTags(ctx context.Context, tags map[string]string)

func SetDebugLevel

func SetDebugLevel(lvl uint64)

func SetDebugLevelEnum

func SetDebugLevelEnum(val DebugLevel)

func SetDebugLevelStrs

func SetDebugLevelStrs(list string)

func SetDebugLevels

func SetDebugLevels(vals []DebugLevel)

func SetTags

func SetTags(span opentracing.Span, tags map[string]string)

func SetupLoggers

func SetupLoggers(logFile string)

SetupLoggers allows for overriding default loggers, primarily for e2e tests. Must be called before InitTracer().

func SpanFromContext

func SpanFromContext(ctx context.Context) opentracing.Span

func SpanLog

func SpanLog(ctx context.Context, lvl uint64, msg string, keysAndValues ...interface{})

func SpanToString

func SpanToString(ctx context.Context) string

func SpanTraceID

func SpanTraceID(ctx context.Context) string

func StartSpan

func StartSpan(lvl uint64, operationName string, opts ...opentracing.StartSpanOption) opentracing.Span

func StartTestSpan

func StartTestSpan(ctx context.Context, opts ...opentracing.StartSpanOption) context.Context

Convenience function for test routines. Does not require InitTracer().

func StreamClientTraceGrpc

func StreamClientTraceGrpc(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error)

func UnaryClientTraceGrpc

func UnaryClientTraceGrpc(ctx context.Context, method string, req, resp interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error

func Unsuppress

func Unsuppress(ospan opentracing.Span)

func WarnLog

func WarnLog(msg string, keysAndValues ...interface{})

Types

type DebugLevel

type DebugLevel int32
const (
	DebugLevel_etcd    DebugLevel = 0
	DebugLevel_api     DebugLevel = 1
	DebugLevel_notify  DebugLevel = 2
	DebugLevel_dmedb   DebugLevel = 3
	DebugLevel_dmereq  DebugLevel = 4
	DebugLevel_locapi  DebugLevel = 5
	DebugLevel_infra   DebugLevel = 6
	DebugLevel_metrics DebugLevel = 7
	DebugLevel_upgrade DebugLevel = 8
	DebugLevel_info    DebugLevel = 9
	DebugLevel_sampled DebugLevel = 10
	DebugLevel_events  DebugLevel = 11
	DebugLevel_fedapi  DebugLevel = 12
)

func DebugLevels

func DebugLevels() []DebugLevel

func ParseDebugLevel

func ParseDebugLevel(data interface{}) (DebugLevel, error)

func (DebugLevel) EnumDescriptor

func (DebugLevel) EnumDescriptor() ([]byte, []int)

func (DebugLevel) MarshalJSON

func (e DebugLevel) MarshalJSON() ([]byte, error)

func (DebugLevel) MarshalYAML

func (e DebugLevel) MarshalYAML() (interface{}, error)

func (DebugLevel) String

func (x DebugLevel) String() string

func (*DebugLevel) UnmarshalJSON

func (e *DebugLevel) UnmarshalJSON(b []byte) error

custom JSON encoding/decoding

func (*DebugLevel) UnmarshalYAML

func (e *DebugLevel) UnmarshalYAML(unmarshal func(interface{}) error) error

type FieldMap

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

func MakeFieldMap

func MakeFieldMap(fields []string) *FieldMap

func NewFieldMap

func NewFieldMap(fields map[string]struct{}) *FieldMap

func (*FieldMap) Clear

func (s *FieldMap) Clear(key string)

func (*FieldMap) Count

func (s *FieldMap) Count() int

func (*FieldMap) Fields

func (s *FieldMap) Fields() []string

func (*FieldMap) Has

func (s *FieldMap) Has(key string) bool

Has checks if the key is set. Note that setting a parent key implies that all child keys are also set.

func (*FieldMap) HasOrHasChild

func (s *FieldMap) HasOrHasChild(key string) bool

HasOrHasChild checks if the key, or any child of the key is set. Note that as with Has(), if a parent of the key is set, this returns true.

func (*FieldMap) Set

func (s *FieldMap) Set(key string)

type MatchOpt

type MatchOpt func(*MatchOptions)

func MatchFilter

func MatchFilter() MatchOpt

func MatchIgnoreBackend

func MatchIgnoreBackend() MatchOpt

func MatchSortArrayedKeys

func MatchSortArrayedKeys() MatchOpt

type MatchOptions

type MatchOptions struct {
	// Filter will ignore 0 or nil fields on the passed in object
	Filter bool
	// IgnoreBackend will ignore fields that were marked backend in .proto
	IgnoreBackend bool
	// Sort repeated (arrays) of Key objects so matching does not
	// fail due to order.
	SortArrayedKeys bool
}

type ReporterCloser

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

func (*ReporterCloser) Close

func (s *ReporterCloser) Close() error

type Span

type Span struct {
	*jaeger.Span
	// contains filtered or unexported fields
}

Wrap Span so we can override Finish()

func (*Span) Finish

func (s *Span) Finish()

func (*Span) Tracer

func (s *Span) Tracer() opentracing.Tracer

type SpanCarrier

type SpanCarrier struct {
	Data   TraceData
	Config SpanConfig
}

type SpanConfig

type SpanConfig struct {
	Suppress            bool // ignore log for show commands etc
	NoTracing           bool // special span that only logs to disk
	SuppressWithoutLogs bool // ignore start, and ignore finish unless span has logs
	HasLogs             bool
	NoLogStartFinish    bool // don't write logs for start and finish, used when span is short and only for logging a single message
}

func (*SpanConfig) ToOptions

func (s *SpanConfig) ToOptions() []opentracing.StartSpanOption

type SpanLineno

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

func WithSpanLineno

func WithSpanLineno(lineno string) SpanLineno

func (SpanLineno) Apply

func (s SpanLineno) Apply(options *opentracing.StartSpanOptions)

type TraceData

type TraceData map[string]string

TraceData is used to transport trace/span across boundaries, such as via etcd (stored on disk) or notify (cached in keys map).

func (TraceData) ForeachKey

func (t TraceData) ForeachKey(handler func(key, val string) error) error

func (TraceData) Set

func (t TraceData) Set(key, val string)

type WithHasLogs

type WithHasLogs struct{}

WithHasLogs is used to propagate the hasLogs state of a span across process API calls

func (WithHasLogs) Apply

func (s WithHasLogs) Apply(options *opentracing.StartSpanOptions)

type WithNoLogStartFinish

type WithNoLogStartFinish struct{}

WithNoLogStartFinish suppresses the file log for Start and Finish calls, used for very short spans created just to log a single log.

func (WithNoLogStartFinish) Apply

type WithNoTracing

type WithNoTracing struct{}

WithNoTracing only logs to disk

func (WithNoTracing) Apply

func (s WithNoTracing) Apply(options *opentracing.StartSpanOptions)

type WithSuppress

type WithSuppress struct{}

WithSuppress suppresses the span (effectively disables it)

func (WithSuppress) Apply

func (s WithSuppress) Apply(options *opentracing.StartSpanOptions)

type WithSuppressWithoutLogs

type WithSuppressWithoutLogs struct{}

WithSuppressWithoutLogs suppresses the span unless there are logs associated with the span. Note the start and finish log messages to disk are always skipped.

func (WithSuppressWithoutLogs) Apply

Jump to

Keyboard shortcuts

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