Created
February 28, 2018 09:27
-
-
Save jezman/89e74a9fc995766cde08b415ccc0c636 to your computer and use it in GitHub Desktop.
template
This file contains hidden or 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
package main | |
import ( | |
"log" | |
"net/http" | |
"os" | |
) | |
var ( | |
err error | |
logfile *os.File | |
Info *log.Logger | |
Error *log.Logger | |
) | |
func someHandler(w http.ResponseWriter, r *http.Request) { | |
} | |
func main() { | |
logfile, err = os.OpenFile("some.log", os.O_RDWR|os.O_APPEND, 0644) | |
if err != nil { | |
panic(err) | |
} | |
defer logfile.Close() | |
Info = log.New(logfile, "INFO: ", log.Ldate|log.Ltime|log.Lshortfile) | |
Error = log.New(logfile, "ERROR: ", log.Ldate|log.Ltime|log.Lshortfile) | |
http.HandleFunc("/path", someHandler) | |
http.ListenAndServe(":8080", nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment