Browse Source

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.
Gabriel Jackson 3 years ago
parent
commit
bf6f61cc69

+ 7 - 7
cmd/cert.go

@@ -82,7 +82,7 @@ func pemBlockForKey(priv interface{}) *pem.Block {
82 82
 	case *ecdsa.PrivateKey:
83 83
 		b, err := x509.MarshalECPrivateKey(k)
84 84
 		if err != nil {
85
-			log.Fatalf("Unable to marshal ECDSA private key: %v\n", err)
85
+			log.Fatalf("Unable to marshal ECDSA private key: %v", err)
86 86
 		}
87 87
 		return &pem.Block{Type: "EC PRIVATE KEY", Bytes: b}
88 88
 	default:
@@ -112,7 +112,7 @@ func runCert(ctx *cli.Context) error {
112 112
 		log.Fatalf("Unrecognized elliptic curve: %q", ctx.String("ecdsa-curve"))
113 113
 	}
114 114
 	if err != nil {
115
-		log.Fatalf("Failed to generate private key: %s", err)
115
+		log.Fatalf("Failed to generate private key: %v", err)
116 116
 	}
117 117
 
118 118
 	var notBefore time.Time
@@ -121,7 +121,7 @@ func runCert(ctx *cli.Context) error {
121 121
 	} else {
122 122
 		notBefore, err = time.Parse("Jan 2 15:04:05 2006", ctx.String("start-date"))
123 123
 		if err != nil {
124
-			log.Fatalf("Failed to parse creation date: %s", err)
124
+			log.Fatalf("Failed to parse creation date: %v", err)
125 125
 		}
126 126
 	}
127 127
 
@@ -130,7 +130,7 @@ func runCert(ctx *cli.Context) error {
130 130
 	serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
131 131
 	serialNumber, err := rand.Int(rand.Reader, serialNumberLimit)
132 132
 	if err != nil {
133
-		log.Fatalf("Failed to generate serial number: %s", err)
133
+		log.Fatalf("Failed to generate serial number: %v", err)
134 134
 	}
135 135
 
136 136
 	template := x509.Certificate{
@@ -163,12 +163,12 @@ func runCert(ctx *cli.Context) error {
163 163
 
164 164
 	derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, publicKey(priv), priv)
165 165
 	if err != nil {
166
-		log.Fatalf("Failed to create certificate: %s", err)
166
+		log.Fatalf("Failed to create certificate: %v", err)
167 167
 	}
168 168
 
169 169
 	certOut, err := os.Create("cert.pem")
170 170
 	if err != nil {
171
-		log.Fatalf("Failed to open cert.pem for writing: %s", err)
171
+		log.Fatalf("Failed to open cert.pem for writing: %v", err)
172 172
 	}
173 173
 	pem.Encode(certOut, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes})
174 174
 	certOut.Close()
@@ -176,7 +176,7 @@ func runCert(ctx *cli.Context) error {
176 176
 
177 177
 	keyOut, err := os.OpenFile("key.pem", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
178 178
 	if err != nil {
179
-		log.Fatalf("Failed to open key.pem for writing: %v\n", err)
179
+		log.Fatalf("Failed to open key.pem for writing: %v", err)
180 180
 	}
181 181
 	pem.Encode(keyOut, pemBlockForKey(priv))
182 182
 	keyOut.Close()

+ 11 - 11
cmd/dump.go

@@ -68,7 +68,7 @@ func runDump(ctx *cli.Context) error {
68 68
 	}
69 69
 	TmpWorkDir, err := ioutil.TempDir(tmpDir, "gitea-dump-")
70 70
 	if err != nil {
71
-		log.Fatalf("Fail to create tmp work directory: %v", err)
71
+		log.Fatalf("Failed to create tmp work directory: %v", err)
72 72
 	}
73 73
 	log.Printf("Creating tmp work dir: %s", TmpWorkDir)
74 74
 
@@ -78,7 +78,7 @@ func runDump(ctx *cli.Context) error {
78 78
 	log.Printf("Dumping local repositories...%s", setting.RepoRootPath)
79 79
 	zip.Verbose = ctx.Bool("verbose")
80 80
 	if err := zip.PackTo(setting.RepoRootPath, reposDump, true); err != nil {
81
-		log.Fatalf("Fail to dump local repositories: %v", err)
81
+		log.Fatalf("Failed to dump local repositories: %v", err)
82 82
 	}
83 83
 
84 84
 	targetDBType := ctx.String("database")
@@ -89,26 +89,26 @@ func runDump(ctx *cli.Context) error {
89 89
 	}
90 90
 
91 91
 	if err := models.DumpDatabase(dbDump, targetDBType); err != nil {
92
-		log.Fatalf("Fail to dump database: %v", err)
92
+		log.Fatalf("Failed to dump database: %v", err)
93 93
 	}
94 94
 
95 95
 	fileName := fmt.Sprintf("gitea-dump-%d.zip", time.Now().Unix())
96 96
 	log.Printf("Packing dump files...")
97 97
 	z, err := zip.Create(fileName)
98 98
 	if err != nil {
99
-		log.Fatalf("Fail to create %s: %v", fileName, err)
99
+		log.Fatalf("Failed to create %s: %v", fileName, err)
100 100
 	}
101 101
 
102 102
 	if err := z.AddFile("gitea-repo.zip", reposDump); err != nil {
103
-		log.Fatalf("Fail to include gitea-repo.zip: %v", err)
103
+		log.Fatalf("Failed to include gitea-repo.zip: %v", err)
104 104
 	}
105 105
 	if err := z.AddFile("gitea-db.sql", dbDump); err != nil {
106
-		log.Fatalf("Fail to include gitea-db.sql: %v", err)
106
+		log.Fatalf("Failed to include gitea-db.sql: %v", err)
107 107
 	}
108 108
 	customDir, err := os.Stat(setting.CustomPath)
109 109
 	if err == nil && customDir.IsDir() {
110 110
 		if err := z.AddDir("custom", setting.CustomPath); err != nil {
111
-			log.Fatalf("Fail to include custom: %v", err)
111
+			log.Fatalf("Failed to include custom: %v", err)
112 112
 		}
113 113
 	} else {
114 114
 		log.Printf("Custom dir %s doesn't exist, skipped", setting.CustomPath)
@@ -124,16 +124,16 @@ func runDump(ctx *cli.Context) error {
124 124
 	}
125 125
 
126 126
 	if err := zipAddDirectoryExclude(z, "data", setting.AppDataPath, sessionAbsPath); err != nil {
127
-		log.Fatalf("Fail to include data directory: %v", err)
127
+		log.Fatalf("Failed to include data directory: %v", err)
128 128
 	}
129 129
 
130 130
 	if err := z.AddDir("log", setting.LogRootPath); err != nil {
131
-		log.Fatalf("Fail to include log: %v", err)
131
+		log.Fatalf("Failed to include log: %v", err)
132 132
 	}
133 133
 	// FIXME: SSH key file.
134 134
 	if err = z.Close(); err != nil {
135 135
 		_ = os.Remove(fileName)
136
-		log.Fatalf("Fail to save %s: %v", fileName, err)
136
+		log.Fatalf("Failed to save %s: %v", fileName, err)
137 137
 	}
138 138
 
139 139
 	if err := os.Chmod(fileName, 0600); err != nil {
@@ -143,7 +143,7 @@ func runDump(ctx *cli.Context) error {
143 143
 	log.Printf("Removing tmp work dir: %s", TmpWorkDir)
144 144
 
145 145
 	if err := os.RemoveAll(TmpWorkDir); err != nil {
146
-		log.Fatalf("Fail to remove %s: %v", TmpWorkDir, err)
146
+		log.Fatalf("Failed to remove %s: %v", TmpWorkDir, err)
147 147
 	}
148 148
 	log.Printf("Finish dumping in file %s", fileName)
149 149
 

+ 4 - 4
cmd/serve.go

@@ -56,7 +56,7 @@ func setup(logPath string) {
56 56
 	if setting.UseSQLite3 || setting.UseTiDB {
57 57
 		workDir, _ := setting.WorkDir()
58 58
 		if err := os.Chdir(workDir); err != nil {
59
-			log.GitLogger.Fatal(4, "Fail to change directory %s: %v", workDir, err)
59
+			log.GitLogger.Fatal(4, "Failed to change directory %s: %v", workDir, err)
60 60
 		}
61 61
 	}
62 62
 
@@ -134,10 +134,10 @@ func handleUpdateTask(uuid string, user, repoUser *models.User, reponame string,
134 134
 	if err == nil {
135 135
 		resp.Body.Close()
136 136
 		if resp.StatusCode/100 != 2 {
137
-			log.GitLogger.Error(2, "Fail to trigger task: not 2xx response code")
137
+			log.GitLogger.Error(2, "Failed to trigger task: not 2xx response code")
138 138
 		}
139 139
 	} else {
140
-		log.GitLogger.Error(2, "Fail to trigger task: %v", err)
140
+		log.GitLogger.Error(2, "Failed to trigger task: %v", err)
141 141
 	}
142 142
 }
143 143
 
@@ -273,7 +273,7 @@ func runServ(c *cli.Context) error {
273 273
 
274 274
 			mode, err := models.AccessLevel(user, repo)
275 275
 			if err != nil {
276
-				fail("Internal error", "Fail to check access: %v", err)
276
+				fail("Internal error", "Failed to check access: %v", err)
277 277
 			} else if mode < requestedMode {
278 278
 				clientMessage := accessDenied
279 279
 				if mode >= models.AccessModeRead {

+ 3 - 3
cmd/web.go

@@ -114,7 +114,7 @@ func newMacaron() *macaron.Macaron {
114 114
 	localeNames, err := options.Dir("locale")
115 115
 
116 116
 	if err != nil {
117
-		log.Fatal(4, "Fail to list locale files: %v", err)
117
+		log.Fatal(4, "Failed to list locale files: %v", err)
118 118
 	}
119 119
 
120 120
 	localFiles := make(map[string][]byte)
@@ -655,7 +655,7 @@ func runWeb(ctx *cli.Context) error {
655 655
 		err = fcgi.Serve(nil, m)
656 656
 	case setting.UnixSocket:
657 657
 		if err := os.Remove(listenAddr); err != nil {
658
-			log.Fatal(4, "Fail to remove unix socket directory %s: %v", listenAddr, err)
658
+			log.Fatal(4, "Failed to remove unix socket directory %s: %v", listenAddr, err)
659 659
 		}
660 660
 		var listener *net.UnixListener
661 661
 		listener, err = net.ListenUnix("unix", &net.UnixAddr{Name: listenAddr, Net: "unix"})
@@ -674,7 +674,7 @@ func runWeb(ctx *cli.Context) error {
674 674
 	}
675 675
 
676 676
 	if err != nil {
677
-		log.Fatal(4, "Fail to start server: %v", err)
677
+		log.Fatal(4, "Failed to start server: %v", err)
678 678
 	}
679 679
 
680 680
 	return nil

+ 1 - 1
cmd/web_graceful.go

@@ -8,9 +8,9 @@ package cmd
8 8
 
9 9
 import (
10 10
 	"crypto/tls"
11
-	"log"
12 11
 	"net/http"
13 12
 
13
+	"code.gitea.io/gitea/modules/log"
14 14
 	"github.com/facebookgo/grace/gracehttp"
15 15
 )
16 16
 

+ 1 - 1
main.go

@@ -38,7 +38,7 @@ func main() {
38 38
 	app.Flags = append(app.Flags, []cli.Flag{}...)
39 39
 	err := app.Run(os.Args)
40 40
 	if err != nil {
41
-		log.Fatal(4, "Fail to run app with %s: %v", os.Args, err)
41
+		log.Fatal(4, "Failed to run app with %s: %v", os.Args, err)
42 42
 	}
43 43
 
44 44
 }

+ 1 - 1
models/migrations/migrations.go

@@ -328,7 +328,7 @@ func attachmentRefactor(x *xorm.Engine) error {
328 328
 
329 329
 		dumpPath := path.Join(setting.LogRootPath, "attachment_path.dump")
330 330
 		ioutil.WriteFile(dumpPath, buf.Bytes(), 0666)
331
-		fmt.Println("Fail to rename some attachments, old and new paths are saved into:", dumpPath)
331
+		log.Info("Failed to rename some attachments, old and new paths are saved into: %s", dumpPath)
332 332
 	}()
333 333
 	for _, attach := range attachments {
334 334
 		if err = os.MkdirAll(path.Dir(attach.NewPath), os.ModePerm); err != nil {

+ 5 - 5
models/models.go

@@ -205,7 +205,7 @@ func getEngine() (*xorm.Engine, error) {
205 205
 			return nil, errors.New("this binary version does not build support for SQLite3")
206 206
 		}
207 207
 		if err := os.MkdirAll(path.Dir(DbCfg.Path), os.ModePerm); err != nil {
208
-			return nil, fmt.Errorf("Fail to create directories: %v", err)
208
+			return nil, fmt.Errorf("Failed to create directories: %v", err)
209 209
 		}
210 210
 		connStr = "file:" + DbCfg.Path + "?cache=shared&mode=rwc"
211 211
 	case "tidb":
@@ -213,7 +213,7 @@ func getEngine() (*xorm.Engine, error) {
213 213
 			return nil, errors.New("this binary version does not build support for TiDB")
214 214
 		}
215 215
 		if err := os.MkdirAll(path.Dir(DbCfg.Path), os.ModePerm); err != nil {
216
-			return nil, fmt.Errorf("Fail to create directories: %v", err)
216
+			return nil, fmt.Errorf("Failed to create directories: %v", err)
217 217
 		}
218 218
 		connStr = "goleveldb://" + DbCfg.Path
219 219
 	default:
@@ -237,7 +237,7 @@ func NewTestEngine(x *xorm.Engine) (err error) {
237 237
 func SetEngine() (err error) {
238 238
 	x, err = getEngine()
239 239
 	if err != nil {
240
-		return fmt.Errorf("Fail to connect to database: %v", err)
240
+		return fmt.Errorf("Failed to connect to database: %v", err)
241 241
 	}
242 242
 
243 243
 	x.SetMapper(core.GonicMapper{})
@@ -247,12 +247,12 @@ func SetEngine() (err error) {
247 247
 	logPath := path.Join(setting.LogRootPath, "xorm.log")
248 248
 
249 249
 	if err := os.MkdirAll(path.Dir(logPath), os.ModePerm); err != nil {
250
-		return fmt.Errorf("Fail to create dir %s: %v", logPath, err)
250
+		return fmt.Errorf("Failed to create dir %s: %v", logPath, err)
251 251
 	}
252 252
 
253 253
 	f, err := os.Create(logPath)
254 254
 	if err != nil {
255
-		return fmt.Errorf("Fail to create xorm.log: %v", err)
255
+		return fmt.Errorf("Failed to create xorm.log: %v", err)
256 256
 	}
257 257
 	x.SetLogger(xorm.NewSimpleLogger(f))
258 258
 	x.ShowSQL(true)

+ 2 - 2
models/org.go

@@ -272,13 +272,13 @@ func deleteOrg(e *xorm.Session, u *User) error {
272 272
 	path := UserPath(u.Name)
273 273
 
274 274
 	if err := os.RemoveAll(path); err != nil {
275
-		return fmt.Errorf("Fail to RemoveAll %s: %v", path, err)
275
+		return fmt.Errorf("Failed to RemoveAll %s: %v", path, err)
276 276
 	}
277 277
 
278 278
 	avatarPath := u.CustomAvatarPath()
279 279
 	if com.IsExist(avatarPath) {
280 280
 		if err := os.Remove(avatarPath); err != nil {
281
-			return fmt.Errorf("Fail to remove %s: %v", avatarPath, err)
281
+			return fmt.Errorf("Failed to remove %s: %v", avatarPath, err)
282 282
 		}
283 283
 	}
284 284
 

+ 1 - 1
models/pull.go

@@ -275,7 +275,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error
275 275
 	tmpBasePath := path.Join(setting.AppDataPath, "tmp/repos", com.ToStr(time.Now().Nanosecond())+".git")
276 276
 
277 277
 	if err := os.MkdirAll(path.Dir(tmpBasePath), os.ModePerm); err != nil {
278
-		return fmt.Errorf("Fail to create dir %s: %v", tmpBasePath, err)
278
+		return fmt.Errorf("Failed to create dir %s: %v", tmpBasePath, err)
279 279
 	}
280 280
 
281 281
 	defer os.RemoveAll(path.Dir(tmpBasePath))

+ 14 - 14
models/repo.go

@@ -83,13 +83,13 @@ func LoadRepoConfig() {
83 83
 	for i, t := range types {
84 84
 		files, err := options.Dir(t)
85 85
 		if err != nil {
86
-			log.Fatal(4, "Fail to get %s files: %v", t, err)
86
+			log.Fatal(4, "Failed to get %s files: %v", t, err)
87 87
 		}
88 88
 		customPath := path.Join(setting.CustomPath, "options", t)
89 89
 		if com.IsDir(customPath) {
90 90
 			customFiles, err := com.StatDir(customPath)
91 91
 			if err != nil {
92
-				log.Fatal(4, "Fail to get custom %s files: %v", t, err)
92
+				log.Fatal(4, "Failed to get custom %s files: %v", t, err)
93 93
 			}
94 94
 
95 95
 			for _, f := range customFiles {
@@ -131,13 +131,13 @@ func NewRepoContext() {
131 131
 
132 132
 	// Check Git installation.
133 133
 	if _, err := exec.LookPath("git"); err != nil {
134
-		log.Fatal(4, "Fail to test 'git' command: %v (forgotten install?)", err)
134
+		log.Fatal(4, "Failed to test 'git' command: %v (forgotten install?)", err)
135 135
 	}
136 136
 
137 137
 	// Check Git version.
138 138
 	gitVer, err := git.BinVersion()
139 139
 	if err != nil {
140
-		log.Fatal(4, "Fail to get Git version: %v", err)
140
+		log.Fatal(4, "Failed to get Git version: %v", err)
141 141
 	}
142 142
 
143 143
 	log.Info("Git Version: %s", gitVer)
@@ -151,11 +151,11 @@ func NewRepoContext() {
151 151
 			// ExitError indicates this config is not set
152 152
 			if _, ok := err.(*exec.ExitError); ok || strings.TrimSpace(stdout) == "" {
153 153
 				if _, stderr, gerr := process.GetManager().Exec("NewRepoContext(set "+configKey+")", "git", "config", "--global", configKey, defaultValue); gerr != nil {
154
-					log.Fatal(4, "Fail to set git %s(%s): %s", configKey, gerr, stderr)
154
+					log.Fatal(4, "Failed to set git %s(%s): %s", configKey, gerr, stderr)
155 155
 				}
156 156
 				log.Info("Git config %s set to %s", configKey, defaultValue)
157 157
 			} else {
158
-				log.Fatal(4, "Fail to get git %s(%s): %s", configKey, err, stderr)
158
+				log.Fatal(4, "Failed to get git %s(%s): %s", configKey, err, stderr)
159 159
 			}
160 160
 		}
161 161
 	}
@@ -163,7 +163,7 @@ func NewRepoContext() {
163 163
 	// Set git some configurations.
164 164
 	if _, stderr, err := process.GetManager().Exec("NewRepoContext(git config --global core.quotepath false)",
165 165
 		"git", "config", "--global", "core.quotepath", "false"); err != nil {
166
-		log.Fatal(4, "Fail to execute 'git config --global core.quotepath false': %s", stderr)
166
+		log.Fatal(4, "Failed to execute 'git config --global core.quotepath false': %s", stderr)
167 167
 	}
168 168
 
169 169
 	RemoveAllWithNotice("Clean up repository temporary data", filepath.Join(setting.AppDataPath, "tmp"))
@@ -566,7 +566,7 @@ func (repo *Repository) SavePatch(index int64, patch []byte) error {
566 566
 	dir := filepath.Dir(patchPath)
567 567
 
568 568
 	if err := os.MkdirAll(dir, os.ModePerm); err != nil {
569
-		return fmt.Errorf("Fail to create dir %s: %v", dir, err)
569
+		return fmt.Errorf("Failed to create dir %s: %v", dir, err)
570 570
 	}
571 571
 
572 572
 	if err = ioutil.WriteFile(patchPath, patch, 0644); err != nil {
@@ -679,7 +679,7 @@ func MigrateRepository(u *User, opts MigrateRepoOptions) (*Repository, error) {
679 679
 	migrateTimeout := time.Duration(setting.Git.Timeout.Migrate) * time.Second
680 680
 
681 681
 	if err := os.RemoveAll(repoPath); err != nil {
682
-		return repo, fmt.Errorf("Fail to remove %s: %v", repoPath, err)
682
+		return repo, fmt.Errorf("Failed to remove %s: %v", repoPath, err)
683 683
 	}
684 684
 
685 685
 	if err = git.Clone(opts.RemoteAddr, repoPath, git.CloneRepoOptions{
@@ -693,7 +693,7 @@ func MigrateRepository(u *User, opts MigrateRepoOptions) (*Repository, error) {
693 693
 	wikiRemotePath := wikiRemoteURL(opts.RemoteAddr)
694 694
 	if len(wikiRemotePath) > 0 {
695 695
 		if err := os.RemoveAll(wikiPath); err != nil {
696
-			return repo, fmt.Errorf("Fail to remove %s: %v", wikiPath, err)
696
+			return repo, fmt.Errorf("Failed to remove %s: %v", wikiPath, err)
697 697
 		}
698 698
 
699 699
 		if err = git.Clone(wikiRemotePath, wikiPath, git.CloneRepoOptions{
@@ -704,7 +704,7 @@ func MigrateRepository(u *User, opts MigrateRepoOptions) (*Repository, error) {
704 704
 		}); err != nil {
705 705
 			log.Warn("Clone wiki: %v", err)
706 706
 			if err := os.RemoveAll(wikiPath); err != nil {
707
-				return repo, fmt.Errorf("Fail to remove %s: %v", wikiPath, err)
707
+				return repo, fmt.Errorf("Failed to remove %s: %v", wikiPath, err)
708 708
 			}
709 709
 		}
710 710
 	}
@@ -938,7 +938,7 @@ func initRepository(e Engine, repoPath string, u *User, repo *Repository, opts C
938 938
 	if opts.AutoInit {
939 939
 
940 940
 		if err := os.MkdirAll(tmpDir, os.ModePerm); err != nil {
941
-			return fmt.Errorf("Fail to create dir %s: %v", tmpDir, err)
941
+			return fmt.Errorf("Failed to create dir %s: %v", tmpDir, err)
942 942
 		}
943 943
 
944 944
 		defer os.RemoveAll(tmpDir)
@@ -1243,7 +1243,7 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error
1243 1243
 	dir := UserPath(newOwner.Name)
1244 1244
 
1245 1245
 	if err := os.MkdirAll(dir, os.ModePerm); err != nil {
1246
-		return fmt.Errorf("Fail to create dir %s: %v", dir, err)
1246
+		return fmt.Errorf("Failed to create dir %s: %v", dir, err)
1247 1247
 	}
1248 1248
 
1249 1249
 	if err = os.Rename(RepoPath(owner.Name, repo.Name), RepoPath(newOwner.Name, repo.Name)); err != nil {
@@ -1818,7 +1818,7 @@ func GitFsck() {
1818 1818
 				repo := bean.(*Repository)
1819 1819
 				repoPath := repo.RepoPath()
1820 1820
 				if err := git.Fsck(repoPath, setting.Cron.RepoHealthCheck.Timeout, setting.Cron.RepoHealthCheck.Args...); err != nil {
1821
-					desc := fmt.Sprintf("Fail to health check repository (%s): %v", repoPath, err)
1821
+					desc := fmt.Sprintf("Failed to health check repository (%s): %v", repoPath, err)
1822 1822
 					log.Warn(desc)
1823 1823
 					if err = CreateRepositoryNotice(desc); err != nil {
1824 1824
 						log.Error(4, "CreateRepositoryNotice: %v", err)

+ 3 - 3
models/repo_editor.go

@@ -107,7 +107,7 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (
107 107
 	dir := path.Dir(filePath)
108 108
 
109 109
 	if err := os.MkdirAll(dir, os.ModePerm); err != nil {
110
-		return fmt.Errorf("Fail to create dir %s: %v", dir, err)
110
+		return fmt.Errorf("Failed to create dir %s: %v", dir, err)
111 111
 	}
112 112
 
113 113
 	// If it's meant to be a new file, make sure it doesn't exist.
@@ -192,7 +192,7 @@ func (repo *Repository) GetDiffPreview(branch, treePath, content string) (diff *
192 192
 	dir := filepath.Dir(filePath)
193 193
 
194 194
 	if err := os.MkdirAll(dir, os.ModePerm); err != nil {
195
-		return nil, fmt.Errorf("Fail to create dir %s: %v", dir, err)
195
+		return nil, fmt.Errorf("Failed to create dir %s: %v", dir, err)
196 196
 	}
197 197
 
198 198
 	if err = ioutil.WriteFile(filePath, []byte(content), 0666); err != nil {
@@ -486,7 +486,7 @@ func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions)
486 486
 	dirPath := path.Join(localPath, opts.TreePath)
487 487
 
488 488
 	if err := os.MkdirAll(dirPath, os.ModePerm); err != nil {
489
-		return fmt.Errorf("Fail to create dir %s: %v", dirPath, err)
489
+		return fmt.Errorf("Failed to create dir %s: %v", dirPath, err)
490 490
 	}
491 491
 
492 492
 	// Copy uploaded files into repository.

+ 2 - 2
models/repo_mirror.go

@@ -140,7 +140,7 @@ func (m *Mirror) runSync() bool {
140 140
 	if _, stderr, err := process.GetManager().ExecDir(
141 141
 		timeout, repoPath, fmt.Sprintf("Mirror.runSync: %s", repoPath),
142 142
 		"git", gitArgs...); err != nil {
143
-		desc := fmt.Sprintf("Fail to update mirror repository '%s': %s", repoPath, stderr)
143
+		desc := fmt.Sprintf("Failed to update mirror repository '%s': %s", repoPath, stderr)
144 144
 		log.Error(4, desc)
145 145
 		if err = CreateRepositoryNotice(desc); err != nil {
146 146
 			log.Error(4, "CreateRepositoryNotice: %v", err)
@@ -151,7 +151,7 @@ func (m *Mirror) runSync() bool {
151 151
 		if _, stderr, err := process.GetManager().ExecDir(
152 152
 			timeout, wikiPath, fmt.Sprintf("Mirror.runSync: %s", wikiPath),
153 153
 			"git", "remote", "update", "--prune"); err != nil {
154
-			desc := fmt.Sprintf("Fail to update mirror wiki repository '%s': %s", wikiPath, stderr)
154
+			desc := fmt.Sprintf("Failed to update mirror wiki repository '%s': %s", wikiPath, stderr)
155 155
 			log.Error(4, desc)
156 156
 			if err = CreateRepositoryNotice(desc); err != nil {
157 157
 				log.Error(4, "CreateRepositoryNotice: %v", err)

+ 1 - 1
models/ssh_key.go

@@ -376,7 +376,7 @@ func addKey(e Engine, key *PublicKey) (err error) {
376 376
 	dir := path.Dir(tmpPath)
377 377
 
378 378
 	if err := os.MkdirAll(dir, os.ModePerm); err != nil {
379
-		return fmt.Errorf("Fail to create dir %s: %v", dir, err)
379
+		return fmt.Errorf("Failed to create dir %s: %v", dir, err)
380 380
 	}
381 381
 
382 382
 	if err = ioutil.WriteFile(tmpPath, []byte(key.Content), 0644); err != nil {

+ 1 - 1
models/update.go

@@ -102,7 +102,7 @@ func PushUpdate(opts PushUpdateOptions) (err error) {
102 102
 	gitUpdate := exec.Command("git", "update-server-info")
103 103
 	gitUpdate.Dir = repoPath
104 104
 	if err = gitUpdate.Run(); err != nil {
105
-		return fmt.Errorf("Fail to call 'git update-server-info': %v", err)
105
+		return fmt.Errorf("Failed to call 'git update-server-info': %v", err)
106 106
 	}
107 107
 
108 108
 	if isDelRef {

+ 4 - 4
models/user.go

@@ -414,7 +414,7 @@ func (u *User) UploadAvatar(data []byte) error {
414 414
 	}
415 415
 
416 416
 	if err := os.MkdirAll(setting.AvatarUploadPath, os.ModePerm); err != nil {
417
-		return fmt.Errorf("Fail to create dir %s: %v", setting.AvatarUploadPath, err)
417
+		return fmt.Errorf("Failed to create dir %s: %v", setting.AvatarUploadPath, err)
418 418
 	}
419 419
 
420 420
 	fw, err := os.Create(u.CustomAvatarPath())
@@ -435,7 +435,7 @@ func (u *User) DeleteAvatar() error {
435 435
 	log.Trace("DeleteAvatar[%d]: %s", u.ID, u.CustomAvatarPath())
436 436
 
437 437
 	if err := os.Remove(u.CustomAvatarPath()); err != nil {
438
-		return fmt.Errorf("Fail to remove %s: %v", u.CustomAvatarPath(), err)
438
+		return fmt.Errorf("Failed to remove %s: %v", u.CustomAvatarPath(), err)
439 439
 	}
440 440
 
441 441
 	u.UseCustomAvatar = false
@@ -924,13 +924,13 @@ func deleteUser(e *xorm.Session, u *User) error {
924 924
 	path := UserPath(u.Name)
925 925
 
926 926
 	if err := os.RemoveAll(path); err != nil {
927
-		return fmt.Errorf("Fail to RemoveAll %s: %v", path, err)
927
+		return fmt.Errorf("Failed to RemoveAll %s: %v", path, err)
928 928
 	}
929 929
 
930 930
 	avatarPath := u.CustomAvatarPath()
931 931
 	if com.IsExist(avatarPath) {
932 932
 		if err := os.Remove(avatarPath); err != nil {
933
-			return fmt.Errorf("Fail to remove %s: %v", avatarPath, err)
933
+			return fmt.Errorf("Failed to remove %s: %v", avatarPath, err)
934 934
 		}
935 935
 	}
936 936
 

+ 2 - 2
models/wiki.go

@@ -133,7 +133,7 @@ func (repo *Repository) updateWikiPage(doer *User, oldWikiPath, wikiPath, conten
133 133
 		file := path.Join(localPath, oldWikiPath+".md")
134 134
 
135 135
 		if err := os.Remove(file); err != nil {
136
-			return fmt.Errorf("Fail to remove %s: %v", file, err)
136
+			return fmt.Errorf("Failed to remove %s: %v", file, err)
137 137
 		}
138 138
 	}
139 139
 
@@ -192,7 +192,7 @@ func (repo *Repository) DeleteWikiPage(doer *User, wikiPath string) (err error)
192 192
 	filename := path.Join(localPath, wikiPath+".md")
193 193
 
194 194
 	if err := os.Remove(filename); err != nil {
195
-		return fmt.Errorf("Fail to remove %s: %v", filename, err)
195
+		return fmt.Errorf("Failed to remove %s: %v", filename, err)
196 196
 	}
197 197
 
198 198
 	title := ToWikiPageName(wikiPath)

+ 1 - 1
modules/base/tool.go

@@ -110,7 +110,7 @@ func GetRandomBytesAsBase64(n int) string {
110 110
 	_, err := io.ReadFull(rand.Reader, bytes)
111 111
 
112 112
 	if err != nil {
113
-		log.Fatal(4, "Error reading random bytes: %s", err)
113
+		log.Fatal(4, "Error reading random bytes: %v", err)
114 114
 	}
115 115
 
116 116
 	return base64.RawURLEncoding.EncodeToString(bytes)

+ 4 - 4
modules/log/file.go

@@ -151,7 +151,7 @@ func (w *FileLogWriter) initFd() error {
151 151
 	fd := w.mw.fd
152 152
 	finfo, err := fd.Stat()
153 153
 	if err != nil {
154
-		return fmt.Errorf("get stat: %s", err)
154
+		return fmt.Errorf("get stat: %v", err)
155 155
 	}
156 156
 	w.maxsizeCursize = int(finfo.Size())
157 157
 	w.dailyOpenDate = time.Now().Day()
@@ -194,12 +194,12 @@ func (w *FileLogWriter) DoRotate() error {
194 194
 		// close fd before rename
195 195
 		// Rename the file to its newfound home
196 196
 		if err = os.Rename(w.Filename, fname); err != nil {
197
-			return fmt.Errorf("Rotate: %s", err)
197
+			return fmt.Errorf("Rotate: %v", err)
198 198
 		}
199 199
 
200 200
 		// re-start logger
201 201
 		if err = w.StartLogger(); err != nil {
202
-			return fmt.Errorf("Rotate StartLogger: %s", err)
202
+			return fmt.Errorf("Rotate StartLogger: %v", err)
203 203
 		}
204 204
 
205 205
 		go w.deleteOldLog()
@@ -221,7 +221,7 @@ func (w *FileLogWriter) deleteOldLog() {
221 221
 			if strings.HasPrefix(filepath.Base(path), filepath.Base(w.Filename)) {
222 222
 
223 223
 				if err := os.Remove(path); err != nil {
224
-					returnErr = fmt.Errorf("Fail to remove %s: %v", path, err)
224
+					returnErr = fmt.Errorf("Failed to remove %s: %v", path, err)
225 225
 				}
226 226
 			}
227 227
 		}

+ 2 - 2
modules/log/log.go

@@ -35,7 +35,7 @@ func NewLogger(bufLen int64, mode, config string) {
35 35
 		loggers = append(loggers, logger)
36 36
 	}
37 37
 	if err := logger.SetLogger(mode, config); err != nil {
38
-		Fatal(2, "Fail to set logger (%s): %v", mode, err)
38
+		Fatal(2, "Failed to set logger (%s): %v", mode, err)
39 39
 	}
40 40
 }
41 41
 
@@ -56,7 +56,7 @@ func NewGitLogger(logPath string) {
56 56
 	path := path.Dir(logPath)
57 57
 
58 58
 	if err := os.MkdirAll(path, os.ModePerm); err != nil {
59
-		Fatal(4, "Fail to create dir %s: %v", path, err)
59
+		Fatal(4, "Failed to create dir %s: %v", path, err)
60 60
 	}
61 61
 
62 62
 	GitLogger = newLogger(0)

+ 1 - 1
modules/mailer/mailer.go

@@ -241,7 +241,7 @@ func processMailQueue() {
241 241
 		case msg := <-mailQueue:
242 242
 			log.Trace("New e-mail sending request %s: %s", msg.GetHeader("To"), msg.Info)
243 243
 			if err := gomail.Send(Sender, msg.Message); err != nil {
244
-				log.Error(3, "Fail to send emails %s: %s - %v", msg.GetHeader("To"), msg.Info, err)
244
+				log.Error(3, "Failed to send emails %s: %s - %v", msg.GetHeader("To"), msg.Info, err)
245 245
 			} else {
246 246
 				log.Trace("E-mails sent %s: %s", msg.GetHeader("To"), msg.Info)
247 247
 			}

+ 30 - 30
modules/setting/setting.go

@@ -431,7 +431,7 @@ func init() {
431 431
 
432 432
 	var err error
433 433
 	if AppPath, err = execPath(); err != nil {
434
-		log.Fatal(4, "fail to get app path: %v\n", err)
434
+		log.Fatal(4, "Failed to get app path: %v", err)
435 435
 	}
436 436
 
437 437
 	// Note: we don't use path.Dir here because it does not handle case
@@ -483,16 +483,16 @@ func IsRunUserMatchCurrentUser(runUser string) (string, bool) {
483 483
 func createPIDFile(pidPath string) {
484 484
 	currentPid := os.Getpid()
485 485
 	if err := os.MkdirAll(filepath.Dir(pidPath), os.ModePerm); err != nil {
486
-		log.Fatal(4, "Can't create PID folder on %s", err)
486
+		log.Fatal(4, "Failed to create PID folder: %v", err)
487 487
 	}
488 488
 
489 489
 	file, err := os.Create(pidPath)
490 490
 	if err != nil {
491
-		log.Fatal(4, "Can't create PID file: %v", err)
491
+		log.Fatal(4, "Failed to create PID file: %v", err)
492 492
 	}
493 493
 	defer file.Close()
494 494
 	if _, err := file.WriteString(strconv.FormatInt(int64(currentPid), 10)); err != nil {
495
-		log.Fatal(4, "Can'write PID information on %s", err)
495
+		log.Fatal(4, "Failed to write PID information: %v", err)
496 496
 	}
497 497
 }
498 498
 
@@ -501,13 +501,13 @@ func createPIDFile(pidPath string) {
501 501
 func NewContext() {
502 502
 	workDir, err := WorkDir()
503 503
 	if err != nil {
504
-		log.Fatal(4, "Fail to get work directory: %v", err)
504
+		log.Fatal(4, "Failed to get work directory: %v", err)
505 505
 	}
506 506
 
507 507
 	Cfg = ini.Empty()
508 508
 
509 509
 	if err != nil {
510
-		log.Fatal(4, "Fail to parse 'app.ini': %v", err)
510
+		log.Fatal(4, "Failed to parse 'app.ini': %v", err)
511 511
 	}
512 512
 
513 513
 	CustomPath = os.Getenv("GITEA_CUSTOM")
@@ -533,7 +533,7 @@ please consider changing to GITEA_CUSTOM`)
533 533
 
534 534
 	if com.IsFile(CustomConf) {
535 535
 		if err = Cfg.Append(CustomConf); err != nil {
536
-			log.Fatal(4, "Fail to load custom conf '%s': %v", CustomConf, err)
536
+			log.Fatal(4, "Failed to load custom conf '%s': %v", CustomConf, err)
537 537
 		}
538 538
 	} else {
539 539
 		log.Warn("Custom config '%s' not found, ignore this if you're running first time", CustomConf)
@@ -542,7 +542,7 @@ please consider changing to GITEA_CUSTOM`)
542 542
 
543 543
 	homeDir, err := com.HomeDir()
544 544
 	if err != nil {
545
-		log.Fatal(4, "Fail to get home directory: %v", err)
545
+		log.Fatal(4, "Failed to get home directory: %v", err)
546 546
 	}
547 547
 	homeDir = strings.Replace(homeDir, "\\", "/", -1)
548 548
 
@@ -578,7 +578,7 @@ please consider changing to GITEA_CUSTOM`)
578 578
 		UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666")
579 579
 		UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32)
580 580
 		if err != nil || UnixSocketPermissionParsed > 0777 {
581
-			log.Fatal(4, "Fail to parse unixSocketPermission: %s", UnixSocketPermissionRaw)
581
+			log.Fatal(4, "Failed to parse unixSocketPermission: %s", UnixSocketPermissionRaw)
582 582
 		}
583 583
 		UnixSocketPermission = uint32(UnixSocketPermissionParsed)
584 584
 	}
@@ -602,7 +602,7 @@ please consider changing to GITEA_CUSTOM`)
602 602
 	SSH.RootPath = path.Join(homeDir, ".ssh")
603 603
 	SSH.KeyTestPath = os.TempDir()
604 604
 	if err = Cfg.Section("server").MapTo(&SSH); err != nil {
605
-		log.Fatal(4, "Fail to map SSH settings: %v", err)
605
+		log.Fatal(4, "Failed to map SSH settings: %v", err)
606 606
 	}
607 607
 
608 608
 	SSH.KeygenPath = sec.Key("SSH_KEYGEN_PATH").MustString("ssh-keygen")
@@ -616,9 +616,9 @@ please consider changing to GITEA_CUSTOM`)
616 616
 
617 617
 	if !SSH.Disabled && !SSH.StartBuiltinServer {
618 618
 		if err := os.MkdirAll(SSH.RootPath, 0700); err != nil {
619
-			log.Fatal(4, "Fail to create '%s': %v", SSH.RootPath, err)
619
+			log.Fatal(4, "Failed to create '%s': %v", SSH.RootPath, err)
620 620
 		} else if err = os.MkdirAll(SSH.KeyTestPath, 0644); err != nil {
621
-			log.Fatal(4, "Fail to create '%s': %v", SSH.KeyTestPath, err)
621
+			log.Fatal(4, "Failed to create '%s': %v", SSH.KeyTestPath, err)
622 622
 		}
623 623
 	}
624 624
 
@@ -632,13 +632,13 @@ please consider changing to GITEA_CUSTOM`)
632 632
 	}
633 633
 
634 634
 	if err = Cfg.Section("server").MapTo(&LFS); err != nil {
635
-		log.Fatal(4, "Fail to map LFS settings: %v", err)
635
+		log.Fatal(4, "Failed to map LFS settings: %v", err)
636 636
 	}
637 637
 
638 638
 	if LFS.StartServer {
639 639
 
640 640
 		if err := os.MkdirAll(LFS.ContentPath, 0700); err != nil {
641
-			log.Fatal(4, "Fail to create '%s': %v", LFS.ContentPath, err)
641
+			log.Fatal(4, "Failed to create '%s': %v", LFS.ContentPath, err)
642 642
 		}
643 643
 
644 644
 		LFS.JWTSecretBytes = make([]byte, 32)
@@ -650,7 +650,7 @@ please consider changing to GITEA_CUSTOM`)
650 650
 			_, err := io.ReadFull(rand.Reader, LFS.JWTSecretBytes)
651 651
 
652 652
 			if err != nil {
653
-				log.Fatal(4, "Error reading random bytes: %s", err)
653
+				log.Fatal(4, "Error reading random bytes: %v", err)
654 654
 			}
655 655
 
656 656
 			LFS.JWTSecretBase64 = base64.RawURLEncoding.EncodeToString(LFS.JWTSecretBytes)
@@ -660,14 +660,14 @@ please consider changing to GITEA_CUSTOM`)
660 660
 			if com.IsFile(CustomConf) {
661 661
 				// Keeps custom settings if there is already something.
662 662
 				if err := cfg.Append(CustomConf); err != nil {
663
-					log.Error(4, "Fail to load custom conf '%s': %v", CustomConf, err)
663
+					log.Error(4, "Failed to load custom conf '%s': %v", CustomConf, err)
664 664
 				}
665 665
 			}
666 666
 
667 667
 			cfg.Section("server").Key("LFS_JWT_SECRET").SetValue(LFS.JWTSecretBase64)
668 668
 
669 669
 			if err := os.MkdirAll(filepath.Dir(CustomConf), os.ModePerm); err != nil {
670
-				log.Fatal(4, "Fail to create '%s': %v", CustomConf, err)
670
+				log.Fatal(4, "Failed to create '%s': %v", CustomConf, err)
671 671
 			}
672 672
 			if err := cfg.SaveTo(CustomConf); err != nil {
673 673
 				log.Fatal(4, "Error saving generated JWT Secret to custom config: %v", err)
@@ -680,22 +680,22 @@ please consider changing to GITEA_CUSTOM`)
680 680
 
681 681
 		binVersion, err := git.BinVersion()
682 682
 		if err != nil {
683
-			log.Fatal(4, "Error retrieving git version: %s", err)
683
+			log.Fatal(4, "Error retrieving git version: %v", err)
684 684
 		}
685 685
 
686 686
 		splitVersion := strings.SplitN(binVersion, ".", 3)
687 687
 
688 688
 		majorVersion, err := strconv.ParseUint(splitVersion[0], 10, 64)
689 689
 		if err != nil {
690
-			log.Fatal(4, "Error parsing git major version: %s", err)
690
+			log.Fatal(4, "Error parsing git major version: %v", err)
691 691
 		}
692 692
 		minorVersion, err := strconv.ParseUint(splitVersion[1], 10, 64)
693 693
 		if err != nil {
694
-			log.Fatal(4, "Error parsing git minor version: %s", err)
694
+			log.Fatal(4, "Error parsing git minor version: %v", err)
695 695
 		}
696 696
 		revisionVersion, err := strconv.ParseUint(splitVersion[2], 10, 64)
697 697
 		if err != nil {
698
-			log.Fatal(4, "Error parsing git revision version: %s", err)
698
+			log.Fatal(4, "Error parsing git revision version: %v", err)
699 699
 		}
700 700
 
701 701
 		if !((majorVersion > 2) || (majorVersion == 2 && minorVersion > 1) ||
@@ -771,11 +771,11 @@ please consider changing to GITEA_CUSTOM`)
771 771
 	}
772 772
 	ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
773 773
 	if err = Cfg.Section("repository").MapTo(&Repository); err != nil {
774
-		log.Fatal(4, "Fail to map Repository settings: %v", err)
774
+		log.Fatal(4, "Failed to map Repository settings: %v", err)
775 775
 	} else if err = Cfg.Section("repository.editor").MapTo(&Repository.Editor); err != nil {
776
-		log.Fatal(4, "Fail to map Repository.Editor settings: %v", err)
776
+		log.Fatal(4, "Failed to map Repository.Editor settings: %v", err)
777 777
 	} else if err = Cfg.Section("repository.upload").MapTo(&Repository.Upload); err != nil {
778
-		log.Fatal(4, "Fail to map Repository.Upload settings: %v", err)
778
+		log.Fatal(4, "Failed to map Repository.Upload settings: %v", err)
779 779
 	}
780 780
 
781 781
 	if !filepath.IsAbs(Repository.Upload.TempPath) {
@@ -823,17 +823,17 @@ please consider changing to GITEA_CUSTOM`)
823 823
 	}
824 824
 
825 825
 	if err = Cfg.Section("ui").MapTo(&UI); err != nil {
826
-		log.Fatal(4, "Fail to map UI settings: %v", err)
826
+		log.Fatal(4, "Failed to map UI settings: %v", err)
827 827
 	} else if err = Cfg.Section("markdown").MapTo(&Markdown); err != nil {
828
-		log.Fatal(4, "Fail to map Markdown settings: %v", err)
828
+		log.Fatal(4, "Failed to map Markdown settings: %v", err)
829 829
 	} else if err = Cfg.Section("cron").MapTo(&Cron); err != nil {
830
-		log.Fatal(4, "Fail to map Cron settings: %v", err)
830
+		log.Fatal(4, "Failed to map Cron settings: %v", err)
831 831
 	} else if err = Cfg.Section("git").MapTo(&Git); err != nil {
832
-		log.Fatal(4, "Fail to map Git settings: %v", err)
832
+		log.Fatal(4, "Failed to map Git settings: %v", err)
833 833
 	} else if err = Cfg.Section("mirror").MapTo(&Mirror); err != nil {
834
-		log.Fatal(4, "Fail to map Mirror settings: %v", err)
834
+		log.Fatal(4, "Failed to map Mirror settings: %v", err)
835 835
 	} else if err = Cfg.Section("api").MapTo(&API); err != nil {
836
-		log.Fatal(4, "Fail to map API settings: %v", err)
836
+		log.Fatal(4, "Failed to map API settings: %v", err)
837 837
 	}
838 838
 
839 839
 	if Mirror.DefaultInterval <= 0 {

+ 5 - 6
modules/ssh/ssh.go

@@ -5,7 +5,6 @@
5 5
 package ssh
6 6
 
7 7
 import (
8
-	"fmt"
9 8
 	"io"
10 9
 	"io/ioutil"
11 10
 	"net"
@@ -117,7 +116,7 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) {
117 116
 func listen(config *ssh.ServerConfig, host string, port int) {
118 117
 	listener, err := net.Listen("tcp", host+":"+com.ToStr(port))
119 118
 	if err != nil {
120
-		log.Fatal(4, "Fail to start SSH server: %v", err)
119
+		log.Fatal(4, "Failed to start SSH server: %v", err)
121 120
 	}
122 121
 	for {
123 122
 		// Once a ServerConfig has been configured, connections can be accepted.
@@ -169,23 +168,23 @@ func Listen(host string, port int) {
169 168
 		filePath := filepath.Dir(keyPath)
170 169
 
171 170
 		if err := os.MkdirAll(filePath, os.ModePerm); err != nil {
172
-			log.Error(4, "Fail to create dir %s: %v", filePath, err)
171
+			log.Error(4, "Failed to create dir %s: %v", filePath, err)
173 172
 		}
174 173
 
175 174
 		_, stderr, err := com.ExecCmd("ssh-keygen", "-f", keyPath, "-t", "rsa", "-N", "")
176 175
 		if err != nil {
177
-			panic(fmt.Sprintf("Fail to generate private key: %v - %s", err, stderr))
176
+			log.Fatal(4, "Failed to generate private key: %v - %s", err, stderr)
178 177
 		}
179 178
 		log.Trace("SSH: New private key is generateed: %s", keyPath)
180 179
 	}
181 180
 
182 181
 	privateBytes, err := ioutil.ReadFile(keyPath)
183 182
 	if err != nil {
184
-		panic("SSH: Fail to load private key")
183
+		log.Fatal(4, "SSH: Failed to load private key")
185 184
 	}
186 185
 	private, err := ssh.ParsePrivateKey(privateBytes)
187 186
 	if err != nil {
188
-		panic("SSH: Fail to parse private key")
187
+		log.Fatal(4, "SSH: Failed to parse private key")
189 188
 	}
190 189
 	config.AddHostKey(private)
191 190
 

+ 1 - 1
routers/init.go

@@ -51,7 +51,7 @@ func GlobalInit() {
51 51
 		highlight.NewContext()
52 52
 		markdown.BuildSanitizer()
53 53
 		if err := models.NewEngine(); err != nil {
54
-			log.Fatal(4, "Fail to initialize ORM engine: %v", err)
54
+			log.Fatal(4, "Failed to initialize ORM engine: %v", err)
55 55
 		}
56 56
 		models.HasEngine = true
57 57
 

+ 1 - 1
routers/install.go

@@ -242,7 +242,7 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
242 242
 	if com.IsFile(setting.CustomConf) {
243 243
 		// Keeps custom settings if there is already something.
244 244
 		if err = cfg.Append(setting.CustomConf); err != nil {
245
-			log.Error(4, "Fail to load custom conf '%s': %v", setting.CustomConf, err)
245
+			log.Error(4, "Failed to load custom conf '%s': %v", setting.CustomConf, err)
246 246
 		}
247 247
 	}
248 248
 	cfg.Section("database").Key("DB_TYPE").SetValue(models.DbCfg.Type)

+ 3 - 3
routers/repo/view.go

@@ -6,10 +6,12 @@ package repo
6 6
 
7 7
 import (
8 8
 	"bytes"
9
+	"encoding/base64"
9 10
 	"fmt"
10 11
 	gotemplate "html/template"
11 12
 	"io/ioutil"
12 13
 	"path"
14
+	"strconv"
13 15
 	"strings"
14 16
 
15 17
 	"code.gitea.io/git"
@@ -22,9 +24,7 @@ import (
22 24
 	"code.gitea.io/gitea/modules/markdown"
23 25
 	"code.gitea.io/gitea/modules/setting"
24 26
 	"code.gitea.io/gitea/modules/templates"
25
-	"encoding/base64"
26 27
 	"github.com/Unknwon/paginater"
27
-	"strconv"
28 28
 )
29 29
 
30 30
 const (
@@ -193,7 +193,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
193 193
 			var fileContent string
194 194
 			if content, err := templates.ToUTF8WithErr(buf); err != nil {
195 195
 				if err != nil {
196
-					log.Error(4, "ToUTF8WithErr: %s", err)
196
+					log.Error(4, "ToUTF8WithErr: %v", err)
197 197
 				}
198 198
 				fileContent = string(buf)
199 199
 			} else {