GithubHelp home page GithubHelp logo

Comments (6)

sirupsen avatar sirupsen commented on May 23, 2024

Quite true. The default formatters set this. The hook then switches on the level. Did you write your own?

from logrus.

vincentbernat avatar vincentbernat commented on May 23, 2024

I didn't set a customer formatter. I am doing that:

log.SetOutput(os.Stderr)
log.SetLevel(log.WarnLevel)
log.SetLevel(log.DebugLevel)
log.WithField("file", "something").
                Debug("main: parsing configuration file")
syslogOutput, err := logrus_syslog.NewSyslogHook("", "",
                 syslog.LOG_INFO|syslog.LOG_DAEMON, "")
if err != nil {
                  log.Fatal("main: unable to setup syslog output")
}
log.AddHook(syslogOutput)
log.WithField("listen", "something").
                Info("proxy: start serving requests")

from logrus.

sirupsen avatar sirupsen commented on May 23, 2024

Did you try debugging it from the hook? That seems strange.

from logrus.

vincentbernat avatar vincentbernat commented on May 23, 2024

❦ 23 novembre 2014 07:14 -0800, Simon Eskildsen [email protected] :

Why are you setting the level twice?

That's a partial code. I am checking if user asked for more debug and
then check to debug. It was just to show you that I may doing
"inappropriate" stuff like start logging stuff before setting the syslog

hook.

/* Thanks to Rob `CmdrTaco' Malda for not influencing this code in any

  • way.
    */
    2.4.3 linux/net/core/netfilter.c

from logrus.

vincentbernat avatar vincentbernat commented on May 23, 2024

Here is a self contained example:

package main

import (
        log "github.com/Sirupsen/logrus"
        "github.com/Sirupsen/logrus/hooks/syslog"
        "log/syslog"
    "os"
)

func main() {
        /* Setup initial logging */
        log.SetOutput(os.Stderr)
    log.SetLevel(log.DebugLevel)
    syslogOutput, err := logrus_syslog.NewSyslogHook("", "",
        syslog.LOG_INFO|syslog.LOG_DAEMON, "")
    if err != nil {
        log.Fatal("main: unable to setup syslog output")
    }
    log.AddHook(syslogOutput)
    log.Debug("main: this should go to syslog")
}

If I leave syslog.go unchanged, nothing gets logged to syslog. It seems that this is the same problem as with #72. I'll do a pull request for that in a few minutes.

Once fixed, I still have that in syslog:

Nov 23 17:53:23 neo ./test1[31584]: #033[34mDEBU#033[0m[0000] main: this should go to syslog

I wouldn't expect the formatter to be attached only to a given output.

from logrus.

sirupsen avatar sirupsen commented on May 23, 2024

Fixed by #84

from logrus.

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.