Source File
log.go
Belonging Package
log
package log
import (
)
const (
Ldate = 1 << iota // the date in the local time zone: 2009/01/23
Ltime // the time in the local time zone: 01:23:23
Lmicroseconds // microsecond resolution: 01:23:23.123123. assumes Ltime.
Llongfile // full file name and line number: /a/b/c/d.go:23
Lshortfile // final file name element and line number: d.go:23. overrides Llongfile
LUTC // if Ldate or Ltime is set, use UTC rather than the local time zone
Lmsgprefix // move the "prefix" from the beginning of the line to before the message
LstdFlags = Ldate | Ltime // initial values for the standard logger
)
func ( *Logger) ( *[]byte, time.Time, string, int) {
if .flag&Lmsgprefix == 0 {
* = append(*, .prefix...)
}
if .flag&(Ldate|Ltime|Lmicroseconds) != 0 {
if .flag&LUTC != 0 {
= .UTC()
}
if .flag&Ldate != 0 {
, , := .Date()
itoa(, , 4)
* = append(*, '/')
itoa(, int(), 2)
* = append(*, '/')
itoa(, , 2)
* = append(*, ' ')
}
if .flag&(Ltime|Lmicroseconds) != 0 {
, , := .Clock()
itoa(, , 2)
* = append(*, ':')
itoa(, , 2)
* = append(*, ':')
itoa(, , 2)
if .flag&Lmicroseconds != 0 {
* = append(*, '.')
itoa(, .Nanosecond()/1e3, 6)
}
* = append(*, ' ')
}
}
if .flag&(Lshortfile|Llongfile) != 0 {
if .flag&Lshortfile != 0 {
:=
for := len() - 1; > 0; -- {
if [] == '/' {
= [+1:]
break
}
}
=
}
* = append(*, ...)
* = append(*, ':')
itoa(, , -1)
* = append(*, ": "...)
}
if .flag&Lmsgprefix != 0 {
* = append(*, .prefix...)
}
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |