本文整理匯總了Golang中net/http.Server.ErrorLog方法的典型用法代碼示例。如果您正苦於以下問題:Golang Server.ErrorLog方法的具體用法?Golang Server.ErrorLog怎麽用?Golang Server.ErrorLog使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net/http.Server
的用法示例。
在下文中一共展示了Server.ErrorLog方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RunTLSWithOptions
// RunWithOptions is a convenience function that runs the negroni stack as a
// provided HTTP server, with the following caveats:
// 1. the Handler field of the provided serverConfig should be nil,
// because the Handler used will be the n Negroni object.
func (n *Negroni) RunTLSWithOptions(addr string, certFile string, keyFile string, serverConfig *http.Server) {
l := log.New(os.Stdout, "[negroni] ", 0)
if serverConfig.Addr == "" {
l.Fatal("Address not specified.")
}
if serverConfig.Handler != nil {
l.Fatal("Handler not supported.")
}
// Don't need this since ListenAndServeTLS expects Handler argument
//serverConfig.Handler = n
if serverConfig.ErrorLog == nil {
serverConfig.ErrorLog = l
}
l.Printf("listening on %s with configuration %v\n", serverConfig.Addr, serverConfig)
l.Fatal(serverConfig.ListenAndServeTLS(addr, certFile, keyFile, n))
}
示例2: main
func main() {
err := database.Connect()
if err != nil {
log.Fatal(err)
}
addr := os.Getenv("LISTEN")
if addr == "" {
addr = "0.0.0.0:8443"
}
if os.Getenv("DEBUG") == "true" {
log.SetLevel(log.DebugLevel)
}
var cert tls.Certificate
if certName == "" {
log.Info("Generating self-signed certificate")
cert, err = GenCert()
} else {
log.Info("Using certificate from vault")
cert, err = GetNutcrackerCert()
}
if err != nil {
log.Fatal(err)
}
sock, err := Socket(addr, cert)
if err != nil {
log.Fatal(err)
}
r := mux.NewRouter()
addRoutes(r)
server := new(http.Server)
server.ErrorLog = new(stdLog.Logger)
server.ErrorLog.SetOutput(ioutil.Discard)
server.Addr = addr
server.Handler = context.ClearHandler(r)
log.Infof("HTTPS server listening on: %s", addr)
server.Serve(sock)
}