This may be a noop question to ask but since I have no idea what and how to search for, I decided to to ask this to public. Please leave a comment if you think this question needs an improvement or need more information. I'll try to respond and edit as soon as possible.
I have this simple Go program that uses thirty party logging library called zerolog and prints logs.
package main
import (
"os"
"time"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
func init() {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
zerolog.TimeFieldFormat = zerolog.TimeFormatUnixMs
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: time.RFC3339Nano})
}
func main() {
log.Debug().Msg("This if debugging message")
log.Info().Msg("This is information message")
}
If you simply run this program with $ go run main.go
, it prints out the following result.
2021-06-23T12:45:29.409Z DBG This if debugging message
2021-06-23T12:45:29.41Z INF This is information message
However, if I use nohup
to run this program $ nohup go run main.go &
, then it creates an output file called nohup.out
and writes different log format. Why is that?
[90m2021-06-23T12:59:37.755Z[0m [33mDBG[0m This if debugging message
[90m2021-06-23T12:59:37.756Z[0m [32mINF[0m This is information message
Can anyone kindly explain to me what format this is and how do I convert this to human readable format like the first result?