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: using log flags and a tag at the same time #5689

Closed
gopherbot opened this issue Jun 12, 2013 · 7 comments
Closed

log/syslog: using log flags and a tag at the same time #5689

gopherbot opened this issue Jun 12, 2013 · 7 comments

Comments

@gopherbot
Copy link

by pierre.louis.roman:

syslog.NewLogger() allow me to specify flags but not a tag; if I want one, I have to
copy/paste the code of this function and replace the "" with my tag.
Code: http://golang.org/src/pkg/log/syslog/syslog.go#L271

How about a third argument for this function in order to allow the user to specify a tag?
The (very small) patch can be found in the attached files. Maybe the format of the diff
isn't the expected one, but the patch is easily reproductible.

go test works fine with it.

Which operating system are you using?
linux/amd64

Which version are you using?  (run 'go version')
1.1

Attachments:

  1. diff_syslog.go (501 bytes)
  2. diff_syslog_test.go (337 bytes)
@minux
Copy link
Member

minux commented Jun 12, 2013

Comment 1:

sorry, we can't make incompatible changes like that given our Go 1 API promises.

@minux
Copy link
Member

minux commented Jun 12, 2013

Comment 2:

also, it's very easy to duplicate the code for syslog.NewLogger in your application.

@gopherbot
Copy link
Author

Comment 3 by pierre.louis.roman:

Didn't think about that issue, you're right.
I agree it is easy to duplicate the code, that's what I did, but adding an argument
seems easier, proper, and would let everybody else use this feature.
Adding a function with three arguments, and let the one with two arguments unchanged,
would be compatible, but perhaps it would not be the "go way". See the attached file.
And thanks for the feedback.

Attachments:

  1. diff_syslog.go (783 bytes)

@minux
Copy link
Member

minux commented Jun 12, 2013

Comment 4:

forgot to mention that there is a SetPrefix for log.Logger.
http://golang.org/pkg/log/#Logger.SetPrefix

@gopherbot
Copy link
Author

Comment 5 by pierre.louis.roman:

Yes there is, but the prefix is printed at the beginning of the line while the tag is
included in the syslog line, which format is also used by other programs.
http://golang.org/src/pkg/log/syslog/syslog.go#L251
So they are two different strings.
Using syslog.NewLogger() forces you to have the absolute path to the executable as a tag
because the tag is set to "", see:
http://golang.org/src/pkg/log/syslog/syslog.go#L110

@bradfitz
Copy link
Contributor

Comment 6:

Sorry, we don't want additions to this package.
We regret adding syslog to the standard library and are not accepting additions to it. 
Like Minux said, this can be done easily enough by caller code. If that's too onerous,
feel free to fork log/syslog on github to extend it.

Status changed to WorkingAsIntended.

@gopherbot
Copy link
Author

Comment 7 by pierre.louis.roman:

Ok, I understand the points of view, I'll simply keep writing it in the caller code as
before.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants