log

package
v1.24.0-m112.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MIT Imports: 19 Imported by: 36

Documentation

Overview

Package log is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildZapLogger added in v1.5.7

func BuildZapLogger(cfg Config) *zap.Logger

BuildZapLogger builds and returns a new zap.Logger for this logging configuration

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

func NewCLILogger added in v1.10.0

func NewCLILogger() *zapLogger

NewCLILogger returns a logger at debug level and log into STDERR for logging from within CLI tools

func NewLazyLogger added in v1.17.0

func NewLazyLogger(logger Logger, tagFn func() []tag.Tag) *lazyLogger

func NewNoopLogger added in v1.5.7

func NewNoopLogger() *noopLogger

NewNoopLogger return a noopLogger

func NewReplayLogger added in v1.5.7

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

NewReplayLogger creates a logger which is aware of Temporal replay mode

func NewSlogLogger added in v1.23.0

func NewSlogLogger(logger Logger) *slog.Logger

NewSlogLogger creates an slog.Logger from a given logger.

func NewTestLogger added in v1.10.0

func NewTestLogger() *zapLogger

NewTestLogger returns a logger for tests

func NewThrottledLogger added in v1.5.7

func NewThrottledLogger(logger Logger, rps quotas.RateFn) *throttledLogger

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

Fatal/Panic logs are always emitted without any throttling

func NewZapLogger added in v1.5.7

func NewZapLogger(zl *zap.Logger) *zapLogger

NewZapLogger returns a new zap based logger from zap.Logger

Types

type Config added in v1.5.7

type Config struct {
	// Stdout is true if the output needs to goto standard out; default is stderr
	Stdout bool `yaml:"stdout"`
	// Level is the desired log level; see colocated zap_logger.go::parseZapLevel()
	Level string `yaml:"level"`
	// OutputFile is the path to the log output file
	OutputFile string `yaml:"outputFile"`
	// Format determines the format of each log file printed to the output.
	// Acceptable values are "json" or "console". The default is "json".
	// Use "console" if you want stack traces to appear on multiple lines.
	Format string `yaml:"format"`
	// Development determines whether the logger is run in Development (== Test) or in
	// Production mode.  Default is Production.  Production-stage disables panics from
	// DPanic logging.
	Development bool `yaml:"development"`
}

Config contains the config items for logger

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)
	DPanic(msg string, tags ...tag.Tag)
	Panic(msg string, tags ...tag.Tag)
	Fatal(msg string, tags ...tag.Tag)
}

Logger is the logging interface. Usage example:

 logger.Info("hello world",
         tag.WorkflowNextEventID(123),
         tag.WorkflowActionWorkflowStarted,
         tag.WorkflowNamespaceID("test-namespace-id")),
	 )
 Note: msg should be static, do not use fmt.Sprintf() for msg. Anything dynamic should be tagged.

func With added in v1.5.7

func With(logger Logger, tags ...tag.Tag) Logger

With returns Logger instance that prepend every log entry with tags. If logger implements WithLogger it is used, otherwise every log call will be intercepted.

type MockLogger

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

MockLogger is a mock of Logger interface.

func NewMockLogger added in v1.5.7

func NewMockLogger(ctrl *gomock.Controller) *MockLogger

NewMockLogger creates a new mock instance.

func (*MockLogger) DPanic added in v1.20.0

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

DPanic mocks base method.

func (*MockLogger) Debug

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

Debug mocks base method.

func (*MockLogger) EXPECT added in v1.5.7

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) Info

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

Info mocks base method.

func (*MockLogger) Panic added in v1.20.0

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

Panic mocks base method.

func (*MockLogger) Warn

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

Warn mocks base method.

type MockLoggerMockRecorder added in v1.5.7

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

MockLoggerMockRecorder is the mock recorder for MockLogger.

func (*MockLoggerMockRecorder) DPanic added in v1.20.0

func (mr *MockLoggerMockRecorder) DPanic(msg interface{}, tags ...interface{}) *gomock.Call

DPanic indicates an expected call of DPanic.

func (*MockLoggerMockRecorder) Debug added in v1.5.7

func (mr *MockLoggerMockRecorder) Debug(msg interface{}, tags ...interface{}) *gomock.Call

Debug indicates an expected call of Debug.

func (*MockLoggerMockRecorder) Error added in v1.5.7

func (mr *MockLoggerMockRecorder) Error(msg interface{}, tags ...interface{}) *gomock.Call

