log

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: Apache-2.0 Imports: 14 Imported by: 175

Documentation

Overview

Package log is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CapturePanic

func CapturePanic(errPanic interface{}, 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 errPanic MUST be the result from calling recover, which MUST be done in a single level deep deferred function. The usual way of calling this is: - defer func() { log.CapturePanic(recover(), logger, &err) }()

Types

type Logger

type Logger interface {
	Debugf(msg string, args ...any)
	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
	SampleInfo(msg string, sampleRate int, tags ...tag.Tag)
	DebugOn() bool
	// Helper returns a logger that will skip one more level in stack trace. This is helpful for layered architecture, when you want to point to a business logic error, instead of pointing to the wrapped generated level.
	Helper() Logger
}

Logger is our abstraction for logging Usage examples:

 import "github.com/uber/cadence/common/log/tag"
 1) logger = logger.WithTags(
         tag.WorkflowNextEventID( 123),
         tag.WorkflowActionWorkflowStarted,
         tag.WorkflowDomainID("test-domain-id"))
    logger.Info("hello world")
 2) logger.Info("hello world",
         tag.WorkflowNextEventID( 123),
         tag.WorkflowActionWorkflowStarted,
         tag.WorkflowDomainID("test-domain-id"))
	   )
 Note: msg should be static, it is not recommended to use fmt.Sprintf() for msg.
       Anything dynamic should be tagged.

func NewLogger added in v1.3.0

func NewLogger(zapLogger *zap.Logger, opts ...Option) Logger

NewLogger returns a new logger

func NewNoop

func NewNoop() Logger

NewNoop return a noop logger

func NewReplayLogger added in v1.3.0

func NewReplayLogger(logger Logger, ctx workflow.Context, enableLogInReplay bool) Logger

NewReplayLogger creates a logger which is aware of cadence's replay mode

func NewThrottledLogger added in v1.3.0

func NewThrottledLogger(logger Logger, rps dynamicproperties.IntPropertyFn) Logger

NewThrottledLogger returns an implementation of logger that throttles the log messages being emitted. The underlying implementation uses a token bucket ratelimiter and stops emitting logs once the bucket runs out of tokens

Fatal/Panic logs are always emitted without any throttling

type MockLogger

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

MockLogger is a mock of Logger interface.

func NewMockLogger added in v1.3.1

func NewMockLogger(ctrl *gomock.Controller) *MockLogger

NewMockLogger creates a new mock instance.

func (*MockLogger) Debug

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

Debug mocks base method.

func (*MockLogger) DebugOn added in v1.3.0

func (m *MockLogger) DebugOn() bool

DebugOn mocks base method.

func (*MockLogger) Debugf added in v1.2.7

func (m *MockLogger) Debugf(msg string, args ...any)

Debugf mocks base method.

func (*MockLogger) EXPECT added in v1.3.6

func (m *MockLogger) EXPECT() *MockLoggerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockLogger) Error

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

Error mocks base method.

func (*MockLogger) Fatal

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

Fatal mocks base method.

func (*MockLogger) Helper added in v1.3.1

func (m *MockLogger) Helper() Logger

Helper mocks base method.

func (*MockLogger) Info

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

Info mocks base method.

func (*MockLogger) SampleInfo added in v1.0.0

func (m *MockLogger) SampleInfo(msg string, sampleRate int, tags ...tag.Tag)

SampleInfo mocks base method.

func (*MockLogger) Warn

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

Warn mocks base method.

func (*MockLogger) WithTags

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

WithTags mocks base method.

type MockLoggerMockRecorder added in v1.3.6

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

MockLoggerMockRecorder is the mock recorder for MockLogger.

func (*MockLoggerMockRecorder) Debug added in v1.3.6

func (mr *MockLoggerMockRecorder) Debug(msg any, tags ...any) *gomock.Call

Debug indicates an expected call of Debug.

func (*MockLoggerMockRecorder) DebugOn added in v1.3.6

func (mr *MockLoggerMockRecorder) DebugOn() *gomock.Call

DebugOn indicates an expected call of DebugOn.

func (*MockLoggerMockRecorder) Debugf added in v1.3.6

func (mr *MockLoggerMockRecorder) Debugf(msg any, args ...any) *gomock.Call

Debugf indicates an expected call of Debugf.

func (*MockLoggerMockRecorder) Error added in v1.3.6

func (mr *MockLoggerMockRecorder) Error(msg any, tags ...any) *gomock.Call

Error indicates an expected call of Error.

func (*MockLoggerMockRecorder) Fatal added in v1.3.6

func (mr *MockLoggerMockRecorder) Fatal(msg any, tags ...any) *gomock.Call

Fatal indicates an expected call of Fatal.

func (*MockLoggerMockRecorder) Helper added in v1.3.6

func (mr *MockLoggerMockRecorder) Helper() *gomock.Call

Helper indicates an expected call of Helper.

func (*MockLoggerMockRecorder) Info added in v1.3.6

func (mr *MockLoggerMockRecorder) Info(msg any, tags ...any) *gomock.Call

Info indicates an expected call of Info.

func (*MockLoggerMockRecorder) SampleInfo added in v1.3.6

func (mr *MockLoggerMockRecorder) SampleInfo(msg, sampleRate any, tags ...any) *gomock.Call

SampleInfo indicates an expected call of SampleInfo.

func (*MockLoggerMockRecorder) Warn added in v1.3.6

func (mr *MockLoggerMockRecorder) Warn(msg any, tags ...any) *gomock.Call

Warn indicates an expected call of Warn.

func (*MockLoggerMockRecorder) WithTags added in v1.3.6

func (mr *MockLoggerMockRecorder) WithTags(tags ...any) *gomock.Call

WithTags indicates an expected call of WithTags.

type Option added in v1.3.0

type Option func(impl *loggerImpl)

Option is used to set options for the logger.

func WithSampleFunc added in v1.3.0

func WithSampleFunc(fn func(int) bool) Option

WithSampleFunc sets the sampling function for the logger.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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