-
-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Hi matrix-corporal team,
We are currently running a self-hosted Matrix server with matrix-corporal. Since our last update, we have observed a recurring WARN log message that is increasing our log file size.
Warning message: Failed to determine user's power level
Relevant Code:
getPowerLevelByRoomIdAndUserId function in corporal/connector/api.go
Issue:
From our perspective, the successful fallback to the users default power level is acceptable behavior and is not indicative of a 'failure' or any action that needs to be taken. However, our logs are filling up with the warning messages. We also can't find a setting to control the log level in order to ignore warnings.
Proposed Solutions:
- Reduce the log level of this specific message:
We recommend modifying the logger.Warn("Failed to determine user's power level") line within the getPowerLevelByRoomIdAndUserId function to logger.Info(...) or logger.Debug(...).
This would reflect that a default value was successfully applied.
Suggested code:
func (me *ApiConnector) getPowerLevelByRoomIdAndUserId(
ctx *AccessTokenContext,
roomId string,
userId string,
) (int, error) {
client, err := me.createMatrixClientForUserId(ctx, userId)
if err != nil {
return 0, err
}
var content map[string]interface{}
err = client.StateEvent(roomId, "m.room.power_levels", "", &content)
if err != nil {
return 0, err
}
jsonObj := gabs.Wrap(content)
userPowerLevel, ok := jsonObj.Search("users", userId).Data().(float64)
if !ok {
// Most likely no power level defined for the user, which means the default applies (if there is one).
logger := me.logger.WithField("roomId", roomId).WithField("userId", userId)
defaultVal, ok := jsonObj.Search("users_default").Data().(float64)
if ok {
logger.Info("User power level not explicitly defined; falling back to default.")
return int(defaultVal), nil
} else {
logger.Warn("Failed to determine user's power level and no 'users_default' found in m.room.power_levels event. Returning power level 0.")
return 0, nil
}
}
return int(userPowerLevel), nil
}
We're happy to open a pull request with the implementation if you're in agreement that this would be a good change.
- Alternatively/additionally implement configurable log levels:
Introduce a configuration variable that allows users to set the desired verbosity for matrix-corporal as a whole. This would provide the flexibility to ignore recurrent warning level messages.
Thank you for considering this request.