-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
removed usage of setlogoption chain element #1186
removed usage of setlogoption chain element #1186
Conversation
Signed-off-by: Mikhail Avramenko <[email protected]>
1c47243
to
206497a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Added a few comments.
@@ -27,6 +27,10 @@ import ( | |||
"github.com/networkservicemesh/sdk/pkg/tools/log/spanlogger" | |||
) | |||
|
|||
const ( | |||
loggedType = "registry" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use this inline
loggedType = "registry" |
@@ -185,7 +185,7 @@ func (s *logrusLogger) WithField(key, value interface{}) log.Logger { | |||
|
|||
// New - creates a logruslogger and returns it | |||
func New(ctx context.Context) log.Logger { | |||
entry := logrus.WithFields(log.Fields(ctx)) | |||
entry := logrus.NewEntry(logrus.StandardLogger()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this changed?
Also, who is using logruslogger.New?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i removed log.Fields(ctx)
method, so it had to be changed
logruslogger.New
used in cmd-...
s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note, cmd- previously could put fields into ctx. So please add logrus.Field variadic.
@@ -185,7 +185,7 @@ func (s *logrusLogger) WithField(key, value interface{}) log.Logger { | |||
|
|||
// New - creates a logruslogger and returns it | |||
func New(ctx context.Context) log.Logger { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func New(ctx context.Context) log.Logger { | |
func New(ctx context.Context, fields ... logrus.Field) log.Logger { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, done
Signed-off-by: Mikhail Avramenko <[email protected]>
b3329fb
to
f4b93f6
Compare
// Field is simple key value pair | ||
type Field struct { | ||
key string | ||
val interface{} | ||
} | ||
|
||
func toMap(fields ...Field) map[string]interface{} { | ||
rv := make(map[string]interface{}) | ||
|
||
for _, f := range fields { | ||
rv[f.key] = f.val | ||
} | ||
|
||
return rv | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Field is simple key value pair | |
type Field struct { | |
key string | |
val interface{} | |
} | |
func toMap(fields ...Field) map[string]interface{} { | |
rv := make(map[string]interface{}) | |
for _, f := range fields { | |
rv[f.key] = f.val | |
} | |
return rv | |
} |
// New - creates a logruslogger and returns it | ||
func New(ctx context.Context) log.Logger { | ||
entry := logrus.NewEntry(logrus.StandardLogger()) | ||
func New(ctx context.Context, fields ...Field) log.Logger { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func New(ctx context.Context, fields ...Field) log.Logger { | |
func New(ctx context.Context, fields ...logrus.Fields) log.Logger { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, done
func New(ctx context.Context) log.Logger { | ||
entry := logrus.NewEntry(logrus.StandardLogger()) | ||
func New(ctx context.Context, fields ...Field) log.Logger { | ||
entry := logrus.WithFields(toMap(fields...)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entry := logrus.WithFields(toMap(fields...)) | |
var entry = logrus.NewEntry(logrus.New()) | |
for _, fieldMap := range fields { | |
entry = entry.WithFields(fieldMap) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, done
Signed-off-by: Mikhail Avramenko <[email protected]>
…k@main PR link: networkservicemesh/sdk#1186 Commit: c6c78c3 Author: Авраменко Михаил Date: 2021-12-06 14:26:30 +0700 Message: - removed usage of setlogoption chain element (#1186) * removed usage of setlogoption chain element Signed-off-by: Mikhail Avramenko <[email protected]> * added variadic fields to log creation Signed-off-by: Mikhail Avramenko <[email protected]> * used logrus fields instead of custom type Signed-off-by: NSMBot <[email protected]>
…k@main PR link: networkservicemesh/sdk#1186 Commit: c6c78c3 Author: Авраменко Михаил Date: 2021-12-06 14:26:30 +0700 Message: - removed usage of setlogoption chain element (#1186) * removed usage of setlogoption chain element Signed-off-by: Mikhail Avramenko <[email protected]> * added variadic fields to log creation Signed-off-by: Mikhail Avramenko <[email protected]> * used logrus fields instead of custom type Signed-off-by: NSMBot <[email protected]>
…k@main PR link: networkservicemesh/sdk#1186 Commit: c6c78c3 Author: Авраменко Михаил Date: 2021-12-06 14:26:30 +0700 Message: - removed usage of setlogoption chain element (#1186) * removed usage of setlogoption chain element Signed-off-by: Mikhail Avramenko <[email protected]> * added variadic fields to log creation Signed-off-by: Mikhail Avramenko <[email protected]> * used logrus fields instead of custom type Signed-off-by: NSMBot <[email protected]>
…k@main PR link: networkservicemesh/sdk#1186 Commit: c6c78c3 Author: Авраменко Михаил Date: 2021-12-06 14:26:30 +0700 Message: - removed usage of setlogoption chain element (#1186) * removed usage of setlogoption chain element Signed-off-by: Mikhail Avramenko <[email protected]> * added variadic fields to log creation Signed-off-by: Mikhail Avramenko <[email protected]> * used logrus fields instead of custom type Signed-off-by: NSMBot <[email protected]>
…k@main PR link: networkservicemesh/sdk#1186 Commit: c6c78c3 Author: Авраменко Михаил Date: 2021-12-06 14:26:30 +0700 Message: - removed usage of setlogoption chain element (#1186) * removed usage of setlogoption chain element Signed-off-by: Mikhail Avramenko <[email protected]> * added variadic fields to log creation Signed-off-by: Mikhail Avramenko <[email protected]> * used logrus fields instead of custom type Signed-off-by: NSMBot <[email protected]>
…k@main PR link: networkservicemesh/sdk#1186 Commit: c6c78c3 Author: Авраменко Михаил Date: 2021-12-06 14:26:30 +0700 Message: - removed usage of setlogoption chain element (#1186) * removed usage of setlogoption chain element Signed-off-by: Mikhail Avramenko <[email protected]> * added variadic fields to log creation Signed-off-by: Mikhail Avramenko <[email protected]> * used logrus fields instead of custom type Signed-off-by: NSMBot <[email protected]>
…k@main PR link: networkservicemesh/sdk#1186 Commit: c6c78c3 Author: Авраменко Михаил Date: 2021-12-06 14:26:30 +0700 Message: - removed usage of setlogoption chain element (#1186) * removed usage of setlogoption chain element Signed-off-by: Mikhail Avramenko <[email protected]> * added variadic fields to log creation Signed-off-by: Mikhail Avramenko <[email protected]> * used logrus fields instead of custom type Signed-off-by: NSMBot <[email protected]>
…k@main PR link: networkservicemesh/sdk#1186 Commit: c6c78c3 Author: Авраменко Михаил Date: 2021-12-06 14:26:30 +0700 Message: - removed usage of setlogoption chain element (#1186) * removed usage of setlogoption chain element Signed-off-by: Mikhail Avramenko <[email protected]> * added variadic fields to log creation Signed-off-by: Mikhail Avramenko <[email protected]> * used logrus fields instead of custom type Signed-off-by: NSMBot <[email protected]>
…k@main PR link: networkservicemesh/sdk#1186 Commit: c6c78c3 Author: Авраменко Михаил Date: 2021-12-06 14:26:30 +0700 Message: - removed usage of setlogoption chain element (#1186) * removed usage of setlogoption chain element Signed-off-by: Mikhail Avramenko <[email protected]> * added variadic fields to log creation Signed-off-by: Mikhail Avramenko <[email protected]> * used logrus fields instead of custom type Signed-off-by: NSMBot <[email protected]>
Signed-off-by: Mikhail Avramenko [email protected]
Description
Removed excessive chain element
setlopoption
Issue link
closes #1147
How Has This Been Tested?
Types of changes