log

package
v0.0.0-...-81f3bb6 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package log is a generated protocol buffer package.

It is generated from these files:

util/log/log.proto

It has these top-level messages:

Entry
FileDetails
FileInfo

Index

Constants

View Source
const (
	// Bits or'ed together to control what's printed.
	// There is no control over the order they appear (the order listed
	// here) or the format they present (as described in the comments).
	// The prefix is followed by a colon only when Llongfile or Lshortfile
	// is specified.
	// For example, flags Ldate | Ltime (or LstdFlags) produce,
	//	2009/01/23 01:23:23 message
	// while flags Ldate | Ltime | Lmicroseconds | Llongfile produce,
	//	2009/01/23 01:23:23.123123 /a/b/c/d.go:23: message
	Ldate         = 1 << iota     // the date in the local time zone: 2009/01/23
	Ltime                         // the time in the local time zone: 01:23:23
	Lmicroseconds                 // microsecond resolution: 01:23:23.123123.  assumes Ltime.
	Llongfile                     // full file name and line number: /a/b/c/d.go:23
	Lshortfile                    // final file name element and line number: d.go:23. overrides Llongfile
	LUTC                          // if Ldate or Ltime is set, use UTC rather than the local time zone
	LstdFlags     = Ldate | Ltime // initial values for the standard logger
)

These flags define which text to prefix to each log entry generated by the Logger.

Variables

View Source
var (
	ErrInvalidLengthLog = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowLog   = fmt.Errorf("proto: integer overflow")
)
View Source
var Severity_name = map[int32]string{
	0: "UNKNOWN",
	1: "INFO",
	2: "WARNING",
	3: "ERROR",
	4: "FATAL",
	5: "NONE",
	6: "DEFAULT",
}
View Source
var Severity_value = map[string]int32{
	"UNKNOWN": 0,
	"INFO":    1,
	"WARNING": 2,
	"ERROR":   3,
	"FATAL":   4,
	"NONE":    5,
	"DEFAULT": 6,
}

Functions

func Event

func Event(ctx context.Context, msg string)

Event looks for an opentracing.Trace in the context and logs the given message to it. If no Trace is found, it looks for an EventLog in the context and logs the message to it. If neither is found, does nothing.

func Eventf

func Eventf(ctx context.Context, format string, args ...interface{})

Eventf looks for an opentracing.Trace in the context and formats and logs the given message to it. If no Trace is found, it looks for an EventLog in the context and logs the message to it. If neither is found, does nothing.

func FinishEventLog

func FinishEventLog(ctx context.Context)

FinishEventLog closes the event log in the context (see WithEventLog). Concurrent and subsequent calls to record events are allowed.

func HasSpanOrEvent

func HasSpanOrEvent(ctx context.Context) bool

HasSpanOrEvent returns true if the context has a span or event that should be logged to.

func MakeMessage

func MakeMessage(ctx context.Context, format string, args []interface{}) string

MakeMessage creates a structured log entry.

func VErrEvent

func VErrEvent(ctx context.Context, level int32, msg string)

VErrEvent either logs an error message to the log files (which also outputs to the active trace or event log) or to the trace/event log alone, depending on whether the specified verbosity level is active.

func VErrEventf

func VErrEventf(ctx context.Context, level int32, format string, args ...interface{})

VErrEventf either logs an error message to the log files (which also outputs to the active trace or event log) or to the trace/event log alone, depending on whether the specified verbosity level is active.

func VErrEventfDepth

func VErrEventfDepth(
	ctx context.Context, depth int, level int32, format string, args ...interface{},
)

VErrEventfDepth performs the same as VErrEventf but checks the verbosity level at the given depth in the call stack.

func VEvent

func VEvent(ctx context.Context, level int32, msg string)

VEvent either logs a message to the log files (which also outputs to the active trace or event log) or to the trace/event log alone, depending on whether the specified verbosity level is active.

func VEventf

func VEventf(ctx context.Context, level int32, format string, args ...interface{})

VEventf either logs a message to the log files (which also outputs to the active trace or event log) or to the trace/event log alone, depending on whether the specified verbosity level is active.

func VEventfDepth

func VEventfDepth(ctx context.Context, depth int, level int32, format string, args ...interface{})

VEventfDepth performs the same as VEventf but checks the verbosity level at the given depth in the call stack.

func WithEventLog

func WithEventLog(ctx context.Context, family, title string) context.Context

WithEventLog creates and embeds a trace.EventLog in the context, causing future logging and event calls to go to the EventLog. The current context must not have an existing open span.

func WithLogTag

func WithLogTag(ctx context.Context, name string, value interface{}) context.Context

WithLogTag returns a context (derived from the given context) which when used with a logging function results in the given name and value being printed in the message.

The value is stored and passed to fmt.Fprint when the log message is constructed. A fmt.Stringer can be passed which allows the value to be "dynamic".

If the value is nil, just the name shows up.

func WithLogTagInt

func WithLogTagInt(ctx context.Context, name string, value int) context.Context

WithLogTagInt is a variant of WithLogTag that avoids the allocation associated with boxing the value in an interface{}.

func WithLogTagInt64

func WithLogTagInt64(ctx context.Context, name string, value int64) context.Context

WithLogTagInt64 is a variant of WithLogTag that avoids the allocation associated with boxing the value in an interface{}.

func WithLogTagStr

func WithLogTagStr(ctx context.Context, name string, value string) context.Context

WithLogTagStr is a variant of WithLogTag that avoids the allocation associated with boxing the value in an interface{}.

func WithNoEventLog

func WithNoEventLog(ctx context.Context) context.Context

WithNoEventLog creates a context which no longer has an embedded event log.

Types

type AmbientContext

type AmbientContext struct {
	// Tracer is used to open spans (see AnnotateCtxWithSpan).
	Tracer opentracing.Tracer
	// contains filtered or unexported fields
}

AmbientContext is a helper type used to "annotate" context.Contexts with log tags and a Tracer or EventLog. It is intended to be embedded into various server components.

Example:

type SomeServer struct {
  log.AmbientContext
  ...
}

ac := AmbientContext{Tracer: tracing.NewTracer()}
ac.AddLogTag("n", 1)

s := &SomeServer{
  AmbientContext: ac
  ...
}

// on an operation with context ctx
ctx = s.AnnotateCtx(ctx)
...

// run a worker
s.stopper.RunWorker(func() {
  ctx := s.AnnotateCtx(context.Background())
  ...
})

// start a background operation
ctx, span := s.AnnotateCtxWithSpan(context.Background(), "some-op")
defer span.Finish()
...

func NewAmbientContext

func NewAmbientContext(ctx context.Context, tracer opentracing.Tracer) AmbientContext

func (*AmbientContext) AddLogTag

func (ac *AmbientContext) AddLogTag(name string, value interface{})

AddLogTag adds a tag; see WithLogTag.

func (*AmbientContext) AddLogTagInt

func (ac *AmbientContext) AddLogTagInt(name string, value int)

AddLogTagInt adds an integer tag; see WithLogTagInt.

func (*AmbientContext) AddLogTagInt64

func (ac *AmbientContext) AddLogTagInt64(name string, value int64)

AddLogTagInt64 adds an integer tag; see WithLogTagInt64.

func (*AmbientContext) AddLogTagStr

func (ac *AmbientContext) AddLogTagStr(name string, value string)

AddLogTagStr adds a string tag; see WithLogTagStr.

func (*AmbientContext) AnnotateCtx

func (ac *AmbientContext) AnnotateCtx(ctx context.Context) context.Context

AnnotateCtx annotates a given context with the information in AmbientContext:

  • the EventLog is embedded in the context if the context doesn't already have an event log or an open trace.
  • the log tags in AmbientContext are added (if ctx doesn't already have them). If the tags already exist, the values from the AmbientContext overwrite the existing values, but the order of the tags might change.

For background operations, context.Background() should be passed; however, in that case it is strongly recommended to open a span if possible (using AnnotateCtxWithSpan).

func (*AmbientContext) AnnotateCtxWithSpan

func (ac *AmbientContext) AnnotateCtxWithSpan(
	ctx context.Context, opName string,
) (context.Context, opentracing.Span)

AnnotateCtxWithSpan annotates the given context with the information in AmbientContext (see AnnotateCtx) and opens a span.

If the given context has a span, the new span is a child of that span. Otherwise, the Tracer in AmbientContext is used to create a new root span.

The caller is responsible for closing the span (via Span.Finish).

func (*AmbientContext) FinishEventLog

func (ac *AmbientContext) FinishEventLog()

FinishEventLog closes the event log. Concurrent and subsequent calls to record events from contexts that use this event log embedded are allowed.

func (*AmbientContext) ResetAndAnnotateCtx

func (ac *AmbientContext) ResetAndAnnotateCtx(ctx context.Context) context.Context

ResetAndAnnotateCtx annotates a given context with the information in AmbientContext, but unlike AnnotateCtx, it drops all log tags in the supplied context before adding the ones from the AmbientContext.

func (*AmbientContext) SetEventLog

func (ac *AmbientContext) SetEventLog(family, title string)

SetEventLog sets up an event log. Annotated contexts log into this event log (unless there's an open Span).

type Entry

type Entry struct {
	Severity Severity `protobuf:"varint,1,opt,name=severity,proto3,enum=cockroach.util.log.Severity" json:"severity,omitempty"`
	// Nanoseconds since the epoch.
	Time      int64  `protobuf:"varint,2,opt,name=time,proto3" json:"time,omitempty"`
	Goroutine int64  `protobuf:"varint,6,opt,name=goroutine,proto3" json:"goroutine,omitempty"`
	File      string `protobuf:"bytes,3,opt,name=file,proto3" json:"file,omitempty"`
	Line      int64  `protobuf:"varint,4,opt,name=line,proto3" json:"line,omitempty"`
	Message   string `protobuf:"bytes,5,opt,name=message,proto3" json:"message,omitempty"`
}

Entry represents a cockroach structured log entry.

func (*Entry) Descriptor

func (*Entry) Descriptor() ([]byte, []int)

func (*Entry) Marshal

func (m *Entry) Marshal() (dAtA []byte, err error)

func (*Entry) MarshalTo

func (m *Entry) MarshalTo(dAtA []byte) (int, error)

func (*Entry) ProtoMessage

func (*Entry) ProtoMessage()

func (*Entry) Reset

func (m *Entry) Reset()

func (*Entry) Size

func (m *Entry) Size() (n int)

func (*Entry) String

func (m *Entry) String() string

func (*Entry) Unmarshal

func (m *Entry) Unmarshal(dAtA []byte) error

type FileDetails

type FileDetails struct {
	Program  string `protobuf:"bytes,1,opt,name=program,proto3" json:"program,omitempty"`
	Host     string `protobuf:"bytes,2,opt,name=host,proto3" json:"host,omitempty"`
	UserName string `protobuf:"bytes,3,opt,name=user_name,json=userName,proto3" json:"user_name,omitempty"`
	Time     int64  `protobuf:"varint,5,opt,name=time,proto3" json:"time,omitempty"`
	PID      int64  `protobuf:"varint,6,opt,name=pid,proto3" json:"pid,omitempty"`
}

A FileDetails holds all of the particulars that can be parsed by the name of a log file.

func (*FileDetails) Descriptor

func (*FileDetails) Descriptor() ([]byte, []int)

func (*FileDetails) Marshal

func (m *FileDetails) Marshal() (dAtA []byte, err error)

func (*FileDetails) MarshalTo

func (m *FileDetails) MarshalTo(dAtA []byte) (int, error)

func (*FileDetails) ProtoMessage

func (*FileDetails) ProtoMessage()

func (*FileDetails) Reset

func (m *FileDetails) Reset()

func (*FileDetails) Size

func (m *FileDetails) Size() (n int)

func (*FileDetails) String

func (m *FileDetails) String() string

func (*FileDetails) Unmarshal

func (m *FileDetails) Unmarshal(dAtA []byte) error

type FileInfo

type FileInfo struct {
	Name         string      `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	SizeBytes    int64       `protobuf:"varint,2,opt,name=size_bytes,json=sizeBytes,proto3" json:"size_bytes,omitempty"`
	ModTimeNanos int64       `protobuf:"varint,3,opt,name=mod_time_nanos,json=modTimeNanos,proto3" json:"mod_time_nanos,omitempty"`
	Details      FileDetails `protobuf:"bytes,4,opt,name=details" json:"details"`
}

func (*FileInfo) Descriptor

func (*FileInfo) Descriptor() ([]byte, []int)

func (*FileInfo) Marshal

func (m *FileInfo) Marshal() (dAtA []byte, err error)

func (*FileInfo) MarshalTo

func (m *FileInfo) MarshalTo(dAtA []byte) (int, error)

func (*FileInfo) ProtoMessage

func (*FileInfo) ProtoMessage()

func (*FileInfo) Reset

func (m *FileInfo) Reset()

func (*FileInfo) Size

func (m *FileInfo) Size() (n int)

func (*FileInfo) String

func (m *FileInfo) String() string

func (*FileInfo) Unmarshal

func (m *FileInfo) Unmarshal(dAtA []byte) error

type Logger

type Logger struct {
	Logger   *log.Logger
	LogLevel int
}

func New

func New(out io.Writer, prefix string, flag int, level int) *Logger

func (*Logger) Fatal

func (l *Logger) Fatal(level int, str string)

Fatal is equivalent to l.Print() followed by a call to os.Exit(1).

func (*Logger) Fatalf

func (l *Logger) Fatalf(level int, str string)

Fatalf is equivalent to l.Printf() followed by a call to os.Exit(1).

func (*Logger) Fatalln

func (l *Logger) Fatalln(level int, str string)

Fatalln is equivalent to l.Println() followed by a call to os.Exit(1).

func (*Logger) GetLevel

func (l *Logger) GetLevel() int

func (*Logger) Panic

func (l *Logger) Panic(level int, str string)

Panic is equivalent to l.Print() followed by a call to panic().

func (*Logger) Panicf

func (l *Logger) Panicf(level int, str string)

Panicf is equivalent to l.Printf() followed by a call to panic().

func (*Logger) Panicln

func (l *Logger) Panicln(level int, str string)

Panicln is equivalent to l.Println() followed by a call to panic().

func (*Logger) Print

func (l *Logger) Print(level int, str string)

Print calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Print.

func (*Logger) Printf

func (l *Logger) Printf(level int, str string)

Printf calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Println

func (l *Logger) Println(level int, str string)

Println calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Println.

type RaftLogger

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

func NewRaftLogger

func NewRaftLogger(prefix string, log *Logger) *RaftLogger

func (*RaftLogger) Debug

func (r *RaftLogger) Debug(v ...interface{})

func (*RaftLogger) Debugf

func (r *RaftLogger) Debugf(format string, v ...interface{})

func (*RaftLogger) Error

func (r *RaftLogger) Error(v ...interface{})

func (*RaftLogger) Errorf

func (r *RaftLogger) Errorf(format string, v ...interface{})

func (*RaftLogger) Fatal

func (r *RaftLogger) Fatal(v ...interface{})

func (*RaftLogger) Fatalf

func (r *RaftLogger) Fatalf(format string, v ...interface{})

func (*RaftLogger) Info

func (r *RaftLogger) Info(v ...interface{})

func (*RaftLogger) Infof

func (r *RaftLogger) Infof(format string, v ...interface{})

func (*RaftLogger) Panic

func (r *RaftLogger) Panic(v ...interface{})

func (*RaftLogger) Panicf

func (r *RaftLogger) Panicf(format string, v ...interface{})

func (*RaftLogger) Warning

func (r *RaftLogger) Warning(v ...interface{})

func (*RaftLogger) Warningf

func (r *RaftLogger) Warningf(format string, v ...interface{})

type Severity

type Severity int32
const (
	Severity_UNKNOWN Severity = 0
	Severity_INFO    Severity = 1
	Severity_WARNING Severity = 2
	Severity_ERROR   Severity = 3
	Severity_FATAL   Severity = 4
	// NONE is used to specify when no messages
	// should be printed to the log file or stderr.
	Severity_NONE Severity = 5
	// DEFAULT is the end sentinel. It is used during command-line
	// handling to indicate that another value should be replaced instead
	// (depending on which command is being run); see cli/flags.go for
	// details.
	Severity_DEFAULT Severity = 6
)

func (Severity) EnumDescriptor

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

func (Severity) String

func (x Severity) String() string

Jump to

Keyboard shortcuts

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