MG-2059 - Set correct log level depending on error#2196
MG-2059 - Set correct log level depending on error#2196nyagamunene wants to merge 20 commits intoabsmach:mainfrom
Conversation
533c151 to
a596fd9
Compare
arvindh123
left a comment
There was a problem hiding this comment.
Please check the following files, I found some error are logged as Warn :
auth/api/logging.go L30 to L128 https://github.com/nyagamunene/magistrala/blob/a596fd9abbf62be732b9185855def1f492f3baeb/auth/api/logging.go#L37-L129
bootstrap/api/logging.go
bootstrap/postgres/configs.go
certs/api/logging.go
cmd/opcua/main.go
coap/api/transport.go
consumers/notifiers/api/logging.go
consumers/writers/api/logging.go
internal/groups/api/logging.go
consumers/writers/api/logging.go
internal/groups/api/logging.go
lora/api/logging.go
invitations/middleware/logging.go
opcua/api/logging.go
pkg/events/redis/subscriber.go
things/api/logging.go
twins/api/logging.go
users/api/logging.go
ws/api/endpoints.go
rodneyosodo
left a comment
There was a problem hiding this comment.
Some errors should be logged with Warn while others should be logged with Error. This is a simple explanation of how to do it https://stackoverflow.com/a/2031195 . Also, consider using ErrorContext and pass in the context rather than Error
95f66c4 to
7022dd0
Compare
7022dd0 to
a8be062
Compare
auth/api/logging.go
Outdated
| if err != nil { | ||
| args = append(args, slog.Any("error", err)) | ||
| lm.logger.Warn("List objects failed to complete successfully", args...) | ||
| lm.logger.ErrorContext(ctx, "List objects failed to complete successfully", args...) |
There was a problem hiding this comment.
Revert all errors to WarnContext
ws/api/endpoints.go
Outdated
| conn, err := upgrader.Upgrade(w, r, nil) | ||
| if err != nil { | ||
| logger.Warn(fmt.Sprintf("Failed to upgrade connection to websocket: %s", err.Error())) | ||
| logger.Error(fmt.Sprintf("Failed to upgrade connection to websocket: %s", err.Error())) |
ws/api/endpoints.go
Outdated
| channelParts := channelPartRegExp.FindStringSubmatch(r.RequestURI) | ||
| if len(channelParts) < 2 { | ||
| logger.Warn("Empty channel id or malformed url") | ||
| logger.Error("Empty channel id or malformed url") |
a8be062 to
bdcbd75
Compare
bdcbd75 to
567b80a
Compare
8fb868f to
ac0a377
Compare
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
7911b5b to
363c11d
Compare
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
What type of PR is this?
This is a refactor because it sets correct log level depending on error.
What does this do?
It fixes the correct log level for the logs. Currently all log are warnings.
Which issue(s) does this PR fix/relate to?
Have you included tests for your changes?
No.
Did you document any new/modified feature?
No.
Notes