Documentation ¶
Overview ¶
Package logging is a generated GoMock package.
Index ¶
- Variables
- func UserString(key, val string) zap.Field
- func UserStrings(key string, val []string) zap.Field
- type Color
- type Config
- type Factory
- type Format
- type Level
- type Logger
- type MockLogger
- func (m *MockLogger) AssertDeferredNoError(f func() error)
- func (m *MockLogger) AssertDeferredTrue(f func() bool, format string, args ...zap.Field)
- func (m *MockLogger) AssertNoError(err error)
- func (m *MockLogger) AssertTrue(b bool, format string, args ...zap.Field)
- func (m *MockLogger) Debug(format string, args ...zap.Field)
- func (m *MockLogger) EXPECT() *MockLoggerMockRecorder
- func (m *MockLogger) Error(format string, args ...zap.Field)
- func (m *MockLogger) Fatal(format string, args ...zap.Field)
- func (m *MockLogger) Info(format string, args ...zap.Field)
- func (m *MockLogger) RecoverAndExit(f, exit func())
- func (m *MockLogger) RecoverAndPanic(f func())
- func (m *MockLogger) Stop()
- func (m *MockLogger) StopOnPanic()
- func (m *MockLogger) Trace(format string, args ...zap.Field)
- func (m *MockLogger) Verbo(format string, args ...zap.Field)
- func (m *MockLogger) Warn(format string, args ...zap.Field)
- func (m *MockLogger) Write(p []byte) (int, error)
- type MockLoggerMockRecorder
- func (mr *MockLoggerMockRecorder) AssertDeferredNoError(f interface{}) *gomock.Call
- func (mr *MockLoggerMockRecorder) AssertDeferredTrue(f, format interface{}, args ...interface{}) *gomock.Call
- func (mr *MockLoggerMockRecorder) AssertNoError(err interface{}) *gomock.Call
- func (mr *MockLoggerMockRecorder) AssertTrue(b, format interface{}, args ...interface{}) *gomock.Call
- func (mr *MockLoggerMockRecorder) Debug(format interface{}, args ...interface{}) *gomock.Call
- func (mr *MockLoggerMockRecorder) Error(format interface{}, args ...interface{}) *gomock.Call
- func (mr *MockLoggerMockRecorder) Fatal(format interface{}, args ...interface{}) *gomock.Call
- func (mr *MockLoggerMockRecorder) Info(format interface{}, args ...interface{}) *gomock.Call
- func (mr *MockLoggerMockRecorder) RecoverAndExit(f, exit interface{}) *gomock.Call
- func (mr *MockLoggerMockRecorder) RecoverAndPanic(f interface{}) *gomock.Call
- func (mr *MockLoggerMockRecorder) Stop() *gomock.Call
- func (mr *MockLoggerMockRecorder) StopOnPanic() *gomock.Call
- func (mr *MockLoggerMockRecorder) Trace(format interface{}, args ...interface{}) *gomock.Call
- func (mr *MockLoggerMockRecorder) Verbo(format interface{}, args ...interface{}) *gomock.Call
- func (mr *MockLoggerMockRecorder) Warn(format interface{}, args ...interface{}) *gomock.Call
- func (mr *MockLoggerMockRecorder) Write(p interface{}) *gomock.Call
- type NoLog
- func (NoLog) AssertDeferredNoError(func() error)
- func (NoLog) AssertDeferredTrue(func() bool, string, ...zap.Field)
- func (NoLog) AssertNoError(error)
- func (NoLog) AssertTrue(bool, string, ...zap.Field)
- func (NoLog) Debug(string, ...zap.Field)
- func (NoLog) Error(string, ...zap.Field)
- func (NoLog) Fatal(string, ...zap.Field)
- func (NoLog) Info(string, ...zap.Field)
- func (NoLog) RecoverAndExit(f, exit func())
- func (NoLog) RecoverAndPanic(f func())
- func (NoLog) Stop()
- func (NoLog) StopOnPanic()
- func (NoLog) Trace(string, ...zap.Field)
- func (NoLog) Verbo(string, ...zap.Field)
- func (NoLog) Warn(string, ...zap.Field)
- func (NoLog) Write([]byte) (int, error)
- type NoWarn
- type RotatingWriterConfig
- type WrappedCore
Constants ¶
This section is empty.
Variables ¶
var ( // Discard is a mock WriterCloser that drops all writes and close requests Discard io.WriteCloser = discard{} )
Functions ¶
func UserString ¶ added in v1.7.17
UserString constructs a field with the given key and the value stripped of newlines. The value is sanitized lazily.
Types ¶
type Color ¶
type Color string
const ( Black Color = "\033[0;30m" DarkGray Color = "\033[1;30m" Red Color = "\033[0;31m" LightRed Color = "\033[1;31m" Green Color = "\033[0;32m" LightGreen Color = "\033[1;32m" Orange Color = "\033[0;33m" Yellow Color = "\033[1;33m" Blue Color = "\033[0;34m" LightBlue Color = "\033[1;34m" Purple Color = "\033[0;35m" LightPurple Color = "\033[1;35m" Cyan Color = "\033[0;36m" LightCyan Color = "\033[1;36m" LightGray Color = "\033[0;37m" White Color = "\033[1;37m" Reset Color = "\033[0;0m" Bold Color = "\033[;1m" Reverse Color = "\033[;7m" )
Colors
type Config ¶
type Config struct { RotatingWriterConfig DisableWriterDisplaying bool `json:"disableWriterDisplaying"` Assertions bool `json:"assertions"` LogLevel Level `json:"logLevel"` DisplayLevel Level `json:"displayLevel"` LogFormat Format `json:"logFormat"` MsgPrefix string `json:"-"` LoggerName string `json:"-"` }
Config defines the configuration of a logger
type Factory ¶
type Factory interface { // Make creates a new logger with name [name] Make(name string) (Logger, error) // MakeChain creates a new logger to log the events of chain [chainID] MakeChain(chainID string) (Logger, error) // SetLogLevels sets log levels for all loggers in factory with given logger name, level pairs. SetLogLevel(name string, level Level) error // SetDisplayLevels sets log display levels for all loggers in factory with given logger name, level pairs. SetDisplayLevel(name string, level Level) error // GetLogLevels returns all log levels in factory as name, level pairs GetLogLevel(name string) (Level, error) // GetDisplayLevels returns all log display levels in factory as name, level pairs GetDisplayLevel(name string) (Level, error) // GetLoggerNames returns the names of all logs created by this factory GetLoggerNames() []string // Close stops and clears all of a Factory's instantiated loggers Close() }
Factory creates new instances of different types of Logger
func NewFactory ¶
NewFactory returns a new instance of a Factory producing loggers configured with the values set in the [config] parameter
type Format ¶ added in v1.7.11
type Format int
Highlight mode to apply to displayed logs
func (Format) ConsoleEncoder ¶ added in v1.7.11
func (Format) FileEncoder ¶ added in v1.7.11
func (Format) MarshalJSON ¶ added in v1.7.11
func (Format) WrapPrefix ¶ added in v1.7.11
type Level ¶
func (Level) LowerString ¶ added in v1.7.11
func (Level) MarshalJSON ¶ added in v1.5.0
func (*Level) UnmarshalJSON ¶ added in v1.5.0
type Logger ¶
type Logger interface { io.Writer // For logging pre-formatted messages // Log that a fatal error has occurred. The program should likely exit soon // after this is called Fatal(msg string, fields ...zap.Field) // Log that an error has occurred. The program should be able to recover // from this error Error(msg string, fields ...zap.Field) // Log that an event has occurred that may indicate a future error or // vulnerability Warn(msg string, fields ...zap.Field) // Log an event that may be useful for a user to see to measure the progress // of the protocol Info(msg string, fields ...zap.Field) // Log an event that may be useful for understanding the order of the // execution of the protocol Trace(msg string, fields ...zap.Field) // Log an event that may be useful for a programmer to see when debuging the // execution of the protocol Debug(msg string, fields ...zap.Field) // Log extremely detailed events that can be useful for inspecting every // aspect of the program Verbo(msg string, fields ...zap.Field) // If assertions are enabled, will result in a panic if err is non-nil AssertNoError(err error) // If assertions are enabled, will result in a panic if b is false AssertTrue(b bool, msg string, fields ...zap.Field) // If assertions are enabled, the function will be called and will result in // a panic the returned value is non-nil AssertDeferredNoError(f func() error) // If assertions are enabled, the function will be called and will result in // a panic the returned value is false AssertDeferredTrue(f func() bool, msg string, fields ...zap.Field) // Recovers a panic, logs the error, and rethrows the panic. StopOnPanic() // If a function panics, this will log that panic and then re-panic ensuring // that the program logs the error before exiting. RecoverAndPanic(f func()) // If a function panics, this will log that panic and then call the exit // function, ensuring that the program logs the error, recovers, and // executes the desired exit function RecoverAndExit(f, exit func()) // Stop this logger and write back all meta-data. Stop() }
Logger defines the interface that is used to keep a record of all events that happen to the program
type MockLogger ¶ added in v1.7.6
type MockLogger struct {
// contains filtered or unexported fields
}
MockLogger is a mock of Logger interface.
func NewMockLogger ¶ added in v1.7.6
func NewMockLogger(ctrl *gomock.Controller) *MockLogger
NewMockLogger creates a new mock instance.
func (*MockLogger) AssertDeferredNoError ¶ added in v1.7.6
func (m *MockLogger) AssertDeferredNoError(f func() error)
AssertDeferredNoError mocks base method.
func (*MockLogger) AssertDeferredTrue ¶ added in v1.7.6
func (m *MockLogger) AssertDeferredTrue(f func() bool, format string, args ...zap.Field)
AssertDeferredTrue mocks base method.
func (*MockLogger) AssertNoError ¶ added in v1.7.6
func (m *MockLogger) AssertNoError(err error)
AssertNoError mocks base method.
func (*MockLogger) AssertTrue ¶ added in v1.7.6
func (m *MockLogger) AssertTrue(b bool, format string, args ...zap.Field)
AssertTrue mocks base method.
func (*MockLogger) Debug ¶ added in v1.7.6
func (m *MockLogger) Debug(format string, args ...zap.Field)
Debug mocks base method.
func (*MockLogger) EXPECT ¶ added in v1.7.6
func (m *MockLogger) EXPECT() *MockLoggerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockLogger) Error ¶ added in v1.7.6
func (m *MockLogger) Error(format string, args ...zap.Field)
Error mocks base method.
func (*MockLogger) Fatal ¶ added in v1.7.6
func (m *MockLogger) Fatal(format string, args ...zap.Field)
Fatal mocks base method.
func (*MockLogger) Info ¶ added in v1.7.6
func (m *MockLogger) Info(format string, args ...zap.Field)
Info mocks base method.
func (*MockLogger) RecoverAndExit ¶ added in v1.7.6
func (m *MockLogger) RecoverAndExit(f, exit func())
RecoverAndExit mocks base method.
func (*MockLogger) RecoverAndPanic ¶ added in v1.7.6
func (m *MockLogger) RecoverAndPanic(f func())
RecoverAndPanic mocks base method.
func (*MockLogger) StopOnPanic ¶ added in v1.7.6
func (m *MockLogger) StopOnPanic()
StopOnPanic mocks base method.
func (*MockLogger) Trace ¶ added in v1.7.6
func (m *MockLogger) Trace(format string, args ...zap.Field)
Trace mocks base method.
func (*MockLogger) Verbo ¶ added in v1.7.6
func (m *MockLogger) Verbo(format string, args ...zap.Field)
Verbo mocks base method.
type MockLoggerMockRecorder ¶ added in v1.7.6
type MockLoggerMockRecorder struct {
// contains filtered or unexported fields
}
MockLoggerMockRecorder is the mock recorder for MockLogger.
func (*MockLoggerMockRecorder) AssertDeferredNoError ¶ added in v1.7.6
func (mr *MockLoggerMockRecorder) AssertDeferredNoError(f interface{}) *gomock.Call
AssertDeferredNoError indicates an expected call of AssertDeferredNoError.
func (*MockLoggerMockRecorder) AssertDeferredTrue ¶ added in v1.7.6
func (mr *MockLoggerMockRecorder) AssertDeferredTrue(f, format interface{}, args ...interface{}) *gomock.Call
AssertDeferredTrue indicates an expected call of AssertDeferredTrue.
func (*MockLoggerMockRecorder) AssertNoError ¶ added in v1.7.6
func (mr *MockLoggerMockRecorder) AssertNoError(err interface{}) *gomock.Call
AssertNoError indicates an expected call of AssertNoError.
func (*MockLoggerMockRecorder) AssertTrue ¶ added in v1.7.6
func (mr *MockLoggerMockRecorder) AssertTrue(b, format interface{}, args ...interface{}) *gomock.Call
AssertTrue indicates an expected call of AssertTrue.
func (*MockLoggerMockRecorder) Debug ¶ added in v1.7.6
func (mr *MockLoggerMockRecorder) Debug(format interface{}, args ...interface{}) *gomock.Call
Debug indicates an expected call of Debug.
func (*MockLoggerMockRecorder) Error ¶ added in v1.7.6
func (mr *MockLoggerMockRecorder) Error(format interface{}, args ...interface{}) *gomock.Call
Error indicates an expected call of Error.
func (*MockLoggerMockRecorder) Fatal ¶ added in v1.7.6
func (mr *MockLoggerMockRecorder) Fatal(format interface{}, args ...interface{}) *gomock.Call
Fatal indicates an expected call of Fatal.
func (*MockLoggerMockRecorder) Info ¶ added in v1.7.6
func (mr *MockLoggerMockRecorder) Info(format interface{}, args ...interface{}) *gomock.Call
Info indicates an expected call of Info.
func (*MockLoggerMockRecorder) RecoverAndExit ¶ added in v1.7.6
func (mr *MockLoggerMockRecorder) RecoverAndExit(f, exit interface{}) *gomock.Call
RecoverAndExit indicates an expected call of RecoverAndExit.
func (*MockLoggerMockRecorder) RecoverAndPanic ¶ added in v1.7.6
func (mr *MockLoggerMockRecorder) RecoverAndPanic(f interface{}) *gomock.Call
RecoverAndPanic indicates an expected call of RecoverAndPanic.
func (*MockLoggerMockRecorder) Stop ¶ added in v1.7.6
func (mr *MockLoggerMockRecorder) Stop() *gomock.Call
Stop indicates an expected call of Stop.
func (*MockLoggerMockRecorder) StopOnPanic ¶ added in v1.7.6
func (mr *MockLoggerMockRecorder) StopOnPanic() *gomock.Call
StopOnPanic indicates an expected call of StopOnPanic.
func (*MockLoggerMockRecorder) Trace ¶ added in v1.7.6
func (mr *MockLoggerMockRecorder) Trace(format interface{}, args ...interface{}) *gomock.Call
Trace indicates an expected call of Trace.
func (*MockLoggerMockRecorder) Verbo ¶ added in v1.7.6
func (mr *MockLoggerMockRecorder) Verbo(format interface{}, args ...interface{}) *gomock.Call
Verbo indicates an expected call of Verbo.
func (*MockLoggerMockRecorder) Warn ¶ added in v1.7.6
func (mr *MockLoggerMockRecorder) Warn(format interface{}, args ...interface{}) *gomock.Call
Warn indicates an expected call of Warn.
func (*MockLoggerMockRecorder) Write ¶ added in v1.7.6
func (mr *MockLoggerMockRecorder) Write(p interface{}) *gomock.Call
Write indicates an expected call of Write.
type NoLog ¶
type NoLog struct{}
func (NoLog) AssertDeferredNoError ¶
func (NoLog) AssertDeferredTrue ¶
func (NoLog) AssertNoError ¶
func (NoLog) RecoverAndExit ¶ added in v0.8.0
func (NoLog) RecoverAndExit(f, exit func())
func (NoLog) RecoverAndPanic ¶
func (NoLog) RecoverAndPanic(f func())
func (NoLog) StopOnPanic ¶
func (NoLog) StopOnPanic()
type RotatingWriterConfig ¶ added in v1.7.11
type WrappedCore ¶ added in v1.7.11
type WrappedCore struct { Core zapcore.Core Writer io.WriteCloser WriterDisabled bool AtomicLevel zap.AtomicLevel }
func NewWrappedCore ¶ added in v1.7.11
func NewWrappedCore(level Level, rw io.WriteCloser, encoder zapcore.Encoder) WrappedCore