Skip to content

log: use atomic types#27763

Merged
fjl merged 4 commits intoethereum:masterfrom
ucwong:at-log
Aug 4, 2023
Merged

log: use atomic types#27763
fjl merged 4 commits intoethereum:masterfrom
ucwong:at-log

Conversation

@ucwong
Copy link
Copy Markdown
Contributor

@ucwong ucwong commented Jul 24, 2023

No description provided.

Copy link
Copy Markdown
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@holiman holiman changed the title log: atomic types used in log log: use atomic types Jul 27, 2023
Comment thread log/format.go Outdated
// locationEnabled is an atomic flag controlling whether the terminal formatter
// should append the log locations too when printing entries.
var locationEnabled uint32
var locationEnabled atomic.Uint32
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an atomic.Bool, really. It's a small enough change that we might just as well fix it in this PR while we're at it, IMO,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done

Comment thread log/handler_glog.go Outdated
override uint32 // Flag whether overrides are used, atomically accessible
backtrace uint32 // Flag whether backtrace location is set
level atomic.Uint32 // Current log level, atomically accessible
override atomic.Uint32 // Flag whether overrides are used, atomically accessible
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also be a boolean. Instead of setting it to len(filter), we would set it to len(filter) != 0

Comment thread log/handler_glog.go Outdated
}
// If no local overrides are present, fast track skipping
if atomic.LoadUint32(&h.override) == 0 {
if h.override.Load() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to be either
h.override.Store(len(filter) != 0) and check if !h.override.Load() {
or
h.override.Store(len(filter) == 0) and check if h.override.Load() {

Comment thread log/handler_glog.go Outdated
backtrace uint32 // Flag whether backtrace location is set
level atomic.Uint32 // Current log level, atomically accessible
override atomic.Bool // Flag whether overrides are used, atomically accessible
backtrace atomic.Uint32 // Flag whether backtrace location is set
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, backtrace also looks very boolean, in it's usage, to me :)

@ucwong ucwong force-pushed the at-log branch 2 times, most recently from e0b71c0 to 0d9e6fd Compare August 1, 2023 13:36
Copy link
Copy Markdown
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fjl fjl merged commit 5c30541 into ethereum:master Aug 4, 2023
@fjl fjl added this to the 1.12.1 milestone Aug 4, 2023
devopsbo3 pushed a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
Co-authored-by: Felix Lange <fjl@twurst.com>
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Nov 15, 2024
Co-authored-by: Felix Lange <fjl@twurst.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants