summaryrefslogtreecommitdiffstats
path: root/models
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 /models
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 'models')
-rw-r--r--models/migrations/migrations.go2
-rw-r--r--models/models.go10
-rw-r--r--models/org.go4
-rw-r--r--models/pull.go2
-rw-r--r--models/repo.go28
-rw-r--r--models/repo_editor.go6
-rw-r--r--models/repo_mirror.go4
-rw-r--r--models/ssh_key.go2
-rw-r--r--models/update.go2
-rw-r--r--models/user.go8
-rw-r--r--models/wiki.go4
11 files changed, 36 insertions, 36 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go
index 69408a071d..5844e3f923 100644
--- a/models/migrations/migrations.go
+++ b/models/migrations/migrations.go
@@ -328,7 +328,7 @@ func attachmentRefactor(x *xorm.Engine) error {
dumpPath := path.Join(setting.LogRootPath, "attachment_path.dump")
ioutil.WriteFile(dumpPath, buf.Bytes(), 0666)
- fmt.Println("Fail to rename some attachments, old and new paths are saved into:", dumpPath)
+ log.Info("Failed to rename some attachments, old and new paths are saved into: %s", dumpPath)
}()
for _, attach := range attachments {
if err = os.MkdirAll(path.Dir(attach.NewPath), os.ModePerm); err != nil {
diff --git a/models/models.go b/models/models.go
index 1ce704a9e4..7353c11598 100644
--- a/models/models.go
+++ b/models/models.go
@@ -205,7 +205,7 @@ func getEngine() (*xorm.Engine, error) {
return nil, errors.New("this binary version does not build support for SQLite3")
}
if err := os.MkdirAll(path.Dir(DbCfg.Path), os.ModePerm); err != nil {
- return nil, fmt.Errorf("Fail to create directories: %v", err)
+ return nil, fmt.Errorf("Failed to create directories: %v", err)
}
connStr = "file:" + DbCfg.Path + "?cache=shared&mode=rwc"
case "tidb":
@@ -213,7 +213,7 @@ func getEngine() (*xorm.Engine, error) {
return nil, errors.New("this binary version does not build support for TiDB")
}
if err := os.MkdirAll(path.Dir(DbCfg.Path), os.ModePerm); err != nil {
- return nil, fmt.Errorf("Fail to create directories: %v", err)
+ return nil, fmt.Errorf("Failed to create directories: %v", err)
}
connStr = "goleveldb://" + DbCfg.Path
default:
@@ -237,7 +237,7 @@ func NewTestEngine(x *xorm.Engine) (err error) {
func SetEngine() (err error) {
x, err = getEngine()
if err != nil {
- return fmt.Errorf("Fail to connect to database: %v", err)
+ return fmt.Errorf("Failed to connect to database: %v", err)
}
x.SetMapper(core.GonicMapper{})
@@ -247,12 +247,12 @@ func SetEngine() (err error) {
logPath := path.Join(setting.LogRootPath, "xorm.log")
if err := os.MkdirAll(path.Dir(logPath), os.ModePerm); err != nil {
- return fmt.Errorf("Fail to create dir %s: %v", logPath, err)
+ return fmt.Errorf("Failed to create dir %s: %v", logPath, err)
}
f, err := os.Create(logPath)
if err != nil {
- return fmt.Errorf("Fail to create xorm.log: %v", err)
+ return fmt.Errorf("Failed to create xorm.log: %v", err)
}
x.SetLogger(xorm.NewSimpleLogger(f))
x.ShowSQL(true)
diff --git a/models/org.go b/models/org.go
index 9911523b70..40f34a4f09 100644
--- a/models/org.go
+++ b/models/org.go
@@ -272,13 +272,13 @@ func deleteOrg(e *xorm.Session, u *User) error {
path := UserPath(u.Name)
if err := os.RemoveAll(path); err != nil {
- return fmt.Errorf("Fail to RemoveAll %s: %v", path, err)
+ return fmt.Errorf("Failed to RemoveAll %s: %v", path, err)
}
avatarPath := u.CustomAvatarPath()
if com.IsExist(avatarPath) {
if err := os.Remove(avatarPath); err != nil {
- return fmt.Errorf("Fail to remove %s: %v", avatarPath, err)
+ return fmt.Errorf("Failed to remove %s: %v", avatarPath, err)
}
}
diff --git a/models/pull.go b/models/pull.go
index e680480978..bdbe4b3a98 100644
--- a/models/pull.go
+++ b/models/pull.go
@@ -275,7 +275,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error
tmpBasePath := path.Join(setting.AppDataPath, "tmp/repos", com.ToStr(time.Now().Nanosecond())+".git")
if err := os.MkdirAll(path.Dir(tmpBasePath), os.ModePerm); err != nil {
- return fmt.Errorf("Fail to create dir %s: %v", tmpBasePath, err)
+ return fmt.Errorf("Failed to create dir %s: %v", tmpBasePath, err)
}
defer os.RemoveAll(path.Dir(tmpBasePath))
diff --git a/models/repo.go b/models/repo.go
index 0e6665b3fb..e286970373 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -83,13 +83,13 @@ func LoadRepoConfig() {
for i, t := range types {
files, err := options.Dir(t)
if err != nil {
- log.Fatal(4, "Fail to get %s files: %v", t, err)
+ log.Fatal(4, "Failed to get %s files: %v", t, err)
}
customPath := path.Join(setting.CustomPath, "options", t)
if com.IsDir(customPath) {
customFiles, err := com.StatDir(customPath)
if err != nil {
- log.Fatal(4, "Fail to get custom %s files: %v", t, err)
+ log.Fatal(4, "Failed to get custom %s files: %v", t, err)
}
for _, f := range customFiles {
@@ -131,13 +131,13 @@ func NewRepoContext() {
// Check Git installation.
if _, err := exec.LookPath("git"); err != nil {
- log.Fatal(4, "Fail to test 'git' command: %v (forgotten install?)", err)
+ log.Fatal(4, "Failed to test 'git' command: %v (forgotten install?)", err)
}
// Check Git version.
gitVer, err := git.BinVersion()
if err != nil {
- log.Fatal(4, "Fail to get Git version: %v", err)
+ log.Fatal(4, "Failed to get Git version: %v", err)
}
log.Info("Git Version: %s", gitVer)
@@ -151,11 +151,11 @@ func NewRepoContext() {
// ExitError indicates this config is not set
if _, ok := err.(*exec.ExitError); ok || strings.TrimSpace(stdout) == "" {
if _, stderr, gerr := process.GetManager().Exec("NewRepoContext(set "+configKey+")", "git", "config", "--global", configKey, defaultValue); gerr != nil {
- log.Fatal(4, "Fail to set git %s(%s): %s", configKey, gerr, stderr)
+ log.Fatal(4, "Failed to set git %s(%s): %s", configKey, gerr, stderr)
}
log.Info("Git config %s set to %s", configKey, defaultValue)
} else {
- log.Fatal(4, "Fail to get git %s(%s): %s", configKey, err, stderr)
+ log.Fatal(4, "Failed to get git %s(%s): %s", configKey, err, stderr)
}
}
}
@@ -163,7 +163,7 @@ func NewRepoContext() {
// Set git some configurations.
if _, stderr, err := process.GetManager().Exec("NewRepoContext(git config --global core.quotepath false)",
"git", "config", "--global", "core.quotepath", "false"); err != nil {
- log.Fatal(4, "Fail to execute 'git config --global core.quotepath false': %s", stderr)
+ log.Fatal(4, "Failed to execute 'git config --global core.quotepath false': %s", stderr)
}
RemoveAllWithNotice("Clean up repository temporary data", filepath.Join(setting.AppDataPath, "tmp"))
@@ -566,7 +566,7 @@ func (repo *Repository) SavePatch(index int64, patch []byte) error {
dir := filepath.Dir(patchPath)
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
- return fmt.Errorf("Fail to create dir %s: %v", dir, err)
+ return fmt.Errorf("Failed to create dir %s: %v", dir, err)
}
if err = ioutil.WriteFile(patchPath, patch, 0644); err != nil {
@@ -679,7 +679,7 @@ func MigrateRepository(u *User, opts MigrateRepoOptions) (*Repository, error) {
migrateTimeout := time.Duration(setting.Git.Timeout.Migrate) * time.Second
if err := os.RemoveAll(repoPath); err != nil {
- return repo, fmt.Errorf("Fail to remove %s: %v", repoPath, err)
+ return repo, fmt.Errorf("Failed to remove %s: %v", repoPath, err)
}
if err = git.Clone(opts.RemoteAddr, repoPath, git.CloneRepoOptions{
@@ -693,7 +693,7 @@ func MigrateRepository(u *User, opts MigrateRepoOptions) (*Repository, error) {
wikiRemotePath := wikiRemoteURL(opts.RemoteAddr)
if len(wikiRemotePath) > 0 {
if err := os.RemoveAll(wikiPath); err != nil {
- return repo, fmt.Errorf("Fail to remove %s: %v", wikiPath, err)
+ return repo, fmt.Errorf("Failed to remove %s: %v", wikiPath, err)
}
if err = git.Clone(wikiRemotePath, wikiPath, git.CloneRepoOptions{
@@ -704,7 +704,7 @@ func MigrateRepository(u *User, opts MigrateRepoOptions) (*Repository, error) {
}); err != nil {
log.Warn("Clone wiki: %v", err)
if err := os.RemoveAll(wikiPath); err != nil {
- return repo, fmt.Errorf("Fail to remove %s: %v", wikiPath, err)
+ return repo, fmt.Errorf("Failed to remove %s: %v", wikiPath, err)
}
}
}
@@ -938,7 +938,7 @@ func initRepository(e Engine, repoPath string, u *User, repo *Repository, opts C
if opts.AutoInit {
if err := os.MkdirAll(tmpDir, os.ModePerm); err != nil {
- return fmt.Errorf("Fail to create dir %s: %v", tmpDir, err)
+ return fmt.Errorf("Failed to create dir %s: %v", tmpDir, err)
}
defer os.RemoveAll(tmpDir)
@@ -1243,7 +1243,7 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error
dir := UserPath(newOwner.Name)
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
- return fmt.Errorf("Fail to create dir %s: %v", dir, err)
+ return fmt.Errorf("Failed to create dir %s: %v", dir, err)
}
if err = os.Rename(RepoPath(owner.Name, repo.Name), RepoPath(newOwner.Name, repo.Name)); err != nil {
@@ -1818,7 +1818,7 @@ func GitFsck() {
repo := bean.(*Repository)
repoPath := repo.RepoPath()
if err := git.Fsck(repoPath, setting.Cron.RepoHealthCheck.Timeout, setting.Cron.RepoHealthCheck.Args...); err != nil {
- desc := fmt.Sprintf("Fail to health check repository (%s): %v", repoPath, err)
+ desc := fmt.Sprintf("Failed to health check repository (%s): %v", repoPath, err)
log.Warn(desc)
if err = CreateRepositoryNotice(desc); err != nil {
log.Error(4, "CreateRepositoryNotice: %v", err)
diff --git a/models/repo_editor.go b/models/repo_editor.go
index 53df81bb59..c675e1cfa8 100644
--- a/models/repo_editor.go
+++ b/models/repo_editor.go
@@ -107,7 +107,7 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (
dir := path.Dir(filePath)
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
- return fmt.Errorf("Fail to create dir %s: %v", dir, err)
+ return fmt.Errorf("Failed to create dir %s: %v", dir, err)
}
// 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 *
dir := filepath.Dir(filePath)
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
- return nil, fmt.Errorf("Fail to create dir %s: %v", dir, err)
+ return nil, fmt.Errorf("Failed to create dir %s: %v", dir, err)
}
if err = ioutil.WriteFile(filePath, []byte(content), 0666); err != nil {
@@ -486,7 +486,7 @@ func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions)
dirPath := path.Join(localPath, opts.TreePath)
if err := os.MkdirAll(dirPath, os.ModePerm); err != nil {
- return fmt.Errorf("Fail to create dir %s: %v", dirPath, err)
+ return fmt.Errorf("Failed to create dir %s: %v", dirPath, err)
}
// Copy uploaded files into repository.
diff --git a/models/repo_mirror.go b/models/repo_mirror.go
index 99760c1496..068911282e 100644
--- a/models/repo_mirror.go
+++ b/models/repo_mirror.go
@@ -140,7 +140,7 @@ func (m *Mirror) runSync() bool {
if _, stderr, err := process.GetManager().ExecDir(
timeout, repoPath, fmt.Sprintf("Mirror.runSync: %s", repoPath),
"git", gitArgs...); err != nil {
- desc := fmt.Sprintf("Fail to update mirror repository '%s': %s", repoPath, stderr)
+ desc := fmt.Sprintf("Failed to update mirror repository '%s': %s", repoPath, stderr)
log.Error(4, desc)
if err = CreateRepositoryNotice(desc); err != nil {
log.Error(4, "CreateRepositoryNotice: %v", err)
@@ -151,7 +151,7 @@ func (m *Mirror) runSync() bool {
if _, stderr, err := process.GetManager().ExecDir(
timeout, wikiPath, fmt.Sprintf("Mirror.runSync: %s", wikiPath),
"git", "remote", "update", "--prune"); err != nil {
- desc := fmt.Sprintf("Fail to update mirror wiki repository '%s': %s", wikiPath, stderr)
+ desc := fmt.Sprintf("Failed to update mirror wiki repository '%s': %s", wikiPath, stderr)
log.Error(4, desc)
if err = CreateRepositoryNotice(desc); err != nil {
log.Error(4, "CreateRepositoryNotice: %v", err)
diff --git a/models/ssh_key.go b/models/ssh_key.go
index 3bd2a739df..9ca45fa6e8 100644
--- a/models/ssh_key.go
+++ b/models/ssh_key.go
@@ -376,7 +376,7 @@ func addKey(e Engine, key *PublicKey) (err error) {
dir := path.Dir(tmpPath)
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
- return fmt.Errorf("Fail to create dir %s: %v", dir, err)
+ return fmt.Errorf("Failed to create dir %s: %v", dir, err)
}
if err = ioutil.WriteFile(tmpPath, []byte(key.Content), 0644); err != nil {
diff --git a/models/update.go b/models/update.go
index 690bc6b329..677a9bda31 100644
--- a/models/update.go
+++ b/models/update.go
@@ -102,7 +102,7 @@ func PushUpdate(opts PushUpdateOptions) (err error) {
gitUpdate := exec.Command("git", "update-server-info")
gitUpdate.Dir = repoPath
if err = gitUpdate.Run(); err != nil {
- return fmt.Errorf("Fail to call 'git update-server-info': %v", err)
+ return fmt.Errorf("Failed to call 'git update-server-info': %v", err)
}
if isDelRef {
diff --git a/models/user.go b/models/user.go
index 7d4f536242..c4a1ce3d56 100644
--- a/models/user.go
+++ b/models/user.go
@@ -414,7 +414,7 @@ func (u *User) UploadAvatar(data []byte) error {
}
if err := os.MkdirAll(setting.AvatarUploadPath, os.ModePerm); err != nil {
- return fmt.Errorf("Fail to create dir %s: %v", setting.AvatarUploadPath, err)
+ return fmt.Errorf("Failed to create dir %s: %v", setting.AvatarUploadPath, err)
}
fw, err := os.Create(u.CustomAvatarPath())
@@ -435,7 +435,7 @@ func (u *User) DeleteAvatar() error {
log.Trace("DeleteAvatar[%d]: %s", u.ID, u.CustomAvatarPath())
if err := os.Remove(u.CustomAvatarPath()); err != nil {
- return fmt.Errorf("Fail to remove %s: %v", u.CustomAvatarPath(), err)
+ return fmt.Errorf("Failed to remove %s: %v", u.CustomAvatarPath(), err)
}
u.UseCustomAvatar = false
@@ -924,13 +924,13 @@ func deleteUser(e *xorm.Session, u *User) error {
path := UserPath(u.Name)
if err := os.RemoveAll(path); err != nil {
- return fmt.Errorf("Fail to RemoveAll %s: %v", path, err)
+ return fmt.Errorf("Failed to RemoveAll %s: %v", path, err)
}
avatarPath := u.CustomAvatarPath()
if com.IsExist(avatarPath) {
if err := os.Remove(avatarPath); err != nil {
- return fmt.Errorf("Fail to remove %s: %v", avatarPath, err)
+ return fmt.Errorf("Failed to remove %s: %v", avatarPath, err)
}
}
diff --git a/models/wiki.go b/models/wiki.go
index 2e2c1d03fa..39e4b2a443 100644
--- a/models/wiki.go
+++ b/models/wiki.go
@@ -133,7 +133,7 @@ func (repo *Repository) updateWikiPage(doer *User, oldWikiPath, wikiPath, conten
file := path.Join(localPath, oldWikiPath+".md")
if err := os.Remove(file); err != nil {
- return fmt.Errorf("Fail to remove %s: %v", file, err)
+ return fmt.Errorf("Failed to remove %s: %v", file, err)
}
}
@@ -192,7 +192,7 @@ func (repo *Repository) DeleteWikiPage(doer *User, wikiPath string) (err error)
filename := path.Join(localPath, wikiPath+".md")
if err := os.Remove(filename); err != nil {
- return fmt.Errorf("Fail to remove %s: %v", filename, err)
+ return fmt.Errorf("Failed to remove %s: %v", filename, err)
}
title := ToWikiPageName(wikiPath)