Skip to content

Conversation

@C-Pro
Copy link
Contributor

@C-Pro C-Pro commented Jun 30, 2025

I noticed a significant CPU time spent in traceInPush even though my log level is LogLevelNone.

The core issue is that log level constants are not ordered in a consistent way (neither high to low, nor low to high):

LogLevelNone LogLevel = iota	// 0 - is no logging
LogLevelTrace			// 1 - max verbosity
LogLevelDebug			// 2 - high verbosity

Because of this, check level >= c.config.LogLevel does not work as expected in logLevelEnabled and for clients with LogLevel not specified (zero value is LogLevelNone) logLevelEnabled always returns true.
Fixing the order of constants would be a proper fix, but can possibly break some users code depending on numerical values.
Instead I add explicit check for LogLevelNone in logLevelEnabled. This should be backwards compatible, unless users actually expect LogLevelNone to be equal to LogLevelTrace.

@FZambia
Copy link
Member

FZambia commented Jun 30, 2025

Oh, unfortunate... Thanks a lot!

@FZambia FZambia merged commit e0ccf72 into centrifugal:master Jun 30, 2025
3 checks passed
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.

2 participants