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

log/syslog: variables and documentation for facility misleading #15731

Closed
awreece opened this issue May 18, 2016 · 3 comments
Closed

log/syslog: variables and documentation for facility misleading #15731

awreece opened this issue May 18, 2016 · 3 comments
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@awreece
Copy link
Contributor

awreece commented May 18, 2016

syslog.Dial and syslog.New take a syslog.Priority as an argument and stores it in a field named priority. This field is used exactly twice:

For examples of someone confused by this in the wild, check out logrus_syslog or golang-samples, which thinks that creating a syslog writer with a severity instead of a facility will do something meaningful:

package main

import (
    "fmt"
    "log/syslog"
)

func test(p syslog.Priority, msg string) {
    w, e := syslog.New(p, msg)
    if e != nil {
        fmt.Println("Error opening syslog", e)
    } else {
        w.Debug("hello, world")
    }
}

func main() {
    test(syslog.LOG_ERR, "ALEX")
    test(syslog.LOG_INFO, "BEN")
    test(syslog.LOG_DAEMON, "CAROLE")
    test(syslog.LOG_USER, "DOUG")
}
<7>1 2016-05-18T10:50:43.326575-07:00 ubuntu-16 ALEX 2517 - -  hello, world
<7>1 2016-05-18T10:50:43.327090-07:00 ubuntu-16 BEN 2517 - -  hello, world
<31>1 2016-05-18T10:50:43.327409-07:00 ubuntu-16 CAROLE 2517 - -  hello, world
<15>1 2016-05-18T10:50:43.327707-07:00 ubuntu-16 DOUG 2517 - -  hello, world

It would be great if facility was a different type from priority, but barring that it would be wonderful to update the documentation here. In particular, I would love to see syslog.New and syslog.Dial take a variable named facility and explain the difference, with an example usage.

I'm happy to do it if such a change could be merged. I see that the package is "frozen" -- will it still accept doc fixes?

@bradfitz
Copy link
Contributor

Documentation changes are fine.

@bradfitz bradfitz added this to the Go1.8Maybe milestone May 18, 2016
@awreece
Copy link
Contributor Author

awreece commented May 18, 2016

The value given to syslog.New is a:

  • priority for syslog.Writer.Write
  • facility for all other consumers of the syslog interface (e.g. syslog.Write.Info)

What is the best way to describe the behavior here? I'd prefer to deprecate that syslog.Writer.Write will use the priority (maybe it should instead default to syslog.LOG_INFO) and to indicate that syslog.New prefers a facility; however we obviously can't break backwards compatibility.

@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 10, 2016
@rsc rsc modified the milestones: Go1.9, Go1.8Maybe Nov 2, 2016
@gopherbot
Copy link

CL https://golang.org/cl/45089 mentions this issue.

@golang golang locked and limited conversation to collaborators Jun 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants