1 개요[ | ]
- Go 패키지 log
- Go log 패키지
- Go 표준 라이브러리 중 하나
Go
CPU
-1.0s
MEM
-0M
-1.0s
Copy
package main
import (
"log"
)
func main() {
log.Print("hello")
log.Print("world")
log.Println("lorem")
log.Println("ipsum")
}
2023/04/18 15:54:09 hello 2023/04/18 15:54:09 world 2023/04/18 15:54:09 lorem 2023/04/18 15:54:09 ipsum
Go
Copy
package main
import (
"bytes"
"fmt"
"log"
)
func main() {
var (
buf bytes.Buffer
logger = log.New(&buf, "logger: ", log.Lshortfile)
)
logger.Print("Hello, log file!")
fmt.Print(&buf)
}
Loading
Go
Copy
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)
}
Loading
2 같이 보기[ | ]
3 참고[ | ]
편집자 Jmnote
로그인하시면 댓글을 쓸 수 있습니다.