-
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
Improving syslog hook #1225
base: master
Are you sure you want to change the base?
Improving syslog hook #1225
Conversation
…server is down, writing does not degrade if syslog server is slow.
@@ -4,50 +4,96 @@ package syslog | |||
|
|||
import ( | |||
"fmt" | |||
"log/syslog" | |||
//"log/syslog" | |||
"github.com/GolangResources/syslog/syslog" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this package brings to the standard library one ?
w, err := syslog.Dial(network, raddr, priority, tag) | ||
return &SyslogHook{w, network, raddr}, err | ||
func NewSyslogHook(network, raddr string, priority sg.Priority, tag string) (*SyslogHook, error) { | ||
w, err := syslog.Dial("ctcp" , raddr, priority, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is ctcp
?
network, | ||
raddr, | ||
tag, | ||
make(chan *SEntry, CHANNEL_DEPTH), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the channel creation be configurable ?
We need to be able to keep a compatible behaviour with the former version.
make(chan *SEntry, CHANNEL_DEPTH), | ||
} | ||
for i := 0; i <= NUM_SYSLOG_WORKERS; i++ { | ||
go hook.worker(i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to be able to stop the started go routine and to wait for them.
tag, | ||
make(chan *SEntry, CHANNEL_DEPTH), | ||
} | ||
for i := 0; i <= NUM_SYSLOG_WORKERS; i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here we need this hook to be configurable so that we can keep the former behaviour.
|
||
func (hook *SyslogHook) worker(i int) { | ||
for entry := range hook.syschan { | ||
time.Sleep(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there a sleep here ?
func (hook *SyslogHook) worker(i int) { | ||
for entry := range hook.syschan { | ||
time.Sleep(1) | ||
func() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of the closure ?
hello @aluvare thanks for your contribution. |
The syslog library has been changed to prevent crashes if the syslog server is down, writes doesnt degrade if syslog server is slow.