Initially forked from snwfdhmp/errlog
Erro (pronounced 'arrow') is a simple tool that helps finding the reasons for errors in your code.
Currently supported languages:
- Golang
Piping your structured log into erro
yourProgram 2>&1 | erro
turns
into
In an IDE like JetBrains Golang, the line where the error comes from is clickable and takes you to that line.
func main() {
logger := log.With().Caller().Logger()
logger.Info().Msg("Welcome to erro 🧑🚀")
logger.Info().Msg("https://github.com/inkmi/erro")
logger.Info().Int("Hello", 42).Msg("Info example")
logger.Trace().Int("Hello", 23).Msg("Trace example")
logger.Debug().Str("Hello", "🦄").Msg("Debug example")
logger.Warn().Str("Hello", "World").Msg("Warn example")
err := errors.New("Testerror")
logger.Error().Err(err).Str("Test", "Test").Msg("Error example")
logger.Info().Int("After", 1).Int("Days", 2).Msg("After the error")
}
go install github.com/inkmi/erro
The log data needs to be structured as JSON.
The log data needs to include caller information, for example
{ "caller": "testerro.go:22" }
Configuration depends on your logging library, for Zerolog it's
logger := log.With().Caller().Logger()
After make build
you can test erro
with
./bin/testerro 2>&1| ./bin/erro
MIT License
- Stephan Schmidt: Author and maintainer
- Martin Joly wrote the original errlog which this code is based on