* 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
This commit is contained in:
@ -123,7 +123,7 @@ type Webhook struct {
|
||||
func (w *Webhook) AfterLoad() {
|
||||
w.HookEvent = &HookEvent{}
|
||||
if err := json.Unmarshal([]byte(w.Events), w.HookEvent); err != nil {
|
||||
log.Error(3, "Unmarshal[%d]: %v", w.ID, err)
|
||||
log.Error("Unmarshal[%d]: %v", w.ID, err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ func (w *Webhook) AfterLoad() {
|
||||
func (w *Webhook) GetSlackHook() *SlackMeta {
|
||||
s := &SlackMeta{}
|
||||
if err := json.Unmarshal([]byte(w.Meta), s); err != nil {
|
||||
log.Error(4, "webhook.GetSlackHook(%d): %v", w.ID, err)
|
||||
log.Error("webhook.GetSlackHook(%d): %v", w.ID, err)
|
||||
}
|
||||
return s
|
||||
}
|
||||
@ -140,7 +140,7 @@ func (w *Webhook) GetSlackHook() *SlackMeta {
|
||||
func (w *Webhook) GetDiscordHook() *DiscordMeta {
|
||||
s := &DiscordMeta{}
|
||||
if err := json.Unmarshal([]byte(w.Meta), s); err != nil {
|
||||
log.Error(4, "webhook.GetDiscordHook(%d): %v", w.ID, err)
|
||||
log.Error("webhook.GetDiscordHook(%d): %v", w.ID, err)
|
||||
}
|
||||
return s
|
||||
}
|
||||
@ -572,13 +572,13 @@ func (t *HookTask) AfterLoad() {
|
||||
|
||||
t.RequestInfo = &HookRequest{}
|
||||
if err := json.Unmarshal([]byte(t.RequestContent), t.RequestInfo); err != nil {
|
||||
log.Error(3, "Unmarshal RequestContent[%d]: %v", t.ID, err)
|
||||
log.Error("Unmarshal RequestContent[%d]: %v", t.ID, err)
|
||||
}
|
||||
|
||||
if len(t.ResponseContent) > 0 {
|
||||
t.ResponseInfo = &HookResponse{}
|
||||
if err := json.Unmarshal([]byte(t.ResponseContent), t.ResponseInfo); err != nil {
|
||||
log.Error(3, "Unmarshal ResponseContent[%d]: %v", t.ID, err)
|
||||
log.Error("Unmarshal ResponseContent[%d]: %v", t.ID, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -586,7 +586,7 @@ func (t *HookTask) AfterLoad() {
|
||||
func (t *HookTask) simpleMarshalJSON(v interface{}) string {
|
||||
p, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
log.Error(3, "Marshal [%d]: %v", t.ID, err)
|
||||
log.Error("Marshal [%d]: %v", t.ID, err)
|
||||
}
|
||||
return string(p)
|
||||
}
|
||||
@ -666,7 +666,7 @@ func prepareWebhook(e Engine, w *Webhook, repo *Repository, event HookEventType,
|
||||
if len(w.Secret) > 0 {
|
||||
data, err := payloader.JSONPayload()
|
||||
if err != nil {
|
||||
log.Error(2, "prepareWebhooks.JSONPayload: %v", err)
|
||||
log.Error("prepareWebhooks.JSONPayload: %v", err)
|
||||
}
|
||||
sig := hmac.New(sha256.New, []byte(w.Secret))
|
||||
sig.Write(data)
|
||||
@ -765,13 +765,13 @@ func (t *HookTask) deliver() {
|
||||
}
|
||||
|
||||
if err := UpdateHookTask(t); err != nil {
|
||||
log.Error(4, "UpdateHookTask [%d]: %v", t.ID, err)
|
||||
log.Error("UpdateHookTask [%d]: %v", t.ID, err)
|
||||
}
|
||||
|
||||
// Update webhook last delivery status.
|
||||
w, err := GetWebhookByID(t.HookID)
|
||||
if err != nil {
|
||||
log.Error(5, "GetWebhookByID: %v", err)
|
||||
log.Error("GetWebhookByID: %v", err)
|
||||
return
|
||||
}
|
||||
if t.IsSucceed {
|
||||
@ -780,7 +780,7 @@ func (t *HookTask) deliver() {
|
||||
w.LastStatus = HookStatusFail
|
||||
}
|
||||
if err = UpdateWebhookLastStatus(w); err != nil {
|
||||
log.Error(5, "UpdateWebhookLastStatus: %v", err)
|
||||
log.Error("UpdateWebhookLastStatus: %v", err)
|
||||
return
|
||||
}
|
||||
}()
|
||||
@ -813,7 +813,7 @@ func DeliverHooks() {
|
||||
tasks := make([]*HookTask, 0, 10)
|
||||
err := x.Where("is_delivered=?", false).Find(&tasks)
|
||||
if err != nil {
|
||||
log.Error(4, "DeliverHooks: %v", err)
|
||||
log.Error("DeliverHooks: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
@ -829,13 +829,13 @@ func DeliverHooks() {
|
||||
|
||||
repoID, err := com.StrTo(repoIDStr).Int64()
|
||||
if err != nil {
|
||||
log.Error(4, "Invalid repo ID: %s", repoIDStr)
|
||||
log.Error("Invalid repo ID: %s", repoIDStr)
|
||||
continue
|
||||
}
|
||||
|
||||
tasks = make([]*HookTask, 0, 5)
|
||||
if err := x.Where("repo_id=? AND is_delivered=?", repoID, false).Find(&tasks); err != nil {
|
||||
log.Error(4, "Get repository [%s] hook tasks: %v", repoID, err)
|
||||
log.Error("Get repository [%d] hook tasks: %v", repoID, err)
|
||||
continue
|
||||
}
|
||||
for _, t := range tasks {
|
||||
|
Reference in New Issue
Block a user