Skip to content
/ erro Public

Reduce debugging time while programming Go. Use static analysis to determine which func call causes the error.

License

Notifications You must be signed in to change notification settings

inkmi/erro

Repository files navigation

Erro: Faster and easier Go debugging in case of an error

Build state Go Version Version Issues Report

gopherbadger-tag-do-not-edit

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

Erro example structured log

into

Erro example pipe output

In an IDE like JetBrains Golang, the line where the error comes from is clickable and takes you to that line.

Erro example Jetbrains output

Example code

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")
}

Install

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

License information

MIT License

Contributors

Major

  • Stephan Schmidt: Author and maintainer
  • Martin Joly wrote the original errlog which this code is based on

About

Reduce debugging time while programming Go. Use static analysis to determine which func call causes the error.

Resources

License

Stars

Watchers

Forks

Packages

No packages published