summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorGabriel Jackson <gabriel@coffeepowered.co>2017-01-29 12:13:57 -0800
committerKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-02-02 15:24:18 +0100
commitbf6f61cc690978bcad416ace8e8da2418602cbf3 (patch)
tree98be4a5abcd53063b41676772b8dd37a47621c44 /cmd
parent73d05a51e3dce4a5b31b8660a6141a14ae615404 (diff)
downloadgitea-bf6f61cc690978bcad416ace8e8da2418602cbf3.tar.gz
gitea-bf6f61cc690978bcad416ace8e8da2418602cbf3.zip
Cleanup log messaging
This change corrects a few logging issues: * Standardized formatting errors with '%v'. * Standardized failure warning word usage. * Corrected an instance of using the standard log library when the gitea log library should be used instead.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/cert.go14
-rw-r--r--cmd/dump.go22
-rw-r--r--cmd/serve.go8
-rw-r--r--cmd/web.go6
-rw-r--r--cmd/web_graceful.go2
5 files changed, 26 insertions, 26 deletions
diff --git a/cmd/cert.go b/cmd/cert.go
index df38513d6b..d9e9e366bb 100644
--- a/cmd/cert.go
+++ b/cmd/cert.go
@@ -82,7 +82,7 @@ func pemBlockForKey(priv interface{}) *pem.Block {
case *ecdsa.PrivateKey:
b, err := x509.MarshalECPrivateKey(k)
if err != nil {
- log.Fatalf("Unable to marshal ECDSA private key: %v\n", err)
+ log.Fatalf("Unable to marshal ECDSA private key: %v", err)
}
return &pem.Block{Type: "EC PRIVATE KEY", Bytes: b}
default:
@@ -112,7 +112,7 @@ func runCert(ctx *cli.Context) error {
log.Fatalf("Unrecognized elliptic curve: %q", ctx.String("ecdsa-curve"))
}
if err != nil {
- log.Fatalf("Failed to generate private key: %s", err)
+ log.Fatalf("Failed to generate private key: %v", err)
}
var notBefore time.Time
@@ -121,7 +121,7 @@ func runCert(ctx *cli.Context) error {
} else {
notBefore, err = time.Parse("Jan 2 15:04:05 2006", ctx.String("start-date"))
if err != nil {
- log.Fatalf("Failed to parse creation date: %s", err)
+ log.Fatalf("Failed to parse creation date: %v", err)
}
}
@@ -130,7 +130,7 @@ func runCert(ctx *cli.Context) error {
serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
serialNumber, err := rand.Int(rand.Reader, serialNumberLimit)
if err != nil {
- log.Fatalf("Failed to generate serial number: %s", err)
+ log.Fatalf("Failed to generate serial number: %v", err)
}
template := x509.Certificate{
@@ -163,12 +163,12 @@ func runCert(ctx *cli.Context) error {
derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, publicKey(priv), priv)
if err != nil {
- log.Fatalf("Failed to create certificate: %s", err)
+ log.Fatalf("Failed to create certificate: %v", err)
}
certOut, err := os.Create("cert.pem")
if err != nil {
- log.Fatalf("Failed to open cert.pem for writing: %s", err)
+ log.Fatalf("Failed to open cert.pem for writing: %v", err)
}
pem.Encode(certOut, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes})
certOut.Close()
@@ -176,7 +176,7 @@ func runCert(ctx *cli.Context) error {
keyOut, err := os.OpenFile("key.pem", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
- log.Fatalf("Failed to open key.pem for writing: %v\n", err)
+ log.Fatalf("Failed to open key.pem for writing: %v", err)
}
pem.Encode(keyOut, pemBlockForKey(priv))
keyOut.Close()
diff --git a/cmd/dump.go b/cmd/dump.go
index c12a7a9180..ef1fdf2054 100644
--- a/cmd/dump.go
+++ b/cmd/dump.go
@@ -68,7 +68,7 @@ func runDump(ctx *cli.Context) error {
}
TmpWorkDir, err := ioutil.TempDir(tmpDir, "gitea-dump-")
if err != nil {
- log.Fatalf("Fail to create tmp work directory: %v", err)
+ log.Fatalf("Failed to create tmp work directory: %v", err)
}
log.Printf("Creating tmp work dir: %s", TmpWorkDir)
@@ -78,7 +78,7 @@ func runDump(ctx *cli.Context) error {
log.Printf("Dumping local repositories...%s", setting.RepoRootPath)
zip.Verbose = ctx.Bool("verbose")
if err := zip.PackTo(setting.RepoRootPath, reposDump, true); err != nil {
- log.Fatalf("Fail to dump local repositories: %v", err)
+ log.Fatalf("Failed to dump local repositories: %v", err)
}
targetDBType := ctx.String("database")
@@ -89,26 +89,26 @@ func runDump(ctx *cli.Context) error {
}
if err := models.DumpDatabase(dbDump, targetDBType); err != nil {
- log.Fatalf("Fail to dump database: %v", err)
+ log.Fatalf("Failed to dump database: %v", err)
}
fileName := fmt.Sprintf("gitea-dump-%d.zip", time.Now().Unix())
log.Printf("Packing dump files...")
z, err := zip.Create(fileName)
if err != nil {
- log.Fatalf("Fail to create %s: %v", fileName, err)
+ log.Fatalf("Failed to create %s: %v", fileName, err)
}
if err := z.AddFile("gitea-repo.zip", reposDump); err != nil {
- log.Fatalf("Fail to include gitea-repo.zip: %v", err)
+ log.Fatalf("Failed to include gitea-repo.zip: %v", err)
}
if err := z.AddFile("gitea-db.sql", dbDump); err != nil {
- log.Fatalf("Fail to include gitea-db.sql: %v", err)
+ log.Fatalf("Failed to include gitea-db.sql: %v", err)
}
customDir, err := os.Stat(setting.CustomPath)
if err == nil && customDir.IsDir() {
if err := z.AddDir("custom", setting.CustomPath); err != nil {
- log.Fatalf("Fail to include custom: %v", err)
+ log.Fatalf("Failed to include custom: %v", err)
}
} else {
log.Printf("Custom dir %s doesn't exist, skipped", setting.CustomPath)
@@ -124,16 +124,16 @@ func runDump(ctx *cli.Context) error {
}
if err := zipAddDirectoryExclude(z, "data", setting.AppDataPath, sessionAbsPath); err != nil {
- log.Fatalf("Fail to include data directory: %v", err)
+ log.Fatalf("Failed to include data directory: %v", err)
}
if err := z.AddDir("log", setting.LogRootPath); err != nil {
- log.Fatalf("Fail to include log: %v", err)
+ log.Fatalf("Failed to include log: %v", err)
}
// FIXME: SSH key file.
if err = z.Close(); err != nil {
_ = os.Remove(fileName)
- log.Fatalf("Fail to save %s: %v", fileName, err)
+ log.Fatalf("Failed to save %s: %v", fileName, err)
}
if err := os.Chmod(fileName, 0600); err != nil {
@@ -143,7 +143,7 @@ func runDump(ctx *cli.Context) error {
log.Printf("Removing tmp work dir: %s", TmpWorkDir)
if err := os.RemoveAll(TmpWorkDir); err != nil {
- log.Fatalf("Fail to remove %s: %v", TmpWorkDir, err)
+ log.Fatalf("Failed to remove %s: %v", TmpWorkDir, err)
}
log.Printf("Finish dumping in file %s", fileName)
diff --git a/cmd/serve.go b/cmd/serve.go
index 8e498faba7..73b9dddd63 100644
--- a/cmd/serve.go
+++ b/cmd/serve.go
@@ -56,7 +56,7 @@ func setup(logPath string) {
if setting.UseSQLite3 || setting.UseTiDB {
workDir, _ := setting.WorkDir()
if err := os.Chdir(workDir); err != nil {
- log.GitLogger.Fatal(4, "Fail to change directory %s: %v", workDir, err)
+ log.GitLogger.Fatal(4, "Failed to change directory %s: %v", workDir, err)
}
}
@@ -134,10 +134,10 @@ func handleUpdateTask(uuid string, user, repoUser *models.User, reponame string,
if err == nil {
resp.Body.Close()
if resp.StatusCode/100 != 2 {
- log.GitLogger.Error(2, "Fail to trigger task: not 2xx response code")
+ log.GitLogger.Error(2, "Failed to trigger task: not 2xx response code")
}
} else {
- log.GitLogger.Error(2, "Fail to trigger task: %v", err)
+ log.GitLogger.Error(2, "Failed to trigger task: %v", err)
}
}
@@ -273,7 +273,7 @@ func runServ(c *cli.Context) error {
mode, err := models.AccessLevel(user, repo)
if err != nil {
- fail("Internal error", "Fail to check access: %v", err)
+ fail("Internal error", "Failed to check access: %v", err)
} else if mode < requestedMode {
clientMessage := accessDenied
if mode >= models.AccessModeRead {
diff --git a/cmd/web.go b/cmd/web.go
index 2e5ae8cd58..026b938f21 100644
--- a/cmd/web.go
+++ b/cmd/web.go
@@ -114,7 +114,7 @@ func newMacaron() *macaron.Macaron {
localeNames, err := options.Dir("locale")
if err != nil {
- log.Fatal(4, "Fail to list locale files: %v", err)
+ log.Fatal(4, "Failed to list locale files: %v", err)
}
localFiles := make(map[string][]byte)
@@ -655,7 +655,7 @@ func runWeb(ctx *cli.Context) error {
err = fcgi.Serve(nil, m)
case setting.UnixSocket:
if err := os.Remove(listenAddr); err != nil {
- log.Fatal(4, "Fail to remove unix socket directory %s: %v", listenAddr, err)
+ log.Fatal(4, "Failed to remove unix socket directory %s: %v", listenAddr, err)
}
var listener *net.UnixListener
listener, err = net.ListenUnix("unix", &net.UnixAddr{Name: listenAddr, Net: "unix"})
@@ -674,7 +674,7 @@ func runWeb(ctx *cli.Context) error {
}
if err != nil {
- log.Fatal(4, "Fail to start server: %v", err)
+ log.Fatal(4, "Failed to start server: %v", err)
}
return nil
diff --git a/cmd/web_graceful.go b/cmd/web_graceful.go
index 488cd4036a..b0b3093b68 100644
--- a/cmd/web_graceful.go
+++ b/cmd/web_graceful.go
@@ -8,9 +8,9 @@ package cmd
import (
"crypto/tls"
- "log"
"net/http"
+ "code.gitea.io/gitea/modules/log"
"github.com/facebookgo/grace/gracehttp"
)