Commit 4e8c1137 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

log/syslog: document that Dial uses net.Dial parameters, add example

Fixes #16761

Change-Id: I709daa87926a31e5f8fd46a4c5ef69718ae349b1
Reviewed-on: https://go-review.googlesource.com/27209Reviewed-by: default avatarChris Broadfoot <cbro@golang.org>
parent 55ea153b
// 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.")
}
......@@ -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")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment