Skip to content

Commit

Permalink
AuthLoggable: added error code in metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
e-kononenko committed Nov 11, 2024
1 parent 3308fa3 commit e84458e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Sources/Auth/Model/AuthLoggable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ extension AuthLoggable {
static var enableLogging: Bool = false
private static let metadataErrorKey = "error"
private static let metadataReasonKey = "reason"
private static let metadataErrorCodeKey = "code"
private static let metadataPreviousSubstatusKey = "previous_substatus"

var loggingMessage: Logger.Message {
Expand Down Expand Up @@ -80,6 +81,8 @@ extension AuthLoggable {
default:
return [:]
}

metadata[Self.metadataErrorCodeKey] = .string(errorCode)

return metadata
}
Expand All @@ -96,4 +99,35 @@ extension AuthLoggable {
var source: String? {
"Auth"
}

private var errorCode: String {
let intCode = switch self {
case .initializeDeviceLoginNetworkError:
1
case .finalizeLoginNetworkError:
2
case .finalizeDeviceLoginNetworkError:
3
case .finalizeDevicePollingLimitReached:
4
case .getCredentialsUpgradeTokenNetworkError:
5
case .getCredentialsScopeIsNotGranted:
6
case .getCredentialsClientUniqueKeyIsDifferent:
7
case .getCredentialsUpgradeTokenNoTokenInResponse:
8
case .getCredentialsRefreshTokenNetworkError:
9
case .getCredentialsRefreshTokenWithClientCredentialsNetworkError:
10
case .authLogout:
11
case .getCredentialsRefreshTokenIsNotAvailable:
12
}

return intCode.description
}
}

0 comments on commit e84458e

Please sign in to comment.