log

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2020 License: MIT Imports: 7 Imported by: 36

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CapturePanic

func CapturePanic(logger Logger, retError *error)

CapturePanic is used to capture panic, it will log the panic and also return the error through pointer. If the panic value is not error then a default error is returned We have to use pointer is because in golang: "recover return nil if was not called directly by a deferred function." And we have to set the returned error otherwise our handler will return nil as error which is incorrect

Types

type Logger

type Logger interface {
	Debug(msg string, tags ...tag.Tag)
	Info(msg string, tags ...tag.Tag)
	Warn(msg string, tags ...tag.Tag)
	Error(msg string, tags ...tag.Tag)
	Fatal(msg string, tags ...tag.Tag)
	WithTags(tags ...tag.Tag) Logger
}

Logger is our abstraction for logging Usage examples:

 import "go.temporal.io/server/common/log/tag"
 1) logger = logger.WithTags(
         tag.WorkflowNextEventID( 123),
         tag.WorkflowActionWorkflowStarted,
         tag.WorkflowNamespaceID("test-namespace-id"))
    logger.Info("hello world")
 2) logger.Info("hello world",
         tag.WorkflowNextEventID( 123),
         tag.WorkflowActionWorkflowStarted,
         tag.WorkflowNamespaceID("test-namespace-id"))
	   )
 Note: msg should be static, it is not recommended to use fmt.Sprintf() for msg.
       Anything dynamic should be tagged.

func NewNoop

func NewNoop() Logger

NewNoop return a noop logger

type MockLogger

type MockLogger struct {
	mock.Mock
}

MockLogger returns a mock for Logger interface

func (*MockLogger) Debug

func (_m *MockLogger) Debug(msg string, tags ...tag.Tag)

Debug provides a mock function with given fields: msg, tags

func (*MockLogger) Error

func (_m *MockLogger) Error(msg string, tags ...tag.Tag)

Error provides a mock function with given fields: msg, tags

func (*MockLogger) Fatal

func (_m *MockLogger) Fatal(msg string, tags ...tag.Tag)

Fatal provides a mock function with given fields: msg, tags

func (*MockLogger) Info

func (_m *MockLogger) Info(msg string, tags ...tag.Tag)

Info provides a mock function with given fields: msg, tags

func (*MockLogger) Warn

func (_m *MockLogger) Warn(msg string, tags ...tag.Tag)

Warn provides a mock function with given fields: msg, tags

func (*MockLogger) WithTags

func (_m *MockLogger) WithTags(tags ...tag.Tag) Logger

WithTags provides a mock function with given fields: tags

type ZapAdapter added in v0.28.0

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

func NewZapAdapter added in v0.28.0

func NewZapAdapter(zapLogger *zap.Logger) *ZapAdapter

func (*ZapAdapter) Debug added in v0.28.0

func (log *ZapAdapter) Debug(msg string, keyvals ...interface{})

func (*ZapAdapter) Error added in v0.28.0

func (log *ZapAdapter) Error(msg string, keyvals ...interface{})

func (*ZapAdapter) Info added in v0.28.0

func (log *ZapAdapter) Info(msg string, keyvals ...interface{})

func (*ZapAdapter) Warn added in v0.28.0

func (log *ZapAdapter) Warn(msg string, keyvals ...interface{})

func (*ZapAdapter) With added in v0.28.0

func (log *ZapAdapter) With(keyvals ...interface{}) log.Logger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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