All Projects → snwfdhmp → Errlog

snwfdhmp / Errlog

Licence: mit
Reduce debugging time while programming Go. Use static and stack-trace analysis to determine which func call causes the error.

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Errlog

madbomber
Backtrace-on-throw C++ exception logger
Stars: ✭ 17 (-95.66%)
Mutual labels:  debugging-tool
Objectdiff.js
Compares JavaScript objects
Stars: ✭ 253 (-35.46%)
Mutual labels:  debugging-tool
Tensorwatch
Debugging, monitoring and visualization for Python Machine Learning and Data Science
Stars: ✭ 3,191 (+714.03%)
Mutual labels:  debugging-tool
ripdb
Remotely accessible IPython-enabled debugger
Stars: ✭ 21 (-94.64%)
Mutual labels:  debugging-tool
phpdebugbar
PSR-15 middleware for PHP Debug bar
Stars: ✭ 64 (-83.67%)
Mutual labels:  debugging-tool
Runtimeunityeditor
In-game inspector and debugging tools for applications made with Unity3D game engine
Stars: ✭ 254 (-35.2%)
Mutual labels:  debugging-tool
netext
WinDbg extension for data mining managed heap. It also includes commands to list http request, wcf services, WIF tokens among others
Stars: ✭ 140 (-64.29%)
Mutual labels:  debugging-tool
Bugsnag React Native
Error monitoring and reporting tool for native exceptions and JS errors in React Native apps
Stars: ✭ 374 (-4.59%)
Mutual labels:  debugging-tool
bugsnag-wordpress
Bugsnag error monitoring for WordPress sites
Stars: ✭ 20 (-94.9%)
Mutual labels:  debugging-tool
Tapping device
TappingDevice makes objects tell you what they do, so you don't need to track them yourself.
Stars: ✭ 296 (-24.49%)
Mutual labels:  debugging-tool
guide-charles-proxy
Charles - Web Debugging Proxy Application. I want to share my experiences when I worked with Charles. It is such an amazing application for debugging and testing the presentation of UI when trying different set of data. Hope you guys will master Charles after reading this section. Let’s find out! 🖍
Stars: ✭ 22 (-94.39%)
Mutual labels:  debugging-tool
jquery-manager
Manage jQuery and jQuery Migrate on a WordPress website, activate a specific jQuery and/or jQuery Migrate version. The ultimate jQuery debugging tool for WordPress
Stars: ✭ 27 (-93.11%)
Mutual labels:  debugging-tool
Watchpoints
watchpoints is an easy-to-use, intuitive variable/object monitor tool for python that behaves similar to watchpoints in gdb.
Stars: ✭ 261 (-33.42%)
Mutual labels:  debugging-tool
Mediator
Cross-platform GUI gRPC debugging proxy
Stars: ✭ 36 (-90.82%)
Mutual labels:  debugging-tool
Cocoadebug
iOS Debugging Tool 🚀
Stars: ✭ 3,769 (+861.48%)
Mutual labels:  debugging-tool
XDebugger
A very lightweight library (4Kb) to create a development or production debugger with custom errors readable for humans. Includes errors in table format, logger and search methods with dynamic filters.
Stars: ✭ 18 (-95.41%)
Mutual labels:  debugging-tool
Debugo
一个可能有点用的 iOS 调试工具~
Stars: ✭ 258 (-34.18%)
Mutual labels:  debugging-tool
Superdump
A service for automated crash-dump analysis
Stars: ✭ 384 (-2.04%)
Mutual labels:  debugging-tool
Xcglogger
A debug log framework for use in Swift projects. Allows you to log details to the console (and optionally a file), just like you would have with NSLog() or print(), but with additional information, such as the date, function name, filename and line number.
Stars: ✭ 3,710 (+846.43%)
Mutual labels:  debugging-tool
Uniscribe
Know your Unicode ✀
Stars: ✭ 266 (-32.14%)
Mutual labels:  debugging-tool

Errlog: reduce debugging time while programming Go Report Card Awesome Documentation GitHub issues license

Example

Introduction

Use errlog to improve error logging and speed up debugging while you create amazing code :

  • Highlight source code
  • Detect and point out which func call is causing the fail
  • Pretty stack trace
  • No-op mode for production
  • Easy implementation, adaptable logger
  • Plug to any current project without changing you or your teammates habits
  • Plug to your current logging system
Go to
Get started
Documentation
Examples
Tweaking
Feedbacks
Contributions
License
Contributors

Get started

Install

go get github.com/snwfdhmp/errlog

Usage

Replace your if err != nil with if errlog.Debug(err) to add debugging informations.

func someFunc() {
    //...
    if errlog.Debug(err) { // will debug & pass if err != nil, will ignore if err == nil
        return
    }
}

In production, call errlog.DefaultLogger.Disable(true) to enable no-op (equivalent to if err != nil)

Tweak as you need

You can configure your own logger with the following options :

type Config struct {
    PrintFunc          func(format string, data ...interface{}) //Printer func (eg: fmt.Printf)
    LinesBefore        int  //How many lines to print *before* the error line when printing source code
    LinesAfter         int  //How many lines to print *after* the error line when printing source code
    PrintStack         bool //Shall we print stack trace ? yes/no
    PrintSource        bool //Shall we print source code along ? yes/no
    PrintError         bool //Shall we print the error of Debug(err) ? yes/no
    ExitOnDebugSuccess bool //Shall we os.Exit(1) after Debug has finished logging everything ? (doesn't happen when err is nil). Will soon be replaced by ExitFunc to enable panic-ing the current goroutine. (if you need this quick, please open an issue)
}

As we don't yet update automatically this README immediately when we add new features, this definition may be outdated. (Last update: 2019/08/07) See the struct definition in godoc.org for the up to date definition

Example

Try yourself

Name and link  Description 
Basic standard usage, quick setup
Custom guided configuration for fulfilling your needs
Disabled how to disable the logging & debugging (eg: for production use)
Failing line far away example of finding the func call that caused the error while it is lines away from the errlog.Debug call
Pretty stack trace pretty stack trace printing instead of debugging.

Just read

Basic example

Note that in the example, you will see some unuseful func. Those are made to generate additional stack trace levels for the sake of example

We're going to use this sample program :

func main() {
    fmt.Println("Program start")

    wrapingFunc() //call to our important function

    fmt.Println("Program end")
}

func wrapingFunc() {
    someBigFunction() // call some func 
}

func someBigFunction() {
    someDumbFunction() // just random calls
    someSmallFunction() // just random calls
    someDumbFunction() // just random calls

    // Here it can fail, so instead of `if err  != nil` we use `errlog.Debug(err)`
    if err := someNastyFunction(); errlog.Debug(err) {
        return
    }

    someSmallFunction() // just random calls
    someDumbFunction() // just random calls
}

func someSmallFunction() {
    _ = fmt.Sprintf("I do things !")
}

func someNastyFunction() error {
    return errors.New("I'm failing for some reason") // simulate an error
}

func someDumbFunction() bool {
    return false // just random things
}

Output

Console Output examples/basic.go

We are able to detect and point out which line is causing the error.

Custom Configuration Example

Let's see what we can do with a custom configuration.

debug := errlog.NewLogger(&errlog.Config{
    // PrintFunc is of type `func (format string, data ...interface{})`
    // so you can easily implement your own logger func.
    // In this example, logrus is used, but any other logger can be used.
    // Beware that you should add '\n' at the end of format string when printing.
    PrintFunc:          logrus.Printf,
    PrintSource:        true, //Print the failing source code
    LinesBefore:        2, //Print 2 lines before failing line
    LinesAfter:         1, //Print 1 line after failing line
    PrintError:         true, //Print the error
    PrintStack:         false, //Don't print the stack trace
    ExitOnDebugSuccess: true, //Exit if err
})

Please note: This definition may be outdated. (Last update: 2019/08/07) See the struct definition in godoc.org for the up to date definition

Output

Console Output examples/custom.go

When the failing func call is a few lines away

Even when the func call is a few lines away, there is no problem for finding it.

Output

Source Example: error earlier in the code

Documentation

Documentation can be found here : Documentation

Feedbacks

Feel free to open an issue for any feedback or suggestion.

I fix process issues quickly.

Contributions

We are happy to collaborate with you :

When submitting a PR, please apply Effective Go best practices. For more information: https://golang.org/doc/effective_go.html

License information

Click the following badge to open LICENSE information.

license

Contributors

Major

Minor fixes

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].