Error indicates an expected call of Error.

func (*MockLoggerMockRecorder) Fatal added in v1.5.7

func (mr *MockLoggerMockRecorder) Fatal(msg interface{}, tags ...interface{}) *gomock.Call

Fatal indicates an expected call of Fatal.

func (*MockLoggerMockRecorder) Info added in v1.5.7

func (mr *MockLoggerMockRecorder) Info(msg interface{}, tags ...interface{}) *gomock.Call

Info indicates an expected call of Info.

func (*MockLoggerMockRecorder) Panic added in v1.20.0

func (mr *MockLoggerMockRecorder) Panic(msg interface{}, tags ...interface{}) *gomock.Call

Panic indicates an expected call of Panic.

func (*MockLoggerMockRecorder) Warn added in v1.5.7

func (mr *MockLoggerMockRecorder) Warn(msg interface{}, tags ...interface{}) *gomock.Call

Warn indicates an expected call of Warn.

type MockSkipLogger added in v1.5.7

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

MockSkipLogger is a mock of SkipLogger interface.

func NewMockSkipLogger added in v1.5.7

func NewMockSkipLogger(ctrl *gomock.Controller) *MockSkipLogger

NewMockSkipLogger creates a new mock instance.

func (*MockSkipLogger) EXPECT added in v1.5.7

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

func (*MockSkipLogger) Skip added in v1.5.7

func (m *MockSkipLogger) Skip(extraSkip int) Logger

Skip mocks base method.

type MockSkipLoggerMockRecorder added in v1.5.7

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

MockSkipLoggerMockRecorder is the mock recorder for MockSkipLogger.

func (*MockSkipLoggerMockRecorder) Skip added in v1.5.7

func (mr *MockSkipLoggerMockRecorder) Skip(extraSkip interface{}) *gomock.Call

Skip indicates an expected call of Skip.

type MockWithLogger added in v1.5.7

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

MockWithLogger is a mock of WithLogger interface.

func NewMockWithLogger added in v1.5.7

func NewMockWithLogger(ctrl *gomock.Controller) *MockWithLogger

NewMockWithLogger creates a new mock instance.

func (*MockWithLogger) EXPECT added in v1.5.7

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

func (*MockWithLogger) With added in v1.5.7

func (m *MockWithLogger) With(tags ...tag.Tag) Logger

With mocks base method.

type MockWithLoggerMockRecorder added in v1.5.7

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

MockWithLoggerMockRecorder is the mock recorder for MockWithLogger.

func (*MockWithLoggerMockRecorder) With added in v1.5.7

func (mr *MockWithLoggerMockRecorder) With(tags ...interface{}) *gomock.Call

With indicates an expected call of With.

type SdkLogger added in v1.5.7

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

func NewSdkLogger added in v1.5.7

func NewSdkLogger(logger Logger) *SdkLogger

func (*SdkLogger) Debug added in v1.5.7

func (l *SdkLogger) Debug(msg string, keyvals ...interface{})

func (*SdkLogger) Error added in v1.5.7

func (l *SdkLogger) Error(msg string, keyvals ...interface{})

func (*SdkLogger) Info added in v1.5.7

func (l *SdkLogger) Info(msg string, keyvals ...interface{})

func (*SdkLogger) Warn added in v1.5.7

func (l *SdkLogger) Warn(msg string, keyvals ...interface{})

func (*SdkLogger) With added in v1.5.7

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

type SkipLogger added in v1.5.7

type SkipLogger interface {
	Skip(extraSkip int) Logger
}

If logger implements SkipLogger then Skip method will be called and extraSkip parameter will have number of extra stack trace frames to skip (useful to log caller func file/line).

type SnTaggedLogger added in v1.19.0

type SnTaggedLogger Logger

Special logger types for use with fx

type ThrottledLogger added in v1.19.0

type ThrottledLogger Logger

type WithLogger added in v1.5.7

type WithLogger interface {
	With(tags ...tag.Tag) Logger
}

Implement WithLogger interface with With method which should return new instance of logger with prepended tags. If WithLogger is not implemented on logger, internal (not very efficient) preppender is used. Create prepended logger example:

logger = log.With(
        logger,
        tag.WorkflowNextEventID(123),
        tag.WorkflowActionWorkflowStarted,
        tag.WorkflowNamespaceID("test-namespace-id"))
...
logger.Info("hello world")

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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