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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。