LoggingCategory

final public 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 logLevel is set to .info, then messages sent at .error, .warn, and .info will be logged, but messages at .debug and .verbose will 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 logged
    

    Declaration

    Swift

    public var logLevel: LogLevel { get set }

Plugin handling

  • Sets plugin as 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 require configure be 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 after configure is 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) throws

    Parameters

    plugin

    The Plugin to add

  • Returns the added plugin with the specified key property.

    Declaration

    Swift

    public func getPlugin(for key: PluginKey) throws -> LoggingCategoryPlugin

    Parameters

    key

    The 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 not key, takes no action.

    Declaration

    Swift

    public func removePlugin(for key: PluginKey)

    Parameters

    key

    The key used to add the plugin

  • reset() Asynchronous

    Declaration

    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 logger(forCategory category: String, logLevel: LogLevel) -> 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 error level

    Declaration

    Swift

    public func error(_ message: @autoclosure () -> String)
  • Logs the error at error level

    Declaration

    Swift

    public func error(error: Error)
  • Logs a message at warn level

    Declaration

    Swift

    public func warn(_ message: @autoclosure () -> String)
  • Logs a message at info level

    Declaration

    Swift

    public func info(_ message: @autoclosure () -> String)
  • Logs a message at debug level

    Declaration

    Swift

    public func debug(_ message: @autoclosure () -> String)
  • Logs a message at verbose level

    Declaration

    Swift

    public func verbose(_ message: @autoclosure () -> String)
  • log

    Declaration

    Swift

    public static var log: Logger { get }
  • log

    Declaration

    Swift

    public var log: Logger { get }