slog

package
v0.0.0-...-e613b9d Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Atrace = Trace
)

Functions

func GetTraceIDTemplate

func GetTraceIDTemplate() string

func GetTraceURLTemplate

func GetTraceURLTemplate() string

func InitSentry

func InitSentry(ctx context.Context) (io.Closer, error)

func Logger

func Logger() *zerolog.Logger

Logger returns the root logger.

func NewEntry

func NewEntry(p []byte) *logging.Entry

func Recover

func Recover(ctx context.Context, task ...async.Task) error

func SetDefaultLogger

func SetDefaultLogger(writer []io.Writer)

SetDefaultLogger sets up the zerolog.Logger

func SetDefaultTracer

func SetDefaultTracer(v Tracer)

func SetTimeFieldFormat

func SetTimeFieldFormat()

SetTimeFieldFormat sets up the zerolog.TimeFieldFormat

Types

type AppengineEntry

type AppengineEntry struct {
	Time                 string                   `protobuf:"bytes,1,opt,name=time,proto3" json:"time,omitempty"`
	Trace                string                   `protobuf:"bytes,2,opt,name=trace,proto3" json:"trace,omitempty"`
	SourceLocation       *AppengineSourceLocation `protobuf:"bytes,3,opt,name=source_location,json=sourceLocation,proto3" json:"source_location,omitempty"`
	Severity             string                   `protobuf:"bytes,4,opt,name=severity,proto3" json:"severity,omitempty"`
	Message              string                   `protobuf:"bytes,5,opt,name=message,proto3" json:"message,omitempty"`
	Data                 string                   `protobuf:"bytes,6,opt,name=data,proto3" json:"data,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                 `json:"-"`
	XXX_unrecognized     []byte                   `json:"-"`
	XXX_sizecache        int32                    `json:"-"`
}

AppengineEntry is ValueObject.

func NewAppengineEntry

func NewAppengineEntry(p []byte) *AppengineEntry

func (*AppengineEntry) Descriptor

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

func (*AppengineEntry) GetData

func (m *AppengineEntry) GetData() string

func (*AppengineEntry) GetMessage

func (m *AppengineEntry) GetMessage() string

func (*AppengineEntry) GetSeverity

func (m *AppengineEntry) GetSeverity() string

func (*AppengineEntry) GetSourceLocation

func (m *AppengineEntry) GetSourceLocation() *AppengineSourceLocation

func (*AppengineEntry) GetTime

func (m *AppengineEntry) GetTime() string

func (*AppengineEntry) GetTrace

func (m *AppengineEntry) GetTrace() string

func (*AppengineEntry) ProtoMessage

func (*AppengineEntry) ProtoMessage()

func (*AppengineEntry) Reset

func (m *AppengineEntry) Reset()

func (*AppengineEntry) String

func (m *AppengineEntry) String() string

func (*AppengineEntry) Validate

func (m *AppengineEntry) Validate() error

Validate checks the field values on AppengineEntry with the rules defined in the proto definition for this message. If any rules are violated, an error is returned.

func (*AppengineEntry) XXX_DiscardUnknown

func (m *AppengineEntry) XXX_DiscardUnknown()

func (*AppengineEntry) XXX_Marshal

func (m *AppengineEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*AppengineEntry) XXX_Merge

func (m *AppengineEntry) XXX_Merge(src proto.Message)

func (*AppengineEntry) XXX_Size

func (m *AppengineEntry) XXX_Size() int

func (*AppengineEntry) XXX_Unmarshal

func (m *AppengineEntry) XXX_Unmarshal(b []byte) error

type AppengineEntryValidationError

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

AppengineEntryValidationError is the validation error returned by AppengineEntry.Validate if the designated constraints aren't met.

func (AppengineEntryValidationError) Cause

Cause function returns cause value.

func (AppengineEntryValidationError) Error

Error satisfies the builtin error interface

func (AppengineEntryValidationError) ErrorName

func (e AppengineEntryValidationError) ErrorName() string

ErrorName returns error name.

func (AppengineEntryValidationError) Field

Field function returns field value.

func (AppengineEntryValidationError) Key

Key function returns key value.

func (AppengineEntryValidationError) Reason

Reason function returns reason value.

type AppengineEntryer

type AppengineEntryer interface {
	Descriptor() ([]byte, []int)
	GetData() map[string]*any.Any
	GetMessage() string
	GetSeverity() string
	GetSourceLocation() *AppengineSourceLocation
	GetTime() string
	GetTrace() string
	ProtoMessage()
	Reset()
	String() string
	Validate() error
	XXX_DiscardUnknown()
	XXX_Marshal([]byte, bool) ([]byte, error)
	XXX_Merge(protoiface.MessageV1)
	XXX_Size() int
	XXX_Unmarshal([]byte) error
}

AppengineEntryer is an interface generated for "github.com/michilu/boilerplate/service/slog.AppengineEntry".

type AppengineLoggingWriter

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

AppengineLogging accepts pre-encoded JSON messages and writes them to Google Appengine Logging and maps Zerolog levels to Appengine levels. The labels argument is ignored if opts includes CommonLabels. The returned client should be closed before the program exits.

func NewAppengineLogging

func NewAppengineLogging(ctx context.Context) (*AppengineLoggingWriter, error)

NewAppengineLogging returns a new AppengineLoggingWriter.

func (*AppengineLoggingWriter) GetParentProjects

func (p *AppengineLoggingWriter) GetParentProjects() string

GetParentProjects returns a string of parent projects. https://godoc.org/cloud.google.com/go/logging#NewClient

func (*AppengineLoggingWriter) GetTraceIDTemplate

func (p *AppengineLoggingWriter) GetTraceIDTemplate() string

GetTraceIDTemplate returns a template string of the stackdriver traceID.

func (*AppengineLoggingWriter) GetTraceURLTemplate

func (p *AppengineLoggingWriter) GetTraceURLTemplate() string

GetTraceURLTemplate returns a template string of the stackdriver traces URL.

func (*AppengineLoggingWriter) Write

func (w *AppengineLoggingWriter) Write(p []byte) (int, error)

Write always returns len(p), nil.

func (*AppengineLoggingWriter) WriteLevel

func (w *AppengineLoggingWriter) WriteLevel(level zerolog.Level, p []byte) (int, error)

WriteLevel implements zerolog.LevelWriter. It always returns len(p), nil.

type AppengineSourceLocation

type AppengineSourceLocation struct {
	File                 string   `protobuf:"bytes,1,opt,name=file,proto3" json:"file,omitempty"`
	Line                 string   `protobuf:"bytes,2,opt,name=line,proto3" json:"line,omitempty"`
	Function             string   `protobuf:"bytes,3,opt,name=function,proto3" json:"function,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

AppengineSourceLocation is ValueObject.

func (*AppengineSourceLocation) Descriptor

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

func (*AppengineSourceLocation) GetFile

func (m *AppengineSourceLocation) GetFile() string

func (*AppengineSourceLocation) GetFunction

func (m *AppengineSourceLocation) GetFunction() string

func (*AppengineSourceLocation) GetLine

func (m *AppengineSourceLocation) GetLine() string

func (*AppengineSourceLocation) ProtoMessage

func (*AppengineSourceLocation) ProtoMessage()

func (*AppengineSourceLocation) Reset

func (m *AppengineSourceLocation) Reset()

func (*AppengineSourceLocation) String

func (m *AppengineSourceLocation) String() string

func (*AppengineSourceLocation) Validate

func (m *AppengineSourceLocation) Validate() error

Validate checks the field values on AppengineSourceLocation with the rules defined in the proto definition for this message. If any rules are violated, an error is returned.

func (*AppengineSourceLocation) XXX_DiscardUnknown

func (m *AppengineSourceLocation) XXX_DiscardUnknown()

func (*AppengineSourceLocation) XXX_Marshal

func (m *AppengineSourceLocation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*AppengineSourceLocation) XXX_Merge

func (m *AppengineSourceLocation) XXX_Merge(src proto.Message)

func (*AppengineSourceLocation) XXX_Size

func (m *AppengineSourceLocation) XXX_Size() int

func (*AppengineSourceLocation) XXX_Unmarshal

func (m *AppengineSourceLocation) XXX_Unmarshal(b []byte) error

type AppengineSourceLocationValidationError

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

AppengineSourceLocationValidationError is the validation error returned by AppengineSourceLocation.Validate if the designated constraints aren't met.

func (AppengineSourceLocationValidationError) Cause

Cause function returns cause value.

func (AppengineSourceLocationValidationError) Error

Error satisfies the builtin error interface

func (AppengineSourceLocationValidationError) ErrorName

ErrorName returns error name.

func (AppengineSourceLocationValidationError) Field

Field function returns field value.

func (AppengineSourceLocationValidationError) Key

Key function returns key value.

func (AppengineSourceLocationValidationError) Reason

Reason function returns reason value.

type HookMeta

type HookMeta struct{}

HookMeta appends a meta information to zerolog.

func (HookMeta) Run

func (HookMeta) Run(e *zerolog.Event, level zerolog.Level, msg string)

Run runs the hook with the event.

type StackdriverCloser

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

func (*StackdriverCloser) Close

func (p *StackdriverCloser) Close() error

type StackdriverLoggingWriter

type StackdriverLoggingWriter struct {
	Logger *logging.Logger
	// contains filtered or unexported fields
}

StackdriverLogging accepts pre-encoded JSON messages and writes them to Google Stackdriver Logging and maps Zerolog levels to Stackdriver levels. The labels argument is ignored if opts includes CommonLabels. The returned client should be closed before the program exits.

func NewStackdriverLogging

func NewStackdriverLogging(
	ctx context.Context,
	projectID string,
	logID string,
	labels map[string]string,
	opts ...logging.LoggerOption,
) (*StackdriverLoggingWriter, *logging.Client, error)

NewStackdriverLogging returns a new StackdriverLoggingWriter.

func (*StackdriverLoggingWriter) Flush

func (p *StackdriverLoggingWriter) Flush() error

func (*StackdriverLoggingWriter) GetParentProjects

func (p *StackdriverLoggingWriter) GetParentProjects() string

GetParentProjects returns a string of parent projects. https://godoc.org/cloud.google.com/go/logging#NewClient

func (*StackdriverLoggingWriter) GetTraceIDTemplate

func (p *StackdriverLoggingWriter) GetTraceIDTemplate() string

GetTraceIDTemplate returns a template string of the stackdriver traceID.

func (*StackdriverLoggingWriter) GetTraceURLTemplate

func (p *StackdriverLoggingWriter) GetTraceURLTemplate() string

GetTraceURLTemplate returns a template string of the stackdriver traces URL.

func (*StackdriverLoggingWriter) Write

func (w *StackdriverLoggingWriter) Write(p []byte) (int, error)

Write always returns len(p), nil.

func (*StackdriverLoggingWriter) WriteLevel

func (w *StackdriverLoggingWriter) WriteLevel(level zerolog.Level, p []byte) (int, error)

WriteLevel implements zerolog.LevelWriter. It always returns len(p), nil.

type StackdriverZerologWriter

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

func NewStackdriverZerologWriter

func NewStackdriverZerologWriter(ctx context.Context) *StackdriverZerologWriter

NewStackdriverZerologWriter returns a new ZerologWriter.

func (*StackdriverZerologWriter) Init

func (*StackdriverZerologWriter) MarshalZerologObject

func (p *StackdriverZerologWriter) MarshalZerologObject(e *zerolog.Event)

type TraceObject

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

Trace is trace span handler for zerolog.

func (*TraceObject) MarshalZerologObject

func (p *TraceObject) MarshalZerologObject(e *zerolog.Event)

type Tracer

type Tracer interface {
	GetTraceIDTemplate() string
	GetTraceURLTemplate() string
}

Jump to

Keyboard shortcuts

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