LoggingCategory
public final class LoggingCategory : Category
extension LoggingCategory: Resettable
extension LoggingCategory: LoggingCategoryClientBehavior
extension LoggingCategory: Logger
extension LoggingCategory: DefaultLogger
AWS Amplify writes console logs through Logger. You can use Logger in your apps for the same purpose.
-
Declaration
Swift
public let categoryType: CategoryType -
The global logLevel. Messages logged at a priority less than or equal to this value will be logged (e.g., if
logLevelis set to.info, then messages sent at.error,.warn, and.infowill be logged, but messages at.debugand.verbosewill not be logged. The global log level is also used for the default logger e.g.,Amplify.Log.debug("debug message"). Defaults to.error.Developers can override log levels per log category, as in
let viewLogger = Amplify.Logging.logger(forCategory: "views", level: .error) let networkLogger = Amplify.Logging.logger(forCategory: "network", level: .info) viewLogger.info("A view loaded") // Will not be logged networkLogger.info("A network operation started") // Will be loggedDeclaration
Swift
public var logLevel: LogLevel { get set }
-
Sets
pluginas the sole provider of functionality for this category. Note: this is different from other category behaviors, which allow multiple plugins to be used to implement functionality.The default plugin that is assigned at initialization will function without an explicit call to
configure. However, adding a plugin will cause the Logging category to requireconfigurebe invoked, and will remove the default-configured Logging plugin during configuration. The result is, during initialization and configuration, calls to any Logging APIs will be handled by the default plugin, until afterconfigureis invoked on logging, at which point calls will be handled by the plugin.Code that invokes Logging APIs should not cache references to the logger, since the underlying plugin may be disposed between calls. Instead, use the
Amplify.Logging.logger(for:)method to get a logger for the specified tag.Declaration
Swift
public func add(plugin: LoggingCategoryPlugin) throwsParameters
pluginThe Plugin to add
-
Returns the added plugin with the specified
keyproperty.Declaration
Swift
public func getPlugin(for key: PluginKey) throws -> LoggingCategoryPluginParameters
keyThe PluginKey (String) of the plugin to retrieve
Return Value
The wrapped plugin
-
Removes the current plugin if its key property matches the provided
key, and reinstalls the default plugin. If the key property of the current plugin is notkey, takes no action.Declaration
Swift
public func removePlugin(for key: PluginKey)Parameters
keyThe key used to
addthe plugin -
reset()AsynchronousDeclaration
Swift
public func reset() async -
Declaration
Swift
public var `default`: Logger { get } -
Declaration
Swift
public func logger(forCategory category: String) -> Logger -
Declaration
Swift
public func logger(forCategory category: CategoryType) -> Logger -
Declaration
Swift
public func enable() -
Declaration
Swift
public func disable() -
Declaration
Swift
public func logger(forNamespace namespace: String) -> Logger -
Declaration
Swift
public func logger(forCategory category: String, forNamespace namespace: String) -> Logger -
Logs a message at
errorlevelDeclaration
Swift
public func error(_ message: @autoclosure () -> String) -
Logs the error at
errorlevelDeclaration
Swift
public func error(error: Error) -
Logs a message at
warnlevelDeclaration
Swift
public func warn(_ message: @autoclosure () -> String) -
Logs a message at
infolevelDeclaration
Swift
public func info(_ message: @autoclosure () -> String) -
Logs a message at
debuglevelDeclaration
Swift
public func debug(_ message: @autoclosure () -> String) -
Logs a message at
verboselevelDeclaration
Swift
public func verbose(_ message: @autoclosure () -> String) -
Declaration
Swift
public static var log: Logger { get } -
Declaration
Swift
public var log: Logger { get }
View on GitHub