Git Product home page Git Product logo

Comments (3)

nhi-vanye avatar nhi-vanye commented on August 18, 2024 1

Thank you for very quick response.

I might consider changing the name to be ConsoleWithMaxLevel() to more closely match the behaviour as I think there's a good use-case for a corresponding ConsoleWithMinLevel(). That would make it very easy to separate production from debug logs with multiple handlers off a single Logger...

from slog.

inhere avatar inhere commented on August 18, 2024

hi @nhi-vanye

There are two ways to limit the log level to be recorded in slog:

  1. Use []level to restrict logging to specified level logs
  2. Use max level to limit the maximum log level

In the next version, I will provide some convenient methods to quickly use two methods:

// limit max log level, will log: panic ~ info level logs
h := handler.ConsoleWithLevel(slog.Info)

functions:

// ConsoleWithLevel create new ConsoleHandler and with max log level
func ConsoleWithLevel(level slog.Level) *ConsoleHandler

// ConsoleWithLevels create new ConsoleHandler and with limited log levels
func ConsoleWithLevels(levels []slog.Level) *ConsoleHandler

from slog.

inhere avatar inhere commented on August 18, 2024

Released on the v0.5.3

from slog.

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.