sum7/warehost
sum7
/
warehost
Archived
1
0
Fork 0

addlogging id

This commit is contained in:
Martin Geno 2016-12-13 11:35:44 +01:00
parent 8818a82b9f
commit 1505a99044
4 changed files with 23 additions and 8 deletions

View File

@ -89,6 +89,7 @@ func databaseEdit(ctx context.Context, w http.ResponseWriter, r *http.Request) (
logger.Info("not found")
return
}
logger = logger.WithField("dbID", database.ID)
var databaseRequest Database
returnerr = libapi.JSONDecoder(r.Body, &databaseRequest, w, logger)
@ -114,13 +115,14 @@ func databaseDelete(ctx context.Context, w http.ResponseWriter, r *http.Request)
returndata = false
logger := log.GetLog(r, "databasedelete")
databaseRequest, returnerr := getDatabase(ctx, w)
database, returnerr := getDatabase(ctx, w)
if returnerr != nil {
logger.Info("not found")
return
}
logger = logger.WithField("dbID", database.ID)
if err := dbconnection.Unscoped().Delete(databaseRequest).Error; err != nil {
if err := dbconnection.Unscoped().Delete(database).Error; err != nil {
logger.Error("database: during create host database: ", err)
w.WriteHeader(http.StatusInternalServerError)
returnerr = &libapi.ErrorResult{Message: "Internal Database Error with Database"}

View File

@ -60,6 +60,7 @@ func domainShow(ctx context.Context, w http.ResponseWriter, r *http.Request) (re
logger.Info("not found")
return
}
logger = logger.WithField("dID", domain.ID)
logger.Info("done")
returndata = domain
return
@ -108,6 +109,7 @@ func domainEdit(ctx context.Context, w http.ResponseWriter, r *http.Request) (re
logger.Info("not found")
return
}
logger = logger.WithField("dID", domain.ID)
var domainRequest Domain
returnerr = libapi.JSONDecoder(r.Body, &domainRequest, w, logger)
@ -138,13 +140,14 @@ func domainDelete(ctx context.Context, w http.ResponseWriter, r *http.Request) (
returndata = false
logger := log.GetLog(r, "domaindelete")
domainRequest, returnerr := getDomain(ctx, w)
domain, returnerr := getDomain(ctx, w)
if returnerr != nil {
logger.Info("not found")
return
}
logger = logger.WithField("dID", domain.ID)
if err := dbconnection.Unscoped().Delete(domainRequest).Error; err != nil {
if err := dbconnection.Unscoped().Delete(domain).Error; err != nil {
logger.Error("database: during create host domain: ", err)
w.WriteHeader(http.StatusInternalServerError)
returnerr = &libapi.ErrorResult{Message: "Internal Database Error with Database"}

View File

@ -44,6 +44,7 @@ func mailList(ctx context.Context, w http.ResponseWriter, r *http.Request) (retu
logger.Info("not found")
return
}
logger = logger.WithField("dID", domain.ID)
dbconnection.Where("domain = ?", domain.ID).Preload("Domain").Preload("Forwards").Find(&mail)
logger.Info("done")
returndata = mail
@ -65,6 +66,7 @@ func mailAdd(ctx context.Context, w http.ResponseWriter, r *http.Request) (retur
logger.Info("not found")
return
}
logger = logger.WithField("dID", domain.ID)
mail := &Mail{
DomainID: domain.ID,
@ -97,6 +99,7 @@ func mailEdit(ctx context.Context, w http.ResponseWriter, r *http.Request) (retu
logger.Info("not found")
return
}
logger = logger.WithField("mID", mail.ID)
var mailRequest Mail
returnerr = libapi.JSONDecoder(r.Body, &mailRequest, w, logger)
@ -146,13 +149,14 @@ func mailDelete(ctx context.Context, w http.ResponseWriter, r *http.Request) (re
returndata = false
logger := log.GetLog(r, "maildelete")
mailRequest, returnerr := getMail(ctx, w)
mail, returnerr := getMail(ctx, w)
if returnerr != nil {
logger.Info("not found")
return
}
logger = logger.WithField("mID", mail.ID)
if err := dbconnection.Unscoped().Delete(mailRequest).Error; err != nil {
if err := dbconnection.Unscoped().Delete(mail).Error; err != nil {
logger.Error("database: during create host mail: ", err)
w.WriteHeader(http.StatusInternalServerError)
returnerr = &libapi.ErrorResult{Message: "Internal Database Error with Database"}

View File

@ -57,6 +57,8 @@ func webList(ctx context.Context, w http.ResponseWriter, r *http.Request) (retur
logger.Info("not found")
return
}
logger = logger.WithField("dID", domain.ID)
dbconnection.Where("domain = ?", domain.ID).Preload("Domain").Preload("HTTPAccess.Login").Preload("FTPAccess.Login").Find(&web)
logger.Info("done")
returndata = web
@ -78,6 +80,8 @@ func webAdd(ctx context.Context, w http.ResponseWriter, r *http.Request) (return
logger.Info("not found")
return
}
logger = logger.WithField("dID", domain.ID)
cleanLoginFTPAccess(webRequest.FTPAccess)
cleanLoginHTTPAccess(webRequest.HTTPAccess)
@ -117,6 +121,7 @@ func webEdit(ctx context.Context, w http.ResponseWriter, r *http.Request) (retur
logger.Info("not found")
return
}
logger = logger.WithField("wID", web.ID)
var webRequest Web
returnerr = libapi.JSONDecoder(r.Body, &webRequest, w, logger)
@ -204,13 +209,14 @@ func webDelete(ctx context.Context, w http.ResponseWriter, r *http.Request) (ret
returndata = false
logger := log.GetLog(r, "webdelete")
webRequest, returnerr := getWeb(ctx, w)
web, returnerr := getWeb(ctx, w)
if returnerr != nil {
logger.Info("not found")
return
}
logger = logger.WithField("wID", web.ID)
if err := dbconnection.Unscoped().Delete(webRequest).Error; err != nil {
if err := dbconnection.Unscoped().Delete(web).Error; err != nil {
logger.Error("database: during create host web: ", err)
w.WriteHeader(http.StatusInternalServerError)
returnerr = &libapi.ErrorResult{Message: "Internal Database Error with Database"}