本文整理汇总了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)
}