Documentation ¶
Index ¶
- func AddCloudErrorReportingOption(zapLogger *zap.Logger) *zap.Logger
- func GetCloudServiceContextOption(serviceName string) zap.Option
- func NewCloudZapConfig(level, encoding string) zap.Config
- func NewLocalZapConfig(level, encoding string) zap.Config
- type Logger
- func (l *Logger) Debug(msg string, field ...zap.Field)
- func (l *Logger) Debugf(template string, args ...interface{})
- func (l *Logger) Debugw(msg string, keysAndValues ...interface{})
- func (l *Logger) Error(msg string, field ...zap.Field)
- func (l *Logger) Errorf(template string, args ...interface{})
- func (l *Logger) Errorw(msg string, keysAndValues ...interface{})
- func (l *Logger) Fatal(msg string, field ...zap.Field)
- func (l *Logger) Fatalf(template string, args ...interface{})
- func (l *Logger) Fatalw(msg string, keysAndValues ...interface{})
- func (l *Logger) Info(msg string, field ...zap.Field)
- func (l *Logger) Infof(template string, args ...interface{})
- func (l *Logger) Infow(msg string, keysAndValues ...interface{})
- func (l *Logger) Warn(msg string, field ...zap.Field)
- func (l *Logger) Warnf(template string, args ...interface{})
- func (l *Logger) Warnw(msg string, keysAndValues ...interface{})
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCloudErrorReportingOption ¶
AddCloudErrorReportingOption add zap option about Error Reporting. You can use Error Reporting in GCP when you use this function. see: https://cloud.google.com/error-reporting/docs/formatting-error-messages?hl=ja#json_representation
func GetCloudServiceContextOption ¶
GetCloudServiceContextOption get zap.Option about serviceName. You have to call this function when you use Error Reporting. e.g. cloud-run-backend-api
func NewCloudZapConfig ¶
NewCloudZapConfig provides default zap config in cloud environment.
func NewLocalZapConfig ¶
NewLocalZapConfig provides default zap config in local environment.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger provides structured logging in Go / Zap.
func NewCloudLogger ¶
NewCloudLogger is logger constructor in Cloud Environment. It has optional arguments about logger options written on options.go. It has been set Error Reporting and Cloud Logging in GCP by default.
func NewLocalLogger ¶
NewLocalLogger is logger constructor in Local Environment. It has optional arguments about logger options written on options.go.
func (*Logger) Debugw ¶
Debugw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
func (*Logger) Error ¶
Error logs a message at ErrorLevel. If you don't need these wrapper methods, you can override them by parent interface defined on your own. You shoud use this method when you want faster logging, but if you don't want to use zap.Field and depend them, you can use Warnf or Warnw.
func (*Logger) Errorf ¶
Errorf uses fmt.Sprintf to log a templated message. e.g. Errorf("something went wrong: %+v", err) If you don't need these wrapper methods, you can override them by parent interface defined on your own.
func (*Logger) Errorw ¶
Errorw logs a message with some additional context. The variadic key-value pairs are treated as they are in With. e.g. WarnW("something went wrong", "key", "value", "sum", 10) If you don't need these wrapper methods, you can override them by parent interface defined on your own.
func (*Logger) Fatalw ¶
Fatalw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
func (*Logger) Infow ¶
Infow logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
func (*Logger) Warn ¶
Warn logs a message at WarnLevel. If you don't need these wrapper methods, you can override them by parent interface defined on your own. You shoud use this method when you want faster logging, but if you don't want to use zap.Field and depend them, you can use Warnf or Warnw.
func (*Logger) Warnf ¶
Warnf uses fmt.Sprintf to log a templated message. e.g. Warnf("something went wrong: %+v", err) If you don't need these wrapper methods, you can override them by parent interface defined on your own.
func (*Logger) Warnw ¶
Warnw logs a message with some additional context. The variadic key-value pairs are treated as they are in With. e.g. WarnW("something went wrong", "key", "value", "sum", 10) If you don't need these wrapper methods, you can override them by parent interface defined on your own.
type Option ¶
type Option func(*loggerOptions)
Option gives functions changed loggerOptions member. It uses Functional Option Pattern.
func NeedErrorReporting ¶
NeedErrorReporting can assign needErrorReporting.