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

Need a light on this, please. #25

Closed
MichelDiz opened this issue Jul 30, 2018 · 2 comments
Closed

Need a light on this, please. #25

MichelDiz opened this issue Jul 30, 2018 · 2 comments
Labels

Comments

@MichelDiz
Copy link

Hello,
OBS. I am extremely new with Golang.

I'm looking for a solution to an idea, I want to improve the output of this program:
https://github.com/dgraph-io/dgraph/tree/master/dgraph/cmd/live

I seek for bars like mpb (sounds like brasilian music LOL) but that it can generate a clean output. All projects with bars generate many lines (per second). I'm using | & tee -a bartest.txt to test.

go run main.go |& tee -a bartest.txt

I wonder if it would be possible to combine the best of both worlds. Bar + a clean output.

The program also issues errors while continuing the process. It would be interesting to display the errors while the progress bar maintains its rhythm. And the output also collects the errors.

At the end of the process if is either fatal error, cancellation, SIGTERM or something else. The program still generates a clean output of what happened.

All this Would it be possible?

This would be an example of the current output


2018/07/29 22:31:59 run.go:337: Creating temp client directory at /var/folders/vb/l72zg91129q5wyqygw59cr2h0000gn/T/x236306353
Processing 21million.schema
2018/07/29 22:32:00 run.go:354: Processed schema file
Processing 1million.rdf.gz
Total Txns done:        0 RDFs per second:       0 Time Elapsed: 2s, Aborts: 0
Total Txns done:        0 RDFs per second:       0 Time Elapsed: 4s, Aborts: 0
Total Txns done:        0 RDFs per second:       0 Time Elapsed: 6s, Aborts: 0
Total Txns done:        0 RDFs per second:       0 Time Elapsed: 8s, Aborts: 0
Total Txns done:      323 RDFs per second:    1564 Time Elapsed: 3m26s, Aborts: 0
2018/07/29 22:35:27 batch.go:125: Error while mutating Predicate is being moved, please retry later
Total Txns done:      327 RDFs per second:    1568 Time Elapsed: 3m28s, Aborts: 1
2018/07/29 22:35:28 batch.go:125: Error while mutating Predicate is being moved, please retry later
2018/07/29 22:35:28 batch.go:125: Error while mutating Predicate is being moved, please retry later
2018/07/29 22:35:28 batch.go:125: Error while mutating Predicate is being moved, please retry later

It displays transactions, time and possible aborts.

@vbauerster
Copy link
Owner

Hello!
If I understood correctly, you'd like to output an error while a bar is running?
If so, there are several ways to achieve this.

  1. Output error message below a bar, when there is an error. BarNewLineExtend option is your friend here, refer to example.
  2. Display an error in place of some decorator, in that case you need to implement custom decorator.
    I used this approach here.

@MichelDiz
Copy link
Author

MichelDiz commented Aug 1, 2018

Hi vbauerster!

Thanks for the answer

Actually I'm thinking now and do something like this https://stackoverflow.com/questions/19965795/go-golang-write-log-to-file at the same time that we show the bars.

In my case it would be a mixture of your approach with this approach of writing Logs to a file.

I have not started anything yet, still probing and also starting with Go Language.

PS. The big problem is that when I use go run main.go | & tee -a bartest.txt
I get a gigantic and ugly Log. This is not what you want in a log file.

Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants