mirror of
https://github.com/PeernetOfficial/core.git
synced 2026-07-17 02:47:51 +01:00
New config field LogTarget. Simplified function backend.LogError.
This commit is contained in:
@@ -111,7 +111,7 @@ func Start(Backend *core.Backend, ListenAddresses []string, UseSSL bool, Certifi
|
||||
// startWebAPI starts a web-server with given parameters and logs the status. If may block forever and only returns if there is an error.
|
||||
// The certificate file and key are only used if SSL is enabled. The read and write timeout may be 0 for no timeout.
|
||||
func startWebAPI(Backend *core.Backend, WebListen string, UseSSL bool, CertificateFile, CertificateKey string, Handler http.Handler, Info string, ReadTimeout, WriteTimeout time.Duration) {
|
||||
Backend.Filters.LogError("startWebAPI", "Start API at '%s'\n", WebListen)
|
||||
Backend.LogError("startWebAPI", "Start API at '%s'\n", WebListen)
|
||||
|
||||
tlsConfig := &tls.Config{MinVersion: tls.VersionTLS12} // for security reasons disable TLS 1.0/1.1
|
||||
|
||||
@@ -127,12 +127,12 @@ func startWebAPI(Backend *core.Backend, WebListen string, UseSSL bool, Certifica
|
||||
if UseSSL {
|
||||
// HTTPS
|
||||
if err := server.ListenAndServeTLS(CertificateFile, CertificateKey); err != nil {
|
||||
Backend.Filters.LogError("startWebAPI", "Error listening on '%s': %v\n", WebListen, err)
|
||||
Backend.LogError("startWebAPI", "Error listening on '%s': %v\n", WebListen, err)
|
||||
}
|
||||
} else {
|
||||
// HTTP
|
||||
if err := server.ListenAndServe(); err != nil {
|
||||
Backend.Filters.LogError("startWebAPI", "Error listening on '%s': %v\n", WebListen, err)
|
||||
Backend.LogError("startWebAPI", "Error listening on '%s': %v\n", WebListen, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,7 +143,7 @@ func EncodeJSON(Backend *core.Backend, w http.ResponseWriter, r *http.Request, d
|
||||
|
||||
err = json.NewEncoder(w).Encode(data)
|
||||
if err != nil {
|
||||
Backend.Filters.LogError("EncodeJSON", "Error writing data for route '%s': %v\n", r.URL.Path, err)
|
||||
Backend.LogError("EncodeJSON", "Error writing data for route '%s': %v\n", r.URL.Path, err)
|
||||
}
|
||||
|
||||
return err
|
||||
|
||||
@@ -29,7 +29,7 @@ func (api *WebapiInstance) apiWarehouseCreateFile(w http.ResponseWriter, r *http
|
||||
hash, status, err := api.backend.UserWarehouse.CreateFile(r.Body, 0)
|
||||
|
||||
if err != nil {
|
||||
api.backend.Filters.LogError("warehouse.CreateFile", "status %d error: %v", status, err)
|
||||
api.backend.LogError("warehouse.CreateFile", "status %d error: %v", status, err)
|
||||
}
|
||||
|
||||
EncodeJSON(api.backend, w, r, WarehouseResult{Status: status, Hash: hash})
|
||||
@@ -54,7 +54,7 @@ func (api *WebapiInstance) apiWarehouseCreateFilePath(w http.ResponseWriter, r *
|
||||
hash, status, err := api.backend.UserWarehouse.CreateFileFromPath(filePath)
|
||||
|
||||
if err != nil {
|
||||
api.backend.Filters.LogError("warehouse.CreateFile", "status %d error: %v", status, err)
|
||||
api.backend.LogError("warehouse.CreateFile", "status %d error: %v", status, err)
|
||||
}
|
||||
|
||||
EncodeJSON(api.backend, w, r, WarehouseResult{Status: status, Hash: hash})
|
||||
@@ -94,7 +94,7 @@ func (api *WebapiInstance) apiWarehouseReadFile(w http.ResponseWriter, r *http.R
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
api.backend.Filters.LogError("warehouse.ReadFile", "status %d read %d error: %v", status, bytesRead, err)
|
||||
api.backend.LogError("warehouse.ReadFile", "status %d read %d error: %v", status, bytesRead, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ func (api *WebapiInstance) apiWarehouseDeleteFile(w http.ResponseWriter, r *http
|
||||
status, err := api.backend.UserWarehouse.DeleteFile(hash)
|
||||
|
||||
if err != nil {
|
||||
api.backend.Filters.LogError("warehouse.DeleteFile", "status %d error: %v", status, err)
|
||||
api.backend.LogError("warehouse.DeleteFile", "status %d error: %v", status, err)
|
||||
}
|
||||
|
||||
EncodeJSON(api.backend, w, r, WarehouseResult{Status: status, Hash: hash})
|
||||
@@ -144,7 +144,7 @@ func (api *WebapiInstance) apiWarehouseReadFilePath(w http.ResponseWriter, r *ht
|
||||
status, bytesRead, err := api.backend.UserWarehouse.ReadFileToDisk(hash, int64(offset), int64(limit), targetFile)
|
||||
|
||||
if err != nil {
|
||||
api.backend.Filters.LogError("warehouse.ReadFileToDisk", "status %d read %d error: %v", status, bytesRead, err)
|
||||
api.backend.LogError("warehouse.ReadFileToDisk", "status %d read %d error: %v", status, bytesRead, err)
|
||||
}
|
||||
|
||||
EncodeJSON(api.backend, w, r, WarehouseResult{Status: status, Hash: hash})
|
||||
|
||||
Reference in New Issue
Block a user