Skip to content

Instantly share code, notes, and snippets.

@prestonp
Last active December 8, 2020 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prestonp/4b9962cca2a7c4b4d938edffb08b0078 to your computer and use it in GitHub Desktop.
Save prestonp/4b9962cca2a7c4b4d938edffb08b0078 to your computer and use it in GitHub Desktop.
quick golang log to file
import (
"fmt"
"log"
"os"
)
func debug(s string, o ...interface{}) {
f, err := os.OpenFile("/tmp/debug.log",
os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.Println(err)
}
defer f.Close()
fmt.Fprintf(f, s+"\n", o...)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment