project-flogo / core

Flogo Core is the core flogo library used create and extend Flogo applications.
BSD 3-Clause "New" or "Revised" License
110 stars 53 forks source link

Print error stack trance only on debug mode #253

Closed lixingwang closed 3 years ago

lixingwang commented 3 years ago

What kind of change does this PR introduce? (check one with "x")

[*] Bugfix
[] Feature
[] Code style update (formatting, local variables)
[] Refactoring (no functional changes, no api changes)
[] Other... Please describe:

Fixes: #251

What is the current behavior?

Today we print error stack trace at INFO or ERROR LEVEL which prints too many logs. The stack trace should be print when only for Log Level at DEBUG or wider level.

021-03-25T10:01:46.491-0500    DEBUG   [flogo.contrib.activity.error] -        Applying InputMapper
2021-03-25T10:01:46.491-0500    DEBUG   [flogo.contrib.activity.error] -        Message :'dadsasdasdasdasd', Data: '<nil>'
2021-03-25T10:01:46.492-0500    INFO    [flogo.contrib.activity.error] -        Eval activity [ThrowError] on instance [c8f38217419f43e6f4c92b2e3d755458] done, took: 44.92µs
2021-03-25T10:01:46.492-0500    ERROR   [flogo.contrib.activity.error] -        Execution failed for Activity[ThrowError] in Flow[asdasd] - dadsasdasdasdasd
github.com/project-flogo/flow/instance.(*TaskInst).EvalActivity.func1
        /Users/xli/gopath/src/github.com/project-flogo/flow/instance/taskinst.go:302
github.com/project-flogo/flow/instance.(*TaskInst).EvalActivity
        /Users/xli/gopath/src/github.com/project-flogo/flow/instance/taskinst.go:357
github.com/project-flogo/flow/model/simple.evalActivity
        /Users/xli/gopath/src/github.com/project-flogo/flow/model/simple/taskbehavior.go:116
github.com/project-flogo/flow/model/simple.(*TaskBehavior).Eval
        /Users/xli/gopath/src/github.com/project-flogo/flow/model/simple/taskbehavior.go:95
github.com/project-flogo/flow/instance.(*IndependentInstance).execTask
        /Users/xli/gopath/src/github.com/project-flogo/flow/instance/ind_instance.go:277
github.com/project-flogo/flow/instance.(*IndependentInstance).DoStep
        /Users/xli/gopath/src/github.com/project-flogo/flow/instance/ind_instance.go:219
github.com/project-flogo/flow.(*FlowAction).Run.func1
        /Users/xli/gopath/src/github.com/project-flogo/flow/action.go:330
2021-03-25T10:01:46.492-0500    ERROR   [flogo.flow] -  Error evaluating activity 'ThrowError'[github.com/project-flogo/contrib/activity/error] - dadsasdasdasdasd
github.com/project-flogo/flow/model/simple.(*TaskBehavior).Eval
        /Users/xli/gopath/src/github.com/project-flogo/flow/model/simple/taskbehavior.go:99
github.com/project-flogo/flow/instance.(*IndependentInstance).execTask
        /Users/xli/gopath/src/github.com/project-flogo/flow/instance/ind_instance.go:277
github.com/project-flogo/flow/instance.(*IndependentInstance).DoStep
        /Users/xli/gopath/src/github.com/project-flogo/flow/instance/ind_instance.go:219
github.com/project-flogo/flow.(*FlowAction).Run.func1
        /Users/xli/gopath/src/github.com/project-flogo/flow/action.go:330
2021-03-25T10:01:46.492-0500    DEBUG   [flogo.flow] -  SetAttr - name: _E, value:map[activity:ThrowError code: data:<nil> message:dadsasdasdasdasd type:activity]

2021-03-25T10:01:46.492-0500    DEBUG   [flogo.flow] -  SetAttr - name: _E.ThrowError, value:map[activity:ThrowError code: data:<nil> message:dadsasdasdasdasd type:activity]

2021-03-25T10:01:46.492-0500    ERROR   [flogo.flow] -  dadsasdasdasdasd
github.com/project-flogo/flow/instance.(*IndependentInstance).HandleGlobalError
        /Users/xli/gopath/src/github.com/project-flogo/flow/instance/ind_instance.go:535
github.com/project-flogo/flow/instance.(*IndependentInstance).handleTaskError
        /Users/xli/gopath/src/github.com/project-flogo/flow/instance/ind_instance.go:498
github.com/project-flogo/flow/instance.(*IndependentInstance).execTask
        /Users/xli/gopath/src/github.com/project-flogo/flow/instance/ind_instance.go:282
github.com/project-flogo/flow/instance.(*IndependentInstance).DoStep
        /Users/xli/gopath/src/github.com/project-flogo/flow/instance/ind_instance.go:219
github.com/project-flogo/flow.(*FlowAction).Run.func1
        /Users/xli/gopath/src/github.com/project-flogo/flow/action.go:330

What is the new behavior?

Only Print stacktrace at DEBUG or Trace level.

2021-03-25T10:22:24.892-0500    INFO    [flogo.general.activity.log] -  www===============
2021-03-25T10:22:24.892-0500    INFO    [flogo.general.activity.log] -  Eval activity [LogMessage] on instance [7bc7c5c3e2731676e1bc86d5a1ad37b0] done, took: 22.625µs
2021-03-25T10:22:24.892-0500    INFO    [flogo.contrib.activity.error] -        Eval activity [ThrowError] on instance [7bc7c5c3e2731676e1bc86d5a1ad37b0] done, took: 2.782µs
2021-03-25T10:22:24.892-0500    ERROR   [flogo.contrib.activity.error] -        Execution failed for Activity[ThrowError] in Flow[asdasd] - dadsasdasdasdasd
2021-03-25T10:22:24.893-0500    ERROR   [flogo.flow] -  Error evaluating activity 'ThrowError'[github.com/project-flogo/contrib/activity/error] - dadsasdasdasdasd
2021-03-25T10:22:24.893-0500    ERROR   [flogo.flow] -  dadsasdasdasdasd
2021-03-25T10:22:24.893-0500    INFO    [flogo.flow] -  Instance [7bc7c5c3e2731676e1bc86d5a1ad37b0] with event id [f9eeae74255a92ff4bc9cb6d4549291a] Failed, took:2.002988491s