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

Correct use of zerolog in the goroutines #689

Open
PeterBocan opened this issue Oct 6, 2024 · 0 comments
Open

Correct use of zerolog in the goroutines #689

PeterBocan opened this issue Oct 6, 2024 · 0 comments

Comments

@PeterBocan
Copy link

Hello,

I am relatively new to the zerolog logger, so apologies if this is trivial question.

I have a following problem - the Zerolog seemingly locks up when printing out from a goroutine. I have a few goroutines using the same logger (no subloggers, or separate loggers). I have a specific goroutine which "watches" over the output of the binaries. It runs over the list of binaries and "forwards" the output from them to the standard output. However this approach only displays one line only.

go func() {
   for {
      select {
      case <- doneWatching:
         return 
      case <- ticker.C:
         for _, binary := range binaries {
             log.Info().Msg(binary.ReadStdout())
         }
      }
   }
} ()

This seemingly innocent code locks up after it prints output from the first binary (iteration). It only prints out from the rest of the buffers when I send a termination signal.

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

No branches or pull requests

1 participant