Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

aluvare
Copy link

@aluvare aluvare commented Feb 11, 2021

The syslog library has been changed to prevent crashes if the syslog server is down, writes doesnt degrade if syslog server is slow.

…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"
Copy link
Collaborator

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)
Copy link
Collaborator

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),
Copy link
Collaborator

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)
Copy link
Collaborator

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++ {
Copy link
Collaborator

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)
Copy link
Collaborator

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 {
Copy link
Collaborator

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 ?

@dgsb
Copy link
Collaborator

dgsb commented Feb 19, 2021

hello @aluvare thanks for your contribution.
I've done some comments/questions on your code changes.
We also need passing tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants