mirror of
https://github.com/pgsty/minio.git
synced 2026-07-21 13:10:22 +03:00
logging: Log only for unhandled errors, remove all the debug logging. (#1652)
This patch brings in the removal of debug logging altogether, instead we bring in the functionality of being able to trace the errors properly pointing back to the origination of the problem. To enable tracing you need to enable "MINIO_TRACE" set to "1" or "true" environment variable which would print back traces whenever there is an error which is unhandled or at the handler layer. By default this tracing is turned off and only user level logging is provided.
This commit is contained in:
committed by
Anand Babu (AB) Periasamy
parent
8828fd1e5c
commit
9472299308
@@ -6,7 +6,6 @@ import (
|
||||
"net/rpc"
|
||||
"strconv"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
router "github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
@@ -22,9 +21,6 @@ type storageServer struct {
|
||||
func (s *storageServer) MakeVolHandler(arg *string, reply *GenericReply) error {
|
||||
err := s.storage.MakeVol(*arg)
|
||||
if err != nil {
|
||||
log.WithFields(logrus.Fields{
|
||||
"volume": *arg,
|
||||
}).Debugf("MakeVol failed with error %s", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -34,7 +30,6 @@ func (s *storageServer) MakeVolHandler(arg *string, reply *GenericReply) error {
|
||||
func (s *storageServer) ListVolsHandler(arg *string, reply *ListVolsReply) error {
|
||||
vols, err := s.storage.ListVols()
|
||||
if err != nil {
|
||||
log.Debugf("Listsvols failed with error %s", err)
|
||||
return err
|
||||
}
|
||||
reply.Vols = vols
|
||||
@@ -45,9 +40,6 @@ func (s *storageServer) ListVolsHandler(arg *string, reply *ListVolsReply) error
|
||||
func (s *storageServer) StatVolHandler(arg *string, reply *VolInfo) error {
|
||||
volInfo, err := s.storage.StatVol(*arg)
|
||||
if err != nil {
|
||||
log.WithFields(logrus.Fields{
|
||||
"volume": *arg,
|
||||
}).Debugf("StatVol failed with error %s", err)
|
||||
return err
|
||||
}
|
||||
*reply = volInfo
|
||||
@@ -59,9 +51,6 @@ func (s *storageServer) StatVolHandler(arg *string, reply *VolInfo) error {
|
||||
func (s *storageServer) DeleteVolHandler(arg *string, reply *GenericReply) error {
|
||||
err := s.storage.DeleteVol(*arg)
|
||||
if err != nil {
|
||||
log.WithFields(logrus.Fields{
|
||||
"volume": *arg,
|
||||
}).Debugf("DeleteVol failed with error %s", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -73,10 +62,6 @@ func (s *storageServer) DeleteVolHandler(arg *string, reply *GenericReply) error
|
||||
func (s *storageServer) StatFileHandler(arg *StatFileArgs, reply *FileInfo) error {
|
||||
fileInfo, err := s.storage.StatFile(arg.Vol, arg.Path)
|
||||
if err != nil {
|
||||
log.WithFields(logrus.Fields{
|
||||
"volume": arg.Vol,
|
||||
"path": arg.Path,
|
||||
}).Debugf("StatFile failed with error %s", err)
|
||||
return err
|
||||
}
|
||||
*reply = fileInfo
|
||||
@@ -87,10 +72,6 @@ func (s *storageServer) StatFileHandler(arg *StatFileArgs, reply *FileInfo) erro
|
||||
func (s *storageServer) ListDirHandler(arg *ListDirArgs, reply *[]string) error {
|
||||
entries, err := s.storage.ListDir(arg.Vol, arg.Path)
|
||||
if err != nil {
|
||||
log.WithFields(logrus.Fields{
|
||||
"volume": arg.Vol,
|
||||
"path": arg.Path,
|
||||
}).Debugf("ListDir failed with error %s", err)
|
||||
return err
|
||||
}
|
||||
*reply = entries
|
||||
@@ -101,10 +82,6 @@ func (s *storageServer) ListDirHandler(arg *ListDirArgs, reply *[]string) error
|
||||
func (s *storageServer) DeleteFileHandler(arg *DeleteFileArgs, reply *GenericReply) error {
|
||||
err := s.storage.DeleteFile(arg.Vol, arg.Path)
|
||||
if err != nil {
|
||||
log.WithFields(logrus.Fields{
|
||||
"volume": arg.Vol,
|
||||
"path": arg.Path,
|
||||
}).Debugf("DeleteFile failed with error %s", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -114,12 +91,6 @@ func (s *storageServer) DeleteFileHandler(arg *DeleteFileArgs, reply *GenericRep
|
||||
func (s *storageServer) RenameFileHandler(arg *RenameFileArgs, reply *GenericReply) error {
|
||||
err := s.storage.RenameFile(arg.SrcVol, arg.SrcPath, arg.DstVol, arg.DstPath)
|
||||
if err != nil {
|
||||
log.WithFields(logrus.Fields{
|
||||
"srcVolume": arg.SrcVol,
|
||||
"srcPath": arg.SrcPath,
|
||||
"dstVolume": arg.DstVol,
|
||||
"dstPath": arg.DstPath,
|
||||
}).Errorf("RenameFile failed with error %s", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -151,10 +122,6 @@ func registerStorageRPCRouter(mux *router.Router, stServer *storageServer) {
|
||||
path := vars["path"]
|
||||
writeCloser, err := stServer.storage.CreateFile(volume, path)
|
||||
if err != nil {
|
||||
log.WithFields(logrus.Fields{
|
||||
"volume": volume,
|
||||
"path": path,
|
||||
}).Debugf("CreateFile failed with error %s", err)
|
||||
httpErr := http.StatusInternalServerError
|
||||
if err == errVolumeNotFound {
|
||||
httpErr = http.StatusNotFound
|
||||
@@ -166,10 +133,6 @@ func registerStorageRPCRouter(mux *router.Router, stServer *storageServer) {
|
||||
}
|
||||
reader := r.Body
|
||||
if _, err = io.Copy(writeCloser, reader); err != nil {
|
||||
log.WithFields(logrus.Fields{
|
||||
"volume": volume,
|
||||
"path": path,
|
||||
}).Debugf("Copying incoming reader to writer failed %s", err)
|
||||
safeCloseAndRemove(writeCloser)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
@@ -184,19 +147,11 @@ func registerStorageRPCRouter(mux *router.Router, stServer *storageServer) {
|
||||
path := vars["path"]
|
||||
offset, err := strconv.ParseInt(r.URL.Query().Get("offset"), 10, 64)
|
||||
if err != nil {
|
||||
log.WithFields(logrus.Fields{
|
||||
"volume": volume,
|
||||
"path": path,
|
||||
}).Debugf("Parse offset failure with error %s", err)
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
readCloser, err := stServer.storage.ReadFile(volume, path, offset)
|
||||
if err != nil {
|
||||
log.WithFields(logrus.Fields{
|
||||
"volume": volume,
|
||||
"path": path,
|
||||
}).Debugf("ReadFile failed with error %s", err)
|
||||
httpErr := http.StatusBadRequest
|
||||
if err == errVolumeNotFound {
|
||||
httpErr = http.StatusNotFound
|
||||
|
||||
Reference in New Issue
Block a user