-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unify logging content style #293
Conversation
a8bd638
to
f6a4123
Compare
Codecov Report
@@ Coverage Diff @@
## master #293 +/- ##
==========================================
- Coverage 51.52% 51.49% -0.03%
==========================================
Files 81 81
Lines 4101 4107 +6
==========================================
+ Hits 2113 2115 +2
- Misses 1701 1706 +5
+ Partials 287 286 -1
Continue to review full report at Codecov.
|
return nil | ||
} | ||
counter, ok := mb.(*slowRequestCounter) | ||
if !ok { | ||
logging.Error(errors.New("Bucket data type error"), "") | ||
logging.Error(errors.New("bucket data type error"), "Bucket data type error in slowRequestLeapArray.currentCounter()") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might need to indicate "type assert failed, expect *slowRequestCounter"
continue | ||
} | ||
counter, ok := mb.(*slowRequestCounter) | ||
if !ok { | ||
logging.Error(errors.New("Bucket data type error"), "") | ||
logging.Error(errors.New("bucket data type error"), "Bucket data type error in slowRequestLeapArray.allCounter()") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with upon
return nil | ||
} | ||
counter, ok := mb.(*errorCounter) | ||
if !ok { | ||
logging.Error(errors.New("Bucket data type error"), "") | ||
logging.Error(errors.New("bucket data type error"), "Bucket data type error in errorCounterLeapArray.currentCounter()") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with upon
continue | ||
} | ||
counter, ok := mb.(*errorCounter) | ||
if !ok { | ||
logging.Error(errors.New("Bucket data type error"), "") | ||
logging.Error(errors.New("bucket data type error"), "Bucket data type error in errorCounterLeapArray.allCounter()") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with upon
core/config/config.go
Outdated
@@ -90,7 +90,7 @@ func loadFromYamlFile(filePath string) error { | |||
if err != nil { | |||
return err | |||
} | |||
logging.Info("Resolving Sentinel config from file", "file", filePath) | |||
logging.Info("[Config] Resolving sentinel config from file", "file", filePath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep "Sentinel", it's a brand.
core/stat/base/bucket_leap_array.go
Outdated
continue | ||
} | ||
b, ok := mb.(*MetricBucket) | ||
if !ok { | ||
logging.Error(errors.New("fail to type assert, expect MetricBucket"), "fail to get current MetricBucket") | ||
logging.Error(errors.New("fail to type assert, expect MetricBucket"), "Fail to get current MetricBucket in BucketLeapArray.CountWithTime()") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: "expect *MetricBucket"
core/stat/base/bucket_leap_array.go
Outdated
return | ||
} | ||
b, ok := mb.(*MetricBucket) | ||
if !ok { | ||
logging.Error(errors.New("fail to type assert, expect MetricBucket"), "Failed to add count: bucket data type error") | ||
logging.Error(errors.New("fail to type assert, expect MetricBucket"), "Bucket data type error in BucketLeapArray.addCountWithTime()") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo "expect *MetricBucket"
core/stat/base/bucket_leap_array.go
Outdated
continue | ||
} | ||
b, ok := mb.(*MetricBucket) | ||
if !ok { | ||
logging.Error(errors.New("fail to type assert, expect MetricBucket"), "fail to get current MetricBucket") | ||
logging.Error(errors.New("fail to type assert, expect MetricBucket"), "Fail to get current MetricBucket in BucketLeapArray.MinRt()") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo "expect *MetricBucket"
continue | ||
} | ||
counter, ok := mb.(*MetricBucket) | ||
if !ok { | ||
logging.Error(errors.New("type assert failed"), "Fail to do type assert, expect: MetricBucket", "type", reflect.TypeOf(mb).Name()) | ||
logging.Error(errors.New("type assert failed"), "Fail to do type assert, expect: MetricBucket in SlidingWindowMetric.GetMaxOfSingleBucket()", "type", reflect.TypeOf(mb).Name()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo "expect *MetricBucket"
continue | ||
} | ||
counter, ok := mb.(*MetricBucket) | ||
if !ok { | ||
logging.Error(errors.New("type assert failed"), "Fail to do type assert, expect: MetricBucket", "type", reflect.TypeOf(mb).Name()) | ||
logging.Error(errors.New("type assert failed"), "Fail to do type assert, expect: MetricBucket in SlidingWindowMetric.MinRT()", "type", reflect.TypeOf(mb).Name()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo "expect *MetricBucket"
return nil | ||
} | ||
mb, ok := mi.(*MetricBucket) | ||
if !ok { | ||
logging.Error(errors.New("type assert failed"), "Fail to do type assert, expect: MetricBucket", "bucketStartTime", w.BucketStart, "type", reflect.TypeOf(mb).Name()) | ||
logging.Error(errors.New("type assert failed"), "Fail to do type assert, expect: MetricBucket in SlidingWindowMetric.metricItemFromBuckets()", "bucketStartTime", w.BucketStart, "type", reflect.TypeOf(mb).Name()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo "expect *MetricBucket"
return nil | ||
} | ||
mb, ok := mi.(*MetricBucket) | ||
if !ok { | ||
logging.Error(errors.New("type assert failed"), "Fail to do type assert, expect: MetricBucket", "type", reflect.TypeOf(mb).Name()) | ||
logging.Error(errors.New("type assert failed"), "Fail to do type assert, expect: MetricBucket in SlidingWindowMetric.metricItemFromBucket()", "type", reflect.TypeOf(mb).Name()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo "expect *MetricBucket"
@@ -41,12 +40,12 @@ func main() { | |||
go func() { | |||
node := stat.GetOrCreateResourceNode("abc", base.ResTypeCommon) | |||
for { | |||
logging.Info(fmt.Sprintf("current concurrency:%d", node.CurrentConcurrency())) | |||
logging.Info("[HotSpot Concurrency] Current concurrency", "current concurrency", node.CurrentConcurrency()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
key shouldn't contain blank, might: "currentConcurrency"?
f6a4123
to
fce4d44
Compare
fce4d44
to
54fcf7b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work
Describe what this PR does / why we need it
unify logging content style
Does this pull request fix one issue?
Fixes:#280
Describe how you did it
对项目中的四种日志类型统一风格,统一的标准如下:
Error:
例如:logging.Error(errors.New("bucket data type error"), "Bucket data type error in errorCounterLeapArray.allCounter()","param","paramValue")
Info:
例如:logging.Info("[Config] Print effective global config", "globalConfig", *globalCfg)
Warn:
例如:logging.Warn("[HotSpot onRuleUpdate] Ignoring the frequent param flow rule due to unsupported control behavior", "rule", r)
Debug:
例如:logging.Debug("[HotSpot onRuleUpdate] Ignoring the frequent param flow rule due to bad generated traffic controller", "rule", r)
Describe how to verify it
Special notes for reviews