diff options
author | zeripath <art27@cantab.net> | 2019-04-02 08:48:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-02 08:48:31 +0100 |
commit | 704da08fdc6bae6fdd6bf1b892ebe12afeef5eca (patch) | |
tree | e0613ab3ba0d4336b0912bbad8862f503ec180f6 /models/pull.go | |
parent | ef2a343e27d8af2de0bb696bd60d9a019e1e8b69 (diff) | |
download | gitea-704da08fdc6bae6fdd6bf1b892ebe12afeef5eca.tar.gz gitea-704da08fdc6bae6fdd6bf1b892ebe12afeef5eca.zip |
Better logging (#6038) (#6095)
* Panic don't fatal on create new logger
Fixes #5854
Signed-off-by: Andrew Thornton <art27@cantab.net>
* partial broken
* Update the logging infrastrcture
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Reset the skip levels for Fatal and Error
Signed-off-by: Andrew Thornton <art27@cantab.net>
* broken ncsa
* More log.Error fixes
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Remove nal
* set log-levels to lowercase
* Make console_test test all levels
* switch to lowercased levels
* OK now working
* Fix vetting issues
* Fix lint
* Fix tests
* change default logging to match current gitea
* Improve log testing
Signed-off-by: Andrew Thornton <art27@cantab.net>
* reset error skip levels to 0
* Update documentation and access logger configuration
* Redirect the router log back to gitea if redirect macaron log but also allow setting the log level - i.e. TRACE
* Fix broken level caching
* Refactor the router log
* Add Router logger
* Add colorizing options
* Adjust router colors
* Only create logger if they will be used
* update app.ini.sample
* rename Attribute ColorAttribute
* Change from white to green for function
* Set fatal/error levels
* Restore initial trace logger
* Fix Trace arguments in modules/auth/auth.go
* Properly handle XORMLogger
* Improve admin/config page
* fix fmt
* Add auto-compression of old logs
* Update error log levels
* Remove the unnecessary skip argument from Error, Fatal and Critical
* Add stacktrace support
* Fix tests
* Remove x/sync from vendors?
* Add stderr option to console logger
* Use filepath.ToSlash to protect against Windows in tests
* Remove prefixed underscores from names in colors.go
* Remove not implemented database logger
This was removed from Gogs on 4 Mar 2016 but left in the configuration
since then.
* Ensure that log paths are relative to ROOT_PATH
* use path.Join
* rename jsonConfig to logConfig
* Rename "config" to "jsonConfig" to make it clearer
* Requested changes
* Requested changes: XormLogger
* Try to color the windows terminal
If successful default to colorizing the console logs
* fixup
* Colorize initially too
* update vendor
* Colorize logs on default and remove if this is not a colorizing logger
* Fix documentation
* fix test
* Use go-isatty to detect if on windows we are on msys or cygwin
* Fix spelling mistake
* Add missing vendors
* More changes
* Rationalise the ANSI writer protection
* Adjust colors on advice from @0x5c
* Make Flags a comma separated list
* Move to use the windows constant for ENABLE_VIRTUAL_TERMINAL_PROCESSING
* Ensure matching is done on the non-colored message - to simpify EXPRESSION
Diffstat (limited to 'models/pull.go')
-rw-r--r-- | models/pull.go | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/models/pull.go b/models/pull.go index ef3ec8e145..ccd8155317 100644 --- a/models/pull.go +++ b/models/pull.go @@ -135,7 +135,7 @@ func (pr *PullRequest) GetDefaultMergeMessage() string { var err error pr.HeadRepo, err = GetRepositoryByID(pr.HeadRepoID) if err != nil { - log.Error(4, "GetRepositoryById[%d]: %v", pr.HeadRepoID, err) + log.Error("GetRepositoryById[%d]: %v", pr.HeadRepoID, err) return "" } } @@ -145,7 +145,7 @@ func (pr *PullRequest) GetDefaultMergeMessage() string { // GetDefaultSquashMessage returns default message used when squash and merging pull request func (pr *PullRequest) GetDefaultSquashMessage() string { if err := pr.LoadIssue(); err != nil { - log.Error(4, "LoadIssue: %v", err) + log.Error("LoadIssue: %v", err) return "" } return fmt.Sprintf("%s (#%d)", pr.Issue.Title, pr.Issue.Index) @@ -172,21 +172,21 @@ func (pr *PullRequest) apiFormat(e Engine) *api.PullRequest { err error ) if err = pr.Issue.loadRepo(e); err != nil { - log.Error(log.ERROR, "loadRepo[%d]: %v", pr.ID, err) + log.Error("loadRepo[%d]: %v", pr.ID, err) return nil } apiIssue := pr.Issue.apiFormat(e) if pr.BaseRepo == nil { pr.BaseRepo, err = getRepositoryByID(e, pr.BaseRepoID) if err != nil { - log.Error(log.ERROR, "GetRepositoryById[%d]: %v", pr.ID, err) + log.Error("GetRepositoryById[%d]: %v", pr.ID, err) return nil } } if pr.HeadRepo == nil { pr.HeadRepo, err = getRepositoryByID(e, pr.HeadRepoID) if err != nil { - log.Error(log.ERROR, "GetRepositoryById[%d]: %v", pr.ID, err) + log.Error("GetRepositoryById[%d]: %v", pr.ID, err) return nil } } @@ -581,11 +581,11 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle pr.MergerID = doer.ID if err = pr.setMerged(); err != nil { - log.Error(4, "setMerged [%d]: %v", pr.ID, err) + log.Error("setMerged [%d]: %v", pr.ID, err) } if err = MergePullRequestAction(doer, pr.Issue.Repo, pr.Issue); err != nil { - log.Error(4, "MergePullRequestAction [%d]: %v", pr.ID, err) + log.Error("MergePullRequestAction [%d]: %v", pr.ID, err) } // Reset cached commit count @@ -593,7 +593,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle // Reload pull request information. if err = pr.LoadAttributes(); err != nil { - log.Error(4, "LoadAttributes: %v", err) + log.Error("LoadAttributes: %v", err) return nil } @@ -605,14 +605,14 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle Repository: pr.Issue.Repo.APIFormat(mode), Sender: doer.APIFormat(), }); err != nil { - log.Error(4, "PrepareWebhooks: %v", err) + log.Error("PrepareWebhooks: %v", err) } else { go HookQueue.Add(pr.Issue.Repo.ID) } l, err := baseGitRepo.CommitsBetweenIDs(pr.MergedCommitID, pr.MergeBase) if err != nil { - log.Error(4, "CommitsBetweenIDs: %v", err) + log.Error("CommitsBetweenIDs: %v", err) return nil } @@ -621,7 +621,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle // to avoid strange diff commits produced. mergeCommit, err := baseGitRepo.GetBranchCommit(pr.BaseBranch) if err != nil { - log.Error(4, "GetBranchCommit: %v", err) + log.Error("GetBranchCommit: %v", err) return nil } if mergeStyle == MergeStyleMerge { @@ -639,7 +639,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle Sender: doer.APIFormat(), } if err = PrepareWebhooks(pr.BaseRepo, HookEventPush, p); err != nil { - log.Error(4, "PrepareWebhooks: %v", err) + log.Error("PrepareWebhooks: %v", err) } else { go HookQueue.Add(pr.BaseRepo.ID) } @@ -692,7 +692,7 @@ func (pr *PullRequest) setMerged() (err error) { func (pr *PullRequest) manuallyMerged() bool { commit, err := pr.getMergeCommit() if err != nil { - log.Error(4, "PullRequest[%d].getMergeCommit: %v", pr.ID, err) + log.Error("PullRequest[%d].getMergeCommit: %v", pr.ID, err) return false } if commit != nil { @@ -705,7 +705,7 @@ func (pr *PullRequest) manuallyMerged() bool { if merger == nil { if pr.BaseRepo.Owner == nil { if err = pr.BaseRepo.getOwner(x); err != nil { - log.Error(4, "BaseRepo.getOwner[%d]: %v", pr.ID, err) + log.Error("BaseRepo.getOwner[%d]: %v", pr.ID, err) return false } } @@ -715,7 +715,7 @@ func (pr *PullRequest) manuallyMerged() bool { pr.MergerID = merger.ID if err = pr.setMerged(); err != nil { - log.Error(4, "PullRequest[%d].setMerged : %v", pr.ID, err) + log.Error("PullRequest[%d].setMerged : %v", pr.ID, err) return false } log.Info("manuallyMerged[%d]: Marked as manually merged into %s/%s by commit id: %s", pr.ID, pr.BaseRepo.Name, pr.BaseBranch, commit.ID.String()) @@ -936,7 +936,7 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str Repo: repo, IsPrivate: repo.IsPrivate, }); err != nil { - log.Error(4, "NotifyWatchers: %v", err) + log.Error("NotifyWatchers: %v", err) } pr.Issue = pull @@ -949,7 +949,7 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str Repository: repo.APIFormat(mode), Sender: pull.Poster.APIFormat(), }); err != nil { - log.Error(4, "PrepareWebhooks: %v", err) + log.Error("PrepareWebhooks: %v", err) } else { go HookQueue.Add(repo.ID) } @@ -997,12 +997,12 @@ func PullRequests(baseRepoID int64, opts *PullRequestsOptions) ([]*PullRequest, countSession, err := listPullRequestStatement(baseRepoID, opts) if err != nil { - log.Error(4, "listPullRequestStatement", err) + log.Error("listPullRequestStatement: %v", err) return nil, 0, err } maxResults, err := countSession.Count(new(PullRequest)) if err != nil { - log.Error(4, "Count PRs", err) + log.Error("Count PRs: %v", err) return nil, maxResults, err } @@ -1010,7 +1010,7 @@ func PullRequests(baseRepoID int64, opts *PullRequestsOptions) ([]*PullRequest, findSession, err := listPullRequestStatement(baseRepoID, opts) sortIssuesSession(findSession, opts.SortType) if err != nil { - log.Error(4, "listPullRequestStatement", err) + log.Error("listPullRequestStatement: %v", err) return nil, maxResults, err } findSession.Limit(ItemsPerPage, (opts.Page-1)*ItemsPerPage) @@ -1215,7 +1215,7 @@ func (pr *PullRequest) AddToTaskQueue() { go pullRequestQueue.AddFunc(pr.ID, func() { pr.Status = PullRequestStatusChecking if err := pr.UpdateCols("status"); err != nil { - log.Error(5, "AddToTaskQueue.UpdateCols[%d].(add to queue): %v", pr.ID, err) + log.Error("AddToTaskQueue.UpdateCols[%d].(add to queue): %v", pr.ID, err) } }) } @@ -1290,10 +1290,10 @@ func addHeadRepoTasks(prs []*PullRequest) { for _, pr := range prs { log.Trace("addHeadRepoTasks[%d]: composing new test task", pr.ID) if err := pr.UpdatePatch(); err != nil { - log.Error(4, "UpdatePatch: %v", err) + log.Error("UpdatePatch: %v", err) continue } else if err := pr.PushToBaseRepo(); err != nil { - log.Error(4, "PushToBaseRepo: %v", err) + log.Error("PushToBaseRepo: %v", err) continue } @@ -1307,23 +1307,23 @@ func AddTestPullRequestTask(doer *User, repoID int64, branch string, isSync bool log.Trace("AddTestPullRequestTask [head_repo_id: %d, head_branch: %s]: finding pull requests", repoID, branch) prs, err := GetUnmergedPullRequestsByHeadInfo(repoID, branch) if err != nil { - log.Error(4, "Find pull requests [head_repo_id: %d, head_branch: %s]: %v", repoID, branch, err) + log.Error("Find pull requests [head_repo_id: %d, head_branch: %s]: %v", repoID, branch, err) return } if isSync { requests := PullRequestList(prs) if err = requests.LoadAttributes(); err != nil { - log.Error(4, "PullRequestList.LoadAttributes: %v", err) + log.Error("PullRequestList.LoadAttributes: %v", err) } if invalidationErr := checkForInvalidation(requests, repoID, doer, branch); invalidationErr != nil { - log.Error(4, "checkForInvalidation: %v", invalidationErr) + log.Error("checkForInvalidation: %v", invalidationErr) } if err == nil { for _, pr := range prs { pr.Issue.PullRequest = pr if err = pr.Issue.LoadAttributes(); err != nil { - log.Error(4, "LoadAttributes: %v", err) + log.Error("LoadAttributes: %v", err) continue } if err = PrepareWebhooks(pr.Issue.Repo, HookEventPullRequest, &api.PullRequestPayload{ @@ -1333,7 +1333,7 @@ func AddTestPullRequestTask(doer *User, repoID int64, branch string, isSync bool Repository: pr.Issue.Repo.APIFormat(AccessModeNone), Sender: doer.APIFormat(), }); err != nil { - log.Error(4, "PrepareWebhooks [pull_id: %v]: %v", pr.ID, err) + log.Error("PrepareWebhooks [pull_id: %v]: %v", pr.ID, err) continue } go HookQueue.Add(pr.Issue.Repo.ID) @@ -1347,7 +1347,7 @@ func AddTestPullRequestTask(doer *User, repoID int64, branch string, isSync bool log.Trace("AddTestPullRequestTask [base_repo_id: %d, base_branch: %s]: finding pull requests", repoID, branch) prs, err = GetUnmergedPullRequestsByBaseInfo(repoID, branch) if err != nil { - log.Error(4, "Find pull requests [base_repo_id: %d, base_branch: %s]: %v", repoID, branch, err) + log.Error("Find pull requests [base_repo_id: %d, base_branch: %s]: %v", repoID, branch, err) return } for _, pr := range prs { @@ -1367,7 +1367,7 @@ func checkForInvalidation(requests PullRequestList, repoID int64, doer *User, br go func() { err := requests.InvalidateCodeComments(doer, gitRepo, branch) if err != nil { - log.Error(4, "PullRequestList.InvalidateCodeComments: %v", err) + log.Error("PullRequestList.InvalidateCodeComments: %v", err) } }() return nil @@ -1396,7 +1396,7 @@ func (pr *PullRequest) checkAndUpdateStatus() { // Make sure there is no waiting test to process before leaving the checking status. if !pullRequestQueue.Exist(pr.ID) { if err := pr.UpdateCols("status, conflicted_files"); err != nil { - log.Error(4, "Update[%d]: %v", pr.ID, err) + log.Error("Update[%d]: %v", pr.ID, err) } } } @@ -1404,7 +1404,7 @@ func (pr *PullRequest) checkAndUpdateStatus() { // IsWorkInProgress determine if the Pull Request is a Work In Progress by its title func (pr *PullRequest) IsWorkInProgress() bool { if err := pr.LoadIssue(); err != nil { - log.Error(4, "LoadIssue: %v", err) + log.Error("LoadIssue: %v", err) return false } @@ -1425,7 +1425,7 @@ func (pr *PullRequest) IsFilesConflicted() bool { // It returns an empty string when none were found func (pr *PullRequest) GetWorkInProgressPrefix() string { if err := pr.LoadIssue(); err != nil { - log.Error(4, "LoadIssue: %v", err) + log.Error("LoadIssue: %v", err) return "" } @@ -1444,7 +1444,7 @@ func TestPullRequests() { err := x.Where("status = ?", PullRequestStatusChecking).Find(&prs) if err != nil { - log.Error(3, "Find Checking PRs", err) + log.Error("Find Checking PRs: %v", err) return } @@ -1454,14 +1454,14 @@ func TestPullRequests() { for _, pr := range prs { checkedPRs[pr.ID] = struct{}{} if err := pr.GetBaseRepo(); err != nil { - log.Error(3, "GetBaseRepo: %v", err) + log.Error("GetBaseRepo: %v", err) continue } if pr.manuallyMerged() { continue } if err := pr.testPatch(x); err != nil { - log.Error(3, "testPatch: %v", err) + log.Error("testPatch: %v", err) continue } @@ -1480,12 +1480,12 @@ func TestPullRequests() { pr, err := GetPullRequestByID(id) if err != nil { - log.Error(4, "GetPullRequestByID[%s]: %v", prID, err) + log.Error("GetPullRequestByID[%s]: %v", prID, err) continue } else if pr.manuallyMerged() { continue } else if err = pr.testPatch(x); err != nil { - log.Error(4, "testPatch[%d]: %v", pr.ID, err) + log.Error("testPatch[%d]: %v", pr.ID, err) continue } |