GO語言"log"包中"Logger.Output"類型的用法及代碼示例。
用法:
func(l *Logger) Output(calldepth int, s string) error
輸出寫入日誌事件的輸出。字符串 s 包含要在 Logger 的標誌指定的前綴之後打印的文本。如果 s 的最後一個字符還不是換行符,則附加換行符。 Calldepth 用於恢複 PC 並提供一般性,盡管目前在所有預定義路徑上它將是 2。
例子:
package main
import (
"bytes"
"fmt"
"log"
)
func main() {
var (
buf bytes.Buffer
logger = log.New(&buf, "INFO: ", log.Lshortfile)
infof = func(info string) {
logger.Output(2, info)
}
)
infof("Hello world")
fmt.Print(&buf)
}
輸出:
INFO: example_test.go:36: Hello world
相關用法
- GO Logger用法及代碼示例
- GO Log10用法及代碼示例
- GO Log用法及代碼示例
- GO Log2用法及代碼示例
- GO LoadLocation用法及代碼示例
- GO LoadX509KeyPair用法及代碼示例
- GO LookPath用法及代碼示例
- GO LookupEnv用法及代碼示例
- GO Location用法及代碼示例
- GO LeadingZeros32用法及代碼示例
- GO LastIndex用法及代碼示例
- GO LeadingZeros8用法及代碼示例
- GO LeadingZeros16用法及代碼示例
- GO ListenAndServe用法及代碼示例
- GO Listener用法及代碼示例
- GO LastIndexAny用法及代碼示例
- GO Len8用法及代碼示例
- GO ListenAndServeTLS用法及代碼示例
- GO LastIndexFunc用法及代碼示例
- GO Len64用法及代碼示例
注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 Logger.Output。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。