mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
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.
This commit is contained in:
committed by
Kim "BKC" Carlbäcker
parent
73d05a51e3
commit
bf6f61cc69
@@ -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 {
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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))
|
||||
|
@@ -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)
|
||||
|
@@ -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.
|
||||
|
@@ -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)
|
||||
|
@@ -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 {
|
||||
|
@@ -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 {
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user