Skip to content

Commit

Permalink
compilation flag for enable-logging-during-decode
Browse files Browse the repository at this point in the history
  • Loading branch information
MahdiBM committed Feb 28, 2023
1 parent f436931 commit 2351524
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Sources/DiscordModels/+DiscordGlobalConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ extension DiscordGlobalConfiguration {
/// For example if a type can't find a representation to decode a value to,
/// and has to get rid of that value.
/// Does not include decode errors.
public static var enableLoggingDuringDecode = false

/// This is supposed to be only used by the library author. Enabling this flag is discouraged.
static func makeDecodeLogger(_ label: String) -> Logger {
if enableLoggingDuringDecode {
#if DISCORDBM_ENABLE_LOGGING_DURING_DECODE
var logger = DiscordGlobalConfiguration.makeLogger(label)
logger[metadataKey: "explanation"] = "Please report this on https://github.com/MahdiBM/DiscordBM/issues if there are no similar issues, so we can keep DiscordBM up to date for the community. You can disable these logs by using 'DiscordGlobalConfiguration.enableLoggingDuringDecode = false'"
logger[metadataKey: "tag"] = "decode-logger"
return logger
} else {
#else
return Logger(label: label, factory: SwiftLogNoOpLogHandler.init)
}
#endif
}
}

0 comments on commit 2351524

Please sign in to comment.