Documentation
¶
Overview ¶
Package log is a generated GoMock package.
Index ¶
- type Field
- type Fields
- type Logger
- type MockLogger
- func (m *MockLogger) Debug(arg0 context.Context, arg1 string, arg2 ...Field)
- func (m *MockLogger) EXPECT() *MockLoggerMockRecorder
- func (m *MockLogger) Error(arg0 context.Context, arg1 string, arg2 ...Field)
- func (m *MockLogger) Fatal(arg0 context.Context, arg1 string, arg2 ...Field)
- func (m *MockLogger) Info(arg0 context.Context, arg1 string, arg2 ...Field)
- func (m *MockLogger) Panic(arg0 context.Context, arg1 string, arg2 ...Field)
- func (m *MockLogger) Warn(arg0 context.Context, arg1 string, arg2 ...Field)
- type MockLoggerMockRecorder
- func (mr *MockLoggerMockRecorder) Debug(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call
- func (mr *MockLoggerMockRecorder) Error(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call
- func (mr *MockLoggerMockRecorder) Fatal(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call
- func (mr *MockLoggerMockRecorder) Info(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call
- func (mr *MockLoggerMockRecorder) Panic(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call
- func (mr *MockLoggerMockRecorder) Warn(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call
- type Zap
- func (z *Zap) Debug(ctx context.Context, msg string, fields ...Field)
- func (z *Zap) Error(ctx context.Context, msg string, fields ...Field)
- func (z *Zap) Fatal(ctx context.Context, msg string, fields ...Field)
- func (z *Zap) Info(ctx context.Context, msg string, fields ...Field)
- func (z *Zap) Panic(ctx context.Context, msg string, fields ...Field)
- func (z *Zap) Warn(ctx context.Context, msg string, fields ...Field)
- type ZapConfig
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger interface {
// Error logs a message at ErrorLevel. The message includes any fields passed at the log site, as well as any
// fields accumulated on the logger.
Error(ctx context.Context, msg string, fields ...Field)
// Debug logs a message at DebugLevel. The message includes any fields passed at the log site, as well as any
// fields accumulated on the logger.
Debug(ctx context.Context, msg string, fields ...Field)
// Fatal logs a message at FatalLevel. The message includes any fields passed at the log site, as well as any
// fields accumulated on the logger. The logger then calls os.Exit(1), even if logging at FatalLevel is disabled.
// Defer aren't executed before exit! Use only in appropriated places like simple main() without defer.
Fatal(ctx context.Context, msg string, fields ...Field)
// Info logs a message at InfoLevel. The message includes any fields passed at the log site, as well as any fields
// accumulated on the logger.
Info(ctx context.Context, msg string, fields ...Field)
// Panic logs a message at PanicLevel. The message includes any fields passed at the log site, as well as any fields
// accumulated on the logger. The logger then panics, even if logging at PanicLevel is disabled.
Panic(ctx context.Context, msg string, fields ...Field)
// Warn logs a message at WarnLevel. The message includes any fields passed at the log site, as well as any fields
// accumulated on the logger.
Warn(ctx context.Context, msg string, fields ...Field)
}
Logger defines a common contract we should follow for each new log provider.
type MockLogger ¶
type MockLogger struct {
// contains filtered or unexported fields
}
MockLogger is a mock of Logger interface.
func NewMockLogger ¶
func NewMockLogger(ctrl *gomock.Controller) *MockLogger
NewMockLogger creates a new mock instance.
func (*MockLogger) Debug ¶
func (m *MockLogger) Debug(arg0 context.Context, arg1 string, arg2 ...Field)
Debug mocks base method.
func (*MockLogger) EXPECT ¶
func (m *MockLogger) EXPECT() *MockLoggerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockLogger) Error ¶
func (m *MockLogger) Error(arg0 context.Context, arg1 string, arg2 ...Field)
Error mocks base method.
func (*MockLogger) Fatal ¶
func (m *MockLogger) Fatal(arg0 context.Context, arg1 string, arg2 ...Field)
Fatal mocks base method.
func (*MockLogger) Info ¶
func (m *MockLogger) Info(arg0 context.Context, arg1 string, arg2 ...Field)
Info mocks base method.
type MockLoggerMockRecorder ¶
type MockLoggerMockRecorder struct {
// contains filtered or unexported fields
}
MockLoggerMockRecorder is the mock recorder for MockLogger.
func (*MockLoggerMockRecorder) Debug ¶
func (mr *MockLoggerMockRecorder) Debug(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call
Debug indicates an expected call of Debug.
func (*MockLoggerMockRecorder) Error ¶
func (mr *MockLoggerMockRecorder) Error(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call
Error indicates an expected call of Error.
func (*MockLoggerMockRecorder) Fatal ¶
func (mr *MockLoggerMockRecorder) Fatal(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call
Fatal indicates an expected call of Fatal.
func (*MockLoggerMockRecorder) Info ¶
func (mr *MockLoggerMockRecorder) Info(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call
Info indicates an expected call of Info.
func (*MockLoggerMockRecorder) Panic ¶
func (mr *MockLoggerMockRecorder) Panic(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call
Panic indicates an expected call of Panic.
func (*MockLoggerMockRecorder) Warn ¶
func (mr *MockLoggerMockRecorder) Warn(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call
Warn indicates an expected call of Warn.
type Zap ¶
type Zap struct {
// contains filtered or unexported fields
}
Zap wraps a zap.Logger and implements Logger inteface.
func NewLoggerZap ¶
NewLoggerZap implements Logger using uber zap structured log package.
Example ¶
log, err := NewLoggerZap(ZapConfig{
Version: "v0.1.0",
DisableStackTrace: false,
})
if err != nil {
// panic should not be used outside func main
// but it is not possible to return on it tests
panic(err)
}
ctx := context.Background()
log.Info(ctx, "new log created successfully")
Example (WithTracing) ¶
version := "v0.1.0"
// If is there already a tracer instance of telemetry you should use it
// this imsplementation exists only for example how to add a log tracer on it
tracer := telemetry.NewDataDog(telemetry.DataDogConfig{
Env: "Local", // environment one of: local, development, homolog, production.
Service: "Service", // application service name, it should be the same of it repository ( Github, Bitbucket, etc ).
Version: version, // Code Version, if there is no version control, then use Git Commit Hash instead.
})
log, err := NewLoggerZap(ZapConfig{
Version: version,
DisableStackTrace: false,
Tracer: tracer,
})
if err != nil {
// panic should not be used outside func main
// but it is not possible to return on it tests
panic(err)
}
ctx := context.Background()
log.Info(ctx, "new log created successfully")