-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
logrus_syslog ignoring log level #1369
Comments
I only had a quick glance, but would have to look up what the intended design was for this. Having a look at the code, I see that the loglevel passed to Lines 23 to 26 in a448f82
Where
However, the Lines 53 to 55 in a448f82
When the hook is added, that information is used to add a hook for each level it supports; Lines 16 to 22 in a448f82
Which, when hooks are triggered, is used to fire the hook; Lines 26 to 34 in a448f82
From the above, this either was by design (hooks always are tiggered for any level they support), or this was an oversight, and either the Lines 274 to 283 in a448f82
|
Would probably be worth (if you have time for that) to look into history to find what the intended design was here (and if it was by design, or an oversight). |
yup, implementing the interface changing what package main
import (
"log/syslog"
log "github.com/sirupsen/logrus"
logrus_syslog "github.com/sirupsen/logrus/hooks/syslog"
)
type testHook struct {
*logrus_syslog.SyslogHook
}
func (h *testHook) Levels() []log.Level {
return []log.Level{log.WarnLevel}
}
func main() {
log.SetLevel(log.DebugLevel)
hook, err := logrus_syslog.NewSyslogHook("tcp", "localhost:5140", syslog.LOG_WARNING, "test")
if err != nil {
panic(err)
}
log.AddHook(&testHook{hook})
//...
} The original behaviour seems very strange to me. You can specify a level but then it is ignored 🤔 |
This issue is stale because it has been open for 30 days with no activity. |
This commit adds instructions to the syslog readme about how to send different log levels to local logging (`log.SetLevel`) and syslog hook. fixes sirupsen#1369
This commit adds instructions to the syslog readme about how to send different log levels to local logging (`log.SetLevel`) and syslog hook. fixes sirupsen#1369
This commit adds instructions to the syslog readme about how to send different log levels to local logging (`log.SetLevel`) and syslog hook. fixes sirupsen#1369
This issue was closed because it has been inactive for 14 days since being marked as stale. |
Following the docs at https://github.com/sirupsen/logrus/#hooks I'm trying to use an external syslog server to send only WARNING (and above) logs there, while sending debug to local logs. Unfortunately it doesn't seem to work. The external syslog server receives whatever I setup with
log.SetLevel()
instead of the priority argument passed tologrus_syslog.NewSyslogHook
.Am I doing anything wrong here? Maybe I misinterpreted the docs?
The text was updated successfully, but these errors were encountered: