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

Improve logs in daemon #352

Merged
merged 10 commits into from
Aug 17, 2018
Merged

Improve logs in daemon #352

merged 10 commits into from
Aug 17, 2018

Conversation

krhubert
Copy link
Contributor

@krhubert krhubert commented Aug 8, 2018

PR for discussion about dameon logs.

Issue 196

Below are logs in text and json formats.

$ ./core
INFO[0000] Starting MESG Core vX.X.X                    
INFO[0000] Server listens on /mesg/server.sock          
INFO[0000] Server listens on [::]:50052                 
INFO[0002] finished unary call with code OK              grpc.code=OK grpc.method=ExecuteTask grpc.service=api.Core grpc.start_time="2018-08-08T21:15:30+02:00" grpc.time_ms=26.072 span.kind=server system=grpc
{"level":"info","msg":"Starting MESG Core vX.X.X","time":"2018-08-08T21:16:37+02:00"}
{"level":"info","msg":"Server listens on [::]:50052","time":"2018-08-08T21:16:37+02:00"}
{"level":"info","msg":"Server listens on /mesg/server.sock","time":"2018-08-08T21:16:37+02:00"}
{"grpc.code":"OK","grpc.method":"ExecuteTask","grpc.service":"api.Core","grpc.start_time":"2018-08-08T21:16:43+02:00","grpc.time_ms":27.99,"level":"info","msg":"finished unary call with code OK","span.kind":"server","system":"grpc","time":"2018-08-08T21:16:43+02:00"}

@mesg-foundation/core Waiting for your feedback.

@krhubert krhubert assigned krhubert and unassigned krhubert Aug 8, 2018
@krhubert krhubert force-pushed the daemon-logs branch 2 times, most recently from 6c3972b to 1cabcd2 Compare August 8, 2018 19:29
api/server.go Outdated
s.instance = grpc.NewServer()
s.instance = grpc.NewServer(
grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(
grpc_logrus.StreamServerInterceptor(log.NewEntry(log.StandardLogger())),
Copy link
Member

Choose a reason for hiding this comment

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

I was thinking this would log all the data in the stream but I cannot see any log from that. I wonder what this is for ? Maybe the StreamClientInterceptor is the one to use.
And should this log all events from the stream or just the connection to the stream ?

@@ -32,9 +31,6 @@ func (execution *Execution) Complete(output string, data map[string]interface{})
execution.Output = output
execution.OutputData = data

Copy link
Member

Choose a reason for hiding this comment

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

I guess you removed the logs here because there is not reason to have them with the rpc middleware

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

@antho1404
Copy link
Member

My logs doesn't look like your

MESG Core is running
time="2018-08-09T05:24:51Z" level=info msg="Starting MESG Core dev local"
time="2018-08-09T05:24:51Z" level=info msg="Server listens on [::]:50052"
time="2018-08-09T05:24:51Z" level=info msg="Server listens on /mesg/server.sock"

Probably because I'm using the ./dev-core that is running the core inside docker and then reading the logs from docker. The logs like that are not really readable

@antho1404
Copy link
Member

antho1404 commented Aug 9, 2018

Everything is good, I just want to fix few things before merge:

  • update the go dependencies in the dockerfile go get github.com/sirupsen/logrus && go get github.com/grpc-ecosystem/go-grpc-middleware
  • update the changelog

Also I like the colored output that is only available with TTY so maybe we should support another flag that might be the default with "colored" or something like that that would put core in a TTY mode and have the colored outputs but this is definitely not required for this PR

@krhubert
Copy link
Contributor Author

@antho1404 done, to merge.

@antho1404
Copy link
Member

I'm ok with this, I'm just thinking should we add the colors on this PR or another one ? the fix is quite easy logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true})

I really think that a nice readable log for human is important but having something in plain text or json is great like that it gives a good flexibility.

Any feedbacks ? @mesg-foundation/core

@krhubert
Copy link
Contributor Author

I'm ok to add some flag to have colors with logs. But forcing color is a bad idea.

@antho1404
Copy link
Member

Sorry I wasn't clear enough in my proposition of the fix, I don't want to replace the text version with the colored one, the text version is really good and a must have, i was talking about another mode like described in my previous comment with "colored".

We would have the 3 following modes:

  • colored (default)
  • text
  • json

I would prefer colored logs by default because it's more user friendly and I think developers who have the need to extract logs will be more comfortable playing with the terminal and using flags etc... and developer who are less comfortable they would prefer something more "human readable" but I would love to have other feedbacks on that

Copy link
Member

@NicolasMahe NicolasMahe left a comment

Choose a reason for hiding this comment

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

Please remove support for colored.

Also the mesg-core start should accept flag to configuration the LogFormat and LogLevel of the Core.

Copy link
Member

@antho1404 antho1404 left a comment

Choose a reason for hiding this comment

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

It is not possible to configure the logs when starting the core with the CLI

MESG_LOG_FORMAT=json ./dev-cli start
./dev-cli logs

That is why a flag for the start command is needed. This flag will send the right env variable to the daemon inside docker

@antho1404
Copy link
Member

antho1404 commented Aug 16, 2018

Ok for me except the PR for dependencies is merged so we have to update this branch and add these dependencies in the vendor

github.com/sirupsen/logrus
github.com/grpc-ecosystem/go-grpc-middleware

Copy link
Member

@NicolasMahe NicolasMahe 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!

@krhubert Please merge dev and add the new packages to vendor.

cmd/start.go Outdated
@@ -18,7 +21,41 @@ var Start = &cobra.Command{
DisableAutoGenTag: true,
}

// logFormatValue reprenets log format flag value.
Copy link
Member

Choose a reason for hiding this comment

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

Typo on "reprenets"

cmd/start.go Outdated
func (v *logFormatValue) Type() string { return "string" }
func (v *logFormatValue) String() string { return string(*v) }

// logLevelValue reprenets log level flag value.
Copy link
Member

Choose a reason for hiding this comment

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

Typo on "reprenets"

@krhubert
Copy link
Contributor Author

@NicolasMahe done

@NicolasMahe NicolasMahe merged commit 2168689 into dev Aug 17, 2018
@NicolasMahe NicolasMahe deleted the daemon-logs branch August 17, 2018 04:04
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.

3 participants