Last active
December 8, 2020 09:54
-
-
Save prestonp/4b9962cca2a7c4b4d938edffb08b0078 to your computer and use it in GitHub Desktop.
quick golang log to file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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