Standard library / log
log.Output()
Write a message with explicit source stack depth and return writer errors. Expected stdout: 'hello\n'.
Formal Syntax & Structure
go syntaxgo
func Output(calldepth int, s string) errorParameters & Attributes
| Name | Type | Description |
|---|---|---|
| calldepth | int | Number of stack frames to skip for source attribution. |
| s | string | Message text. |
Return Value
error
Write a message with explicit source stack depth and return writer errors.
Working Example
Example Snippetgo
package main
import ( "bytes" "fmt" "log")
func check(e error) { if e != nil { panic(e) }}
func main() { var b bytes.Buffer log.SetOutput(&b) log.SetFlags(0) log.SetPrefix("") check(log.Output(1, "hello")) fmt.Print(b.String())}