@@ -39,9 +39,9 @@ var errTraceSyntax = errors.New("expect file.go:234")
3939type GlogHandler struct {
4040 origin Handler // The origin handler this wraps
4141
42- level uint32 // Current log level, atomically accessible
43- override uint32 // Flag whether overrides are used, atomically accessible
44- backtrace uint32 // Flag whether backtrace location is set
42+ level atomic. Uint32 // Current log level, atomically accessible
43+ override atomic. Bool // Flag whether overrides are used, atomically accessible
44+ backtrace atomic. Bool // Flag whether backtrace location is set
4545
4646 patterns []pattern // Current list of patterns to override with
4747 siteCache map [uintptr ]Lvl // Cache of callsite pattern evaluations
@@ -72,7 +72,7 @@ type pattern struct {
7272// Verbosity sets the glog verbosity ceiling. The verbosity of individual packages
7373// and source files can be raised using Vmodule.
7474func (h * GlogHandler ) Verbosity (level Lvl ) {
75- atomic . StoreUint32 ( & h .level , uint32 (level ))
75+ h .level . Store ( uint32 (level ))
7676}
7777
7878// Vmodule sets the glog verbosity pattern.
@@ -138,7 +138,7 @@ func (h *GlogHandler) Vmodule(ruleset string) error {
138138
139139 h .patterns = filter
140140 h .siteCache = make (map [uintptr ]Lvl )
141- atomic . StoreUint32 ( & h .override , uint32 (len (filter )) )
141+ h .override . Store (len (filter ) != 0 )
142142
143143 return nil
144144}
@@ -171,7 +171,7 @@ func (h *GlogHandler) BacktraceAt(location string) error {
171171 defer h .lock .Unlock ()
172172
173173 h .location = location
174- atomic . StoreUint32 ( & h .backtrace , uint32 (len (location )) )
174+ h .backtrace . Store (len (location ) > 0 )
175175
176176 return nil
177177}
@@ -180,7 +180,7 @@ func (h *GlogHandler) BacktraceAt(location string) error {
180180// and backtrace filters, finally emitting it if either allow it through.
181181func (h * GlogHandler ) Log (r * Record ) error {
182182 // If backtracing is requested, check whether this is the callsite
183- if atomic . LoadUint32 ( & h .backtrace ) > 0 {
183+ if h .backtrace . Load () {
184184 // Everything below here is slow. Although we could cache the call sites the
185185 // same way as for vmodule, backtracing is so rare it's not worth the extra
186186 // complexity.
@@ -198,11 +198,11 @@ func (h *GlogHandler) Log(r *Record) error {
198198 }
199199 }
200200 // If the global log level allows, fast track logging
201- if atomic . LoadUint32 ( & h .level ) >= uint32 (r .Lvl ) {
201+ if h .level . Load ( ) >= uint32 (r .Lvl ) {
202202 return h .origin .Log (r )
203203 }
204204 // If no local overrides are present, fast track skipping
205- if atomic . LoadUint32 ( & h .override ) == 0 {
205+ if ! h .override . Load () {
206206 return nil
207207 }
208208 // Check callsite cache for previously calculated log levels
0 commit comments