Skip to content
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

Merged

Conversation

Mixaster995
Copy link
Contributor

Signed-off-by: Mikhail Avramenko [email protected]

Description

Removed excessive chain element setlopoption

Issue link

closes #1147

How Has This Been Tested?

  • Added unit testing to cover
  • Tested manually
  • Tested by integration testing
  • Have not tested

Types of changes

  • Bug fix
  • New functionallity
  • Documentation
  • Refactoring
  • CI

@Mixaster995 Mixaster995 force-pushed the fix/remove-setlogoption branch from 1c47243 to 206497a Compare December 2, 2021 04:31
Copy link
Member

@denis-tingaikin denis-tingaikin left a 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"
Copy link
Member

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

Suggested change
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())
Copy link
Member

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?

Copy link
Contributor Author

@Mixaster995 Mixaster995 Dec 2, 2021

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

Copy link
Member

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.

@Mixaster995 Mixaster995 mentioned this pull request Dec 2, 2021
5 tasks
@@ -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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func New(ctx context.Context) log.Logger {
func New(ctx context.Context, fields ... logrus.Field) log.Logger {

Copy link
Contributor Author

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]>
@Mixaster995 Mixaster995 force-pushed the fix/remove-setlogoption branch from b3329fb to f4b93f6 Compare December 3, 2021 06:16
Comment on lines 186 to 200
// 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
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func New(ctx context.Context, fields ...Field) log.Logger {
func New(ctx context.Context, fields ...logrus.Fields) log.Logger {

Copy link
Contributor Author

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...))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
entry := logrus.WithFields(toMap(fields...))
var entry = logrus.NewEntry(logrus.New())
for _, fieldMap := range fields {
entry = entry.WithFields(fieldMap)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, done

@denis-tingaikin denis-tingaikin merged commit c6c78c3 into networkservicemesh:main Dec 6, 2021
nsmbot pushed a commit to networkservicemesh/cmd-nsmgr that referenced this pull request Dec 6, 2021
…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]>
nsmbot pushed a commit to networkservicemesh/sdk-kernel that referenced this pull request Dec 6, 2021
…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]>
nsmbot pushed a commit to networkservicemesh/cmd-registry-memory that referenced this pull request Dec 6, 2021
…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]>
nsmbot pushed a commit to networkservicemesh/cmd-registry-proxy-dns that referenced this pull request Dec 6, 2021
…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]>
nsmbot pushed a commit to networkservicemesh/sdk-k8s that referenced this pull request Dec 6, 2021
…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]>
nsmbot pushed a commit to networkservicemesh/cmd-nsc-init that referenced this pull request Dec 6, 2021
…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]>
nsmbot pushed a commit to networkservicemesh/cmd-admission-webhook-k8s that referenced this pull request Dec 6, 2021
…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]>
nsmbot pushed a commit to networkservicemesh/cmd-nsmgr-proxy that referenced this pull request Dec 6, 2021
…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]>
nsmbot pushed a commit to networkservicemesh/cmd-nse-vfio that referenced this pull request Dec 6, 2021
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use NewClient instead of NewServerToClient
4 participants