GO语言"log/syslog"包中"Dial"函数的用法及代码示例。
用法:
func Dial(network, raddr string, priority Priority, tag string)(*Writer, error)
Dial 通过连接到指定网络上的地址 raddr 来建立到日志守护程序的连接。对返回的写入器的每次写入都会发送一条日志消息,其中包含设施和严重性(来自优先级)和标签。如果标签为空,则使用 os.Args[0]。如果网络为空,Dial 将连接到本地系统日志服务器。否则,请参阅 net.Dial 的文档以获取 network 和 raddr 的有效值。
例子:
package main
import (
"fmt"
"log"
"log/syslog"
)
func main() {
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.")
}
相关用法
- GO Dial用法及代码示例
- GO Dialer用法及代码示例
- GO Div64用法及代码示例
- GO Div32用法及代码示例
- GO Dim用法及代码示例
- GO Dir用法及代码示例
- GO DecodeLastRuneInString用法及代码示例
- GO DumpResponse用法及代码示例
- GO DB.QueryRowContext用法及代码示例
- GO Date用法及代码示例
- GO DB.ExecContext用法及代码示例
- GO DB.BeginTx用法及代码示例
- GO Decoder.Token用法及代码示例
- GO Decoder.Decode用法及代码示例
- GO DumpRequest用法及代码示例
- GO Drawer用法及代码示例
- GO Duration.Hours用法及代码示例
- GO Duration.Round用法及代码示例
- GO DecodeRuneInString用法及代码示例
- GO DumpRequestOut用法及代码示例
注:本文由纯净天空筛选整理自golang.google.cn大神的英文原创作品 Dial。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。