Git Product home page Git Product logo

Comments (3)

inconshreveable avatar inconshreveable commented on June 12, 2024 1

This is pretty easy to create yourself, and that's the way I'd recommend doing it:

log15.Root().SetHandler(log15.FilterHandler(func(r *Record) bool {
    if r.Lvl == log15.LvlCrit {
        os.Exit(1)
    }
    return true
}, log15.StdoutHandler)

In general though, I wouldn't recommend behavior like this. It's usually much better to return an error and then have your main() function just exit(1) if any of the functions it calls return errors. This makes your code more amenable for reuse as a library.

from log15.

flowchartsman avatar flowchartsman commented on June 12, 2024

Fair enough, and, indeed, I write library code that way specifically for that reason. That said, it's a 6 of one half a dozen of the other situation and this is an "opinionated" framework ;). Feel free to close this, you won't catch any flak from me.

from log15.

inconshreveable avatar inconshreveable commented on June 12, 2024

I like to keep the API minimalist, so I think we'll leave it as is for now. If you want to add that handler to log15/ext though, that would be a good pull request

from log15.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.