summaryrefslogtreecommitdiff
path: root/interfaces
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-11-26 15:30:16 +0300
committerGitHub <[email protected]>2020-11-26 15:30:16 +0300
commitee68279e68ab854ae313fc84ea6a2a905133da87 (patch)
treef0731b1bbbc996347060e8c88d49616090877a65 /interfaces
parent0a48a027642a34c560717526c55f70b7260d678c (diff)
parent7ef7ce5859be3b30476167ee9a2d9d3b0092259a (diff)
Merge pull request #400 from spiral/plugin/http
[RR2] New http plugin for the RR 2.0
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)...))
-}