summaryrefslogtreecommitdiff
path: root/interfaces
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-11-18 18:15:09 +0300
committerValery Piashchynski <[email protected]>2020-11-18 18:15:09 +0300
commit8fab090abc369237d5f9be2ee676005b24c2a470 (patch)
tree9f7fc358b66357f0218b8256d8073616995b91db /interfaces
parent4ccd58fc363264d24f642ab7e0ccfe6538a0b91c (diff)
Handler test
Diffstat (limited to 'interfaces')
-rw-r--r--interfaces/log/zap_adapter.go56
1 files changed, 0 insertions, 56 deletions
diff --git a/interfaces/log/zap_adapter.go b/interfaces/log/zap_adapter.go
deleted file mode 100644
index 65f8d04b..00000000
--- a/interfaces/log/zap_adapter.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package log
-
-import (
- "fmt"
-
- "go.uber.org/zap"
-)
-
-type ZapAdapter struct {
- zl *zap.Logger
-}
-
-// Create NewZapAdapter which uses general log interface
-func NewZapAdapter(zapLogger *zap.Logger) *ZapAdapter {
- return &ZapAdapter{
- zl: zapLogger.WithOptions(zap.AddCallerSkip(1)),
- }
-}
-
-func (log *ZapAdapter) fields(keyvals []interface{}) []zap.Field {
- // we should have even number of keys and values
- if len(keyvals)%2 != 0 {
- return []zap.Field{zap.Error(fmt.Errorf("odd number of keyvals pairs: %v", keyvals))}
- }
-
- var fields []zap.Field
- for i := 0; i < len(keyvals); i += 2 {
- key, ok := keyvals[i].(string)
- if !ok {
- key = fmt.Sprintf("%v", keyvals[i])
- }
- fields = append(fields, zap.Any(key, keyvals[i+1]))
- }
-
- return fields
-}
-
-func (log *ZapAdapter) Debug(msg string, keyvals ...interface{}) {
- log.zl.Debug(msg, log.fields(keyvals)...)
-}
-
-func (log *ZapAdapter) Info(msg string, keyvals ...interface{}) {
- log.zl.Info(msg, log.fields(keyvals)...)
-}
-
-func (log *ZapAdapter) Warn(msg string, keyvals ...interface{}) {
- log.zl.Warn(msg, log.fields(keyvals)...)
-}
-
-func (log *ZapAdapter) Error(msg string, keyvals ...interface{}) {
- log.zl.Error(msg, log.fields(keyvals)...)
-}
-
-func (log *ZapAdapter) With(keyvals ...interface{}) Logger {
- return NewZapAdapter(log.zl.With(log.fields(keyvals)...))
-}