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

Add Severity and VerboseLevel to grpclog. #922

Merged
merged 11 commits into from
Jun 19, 2017
Merged

Conversation

menghanl
Copy link
Contributor

@menghanl menghanl commented Oct 7, 2016

updates #120
updates #1044
#1052
#954
#1059

stringerPrintln
)

type grpclogStringer struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

call this "Stringer" since the package name is grpclog already?

@tamird
Copy link
Contributor

tamird commented Jan 11, 2017

This approach adds an allocation to every logged line 🙍

@menghanl
Copy link
Contributor Author

menghanl commented Jan 11, 2017

Reverted the commit to use stringer, including the memory allocations.
The change was intended to add support for structured logging. Will think about that later.

@beldpro-ci
Copy link

Hey, what's missing here aside the .travis.yml rebase?

@menghanl
Copy link
Contributor Author

menghanl commented Apr 7, 2017

ping

@dfawley
Copy link
Member

dfawley commented Apr 7, 2017

As discussed, please maintain compatibility with older clients by creating a new interface and keeping the old one, and wrapping the old Logger with a new Logger.

Copy link
Member

@dfawley dfawley left a comment

Choose a reason for hiding this comment

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

LGTM, just a few minor things...

"github.com/golang/glog"
"google.golang.org/grpc/grpclog"
)

func init() {
grpclog.SetLogger(&glogger{})
grpclog.SetLoggerv2(&glogger{})
Copy link
Member

Choose a reason for hiding this comment

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

Nit: LoggerV2, not Loggerv2

@@ -37,38 +37,64 @@ Package glogger defines glog-based logging for grpc.
package glogger
Copy link
Member

Choose a reason for hiding this comment

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

How about a usage comment for this package? "Import this package anonymously to activate it as the enabled grpc logger" or something?

@@ -0,0 +1,185 @@
/*
*
* Copyright 2015, Google Inc.
Copy link
Member

Choose a reason for hiding this comment

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

Change the date?


// Loggerv2 does underlying logging work for grpclog.
type Loggerv2 interface {
// Info logs args. Arguments are handled in the manner of fmt.Print.
Copy link
Member

Choose a reason for hiding this comment

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

Info logs args informationally? Or something?

// Error logs will be written to errorW, warningW and infoW.
// Warning logs will be written to warningW and infoW.
// Info logs will be written to infoW.
func NewLoggerv2(infoW io.Writer, warningW io.Writer, errorW io.Writer) Loggerv2 {
Copy link
Member

Choose a reason for hiding this comment

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

infoW, warningW, errorW io.Writer

@@ -0,0 +1,77 @@
/*
*
* Copyright 2016, Google Inc.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: date.

os.Exit(1)
}

// Fatalf is equivalent to Infof() followed by a call to os.Exit() with a non-zero exit code.
Copy link
Member

Choose a reason for hiding this comment

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

Please fix this comment to refer to FATAL log.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

)

// VerboseLevel identifies the verbose level used in grpclog.V() function.
type VerboseLevel int32
Copy link
Member

Choose a reason for hiding this comment

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

Remove this type and use int directly in V.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@bufdev
Copy link
Contributor

bufdev commented Apr 18, 2017

Can we make this more "standard" with regards to popular logging packages, ie github.com/Sirupsen/logrus and github.com/uber-go-zap? Things in particular:

  • Rename Warning to Warn
  • Remove the V function

I don't think https://github.com/golang/glog was ever meant to be this widely used, and it would be nicer for this to be more in line with existing loggers.

Also to note: do we have to support both Foo and Fooln? They generally end up doing the same, but this is an arguable point.

@menghanl
Copy link
Contributor Author

@peter-edge
github.com/Sirupsen/logrus actually has both Warn and Warning.

And also, we want to use V to warp some logs that are off by default.

@menghanl menghanl merged commit 2887f94 into grpc:master Jun 19, 2017
@menghanl menghanl deleted the log branch June 19, 2017 20:57
@menghanl menghanl added 1.5 Type: API Change Breaking API changes (experimental APIs only!) labels Jun 22, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: API Change Breaking API changes (experimental APIs only!)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants