]> Cypherpunks repositories - gostls13.git/commitdiff
log/syslog: document that Dial uses net.Dial parameters, add example
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 17 Aug 2016 14:32:49 +0000 (14:32 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 19 Aug 2016 01:01:47 +0000 (01:01 +0000)
Fixes #16761

Change-Id: I709daa87926a31e5f8fd46a4c5ef69718ae349b1
Reviewed-on: https://go-review.googlesource.com/27209
Reviewed-by: Chris Broadfoot <cbro@golang.org>
src/log/syslog/example_test.go [new file with mode: 0644]
src/log/syslog/syslog.go

diff --git a/src/log/syslog/example_test.go b/src/log/syslog/example_test.go
new file mode 100644 (file)
index 0000000..3d5b76d
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !windows,!nacl,!plan9
+
+package syslog_test
+
+import (
+       "fmt"
+       "log"
+       "log/syslog"
+)
+
+func ExampleDial() {
+       sysLog, err := syslog.Dial("tcp", "localhost:1234",
+               syslog.LOG_WARNING|syslog.LOG_DAEMON, "demotag")
+       if err != nil {
+               log.Fatal(err)
+       }
+       fmt.Fprintf(sysLog, "This is a daemon warning with demotag.")
+       sysLog.Emerg("And this is a daemon emergency with demotag.")
+}
index 9e888dd1d9dd4d92ba9a7b71847cdbec27fec3e7..df9ffb8e331c0695f39e80599598fcaa278a6c76 100644 (file)
@@ -112,6 +112,8 @@ func New(priority Priority, tag string) (*Writer, error) {
 // writer sends a log message with the given facility, severity and
 // tag.
 // If network is empty, Dial will connect to the local syslog server.
+// Otherwise, see the documentation for net.Dial for valid values
+// of network and raddr.
 func Dial(network, raddr string, priority Priority, tag string) (*Writer, error) {
        if priority < 0 || priority > LOG_LOCAL7|LOG_DEBUG {
                return nil, errors.New("log/syslog: invalid priority")