TriforkSwiftLogger

1.1.0

trifork/TriforkSwiftLogger

What's New

1.1.0

2020-12-10T09:06:28Z

💥 This update contains breaking changes!

  • TriforkSwiftLogger was renamed to OSLogger
  • AsyncLoggerProtocol was removed. This behaviour can be implemented in your own logger implementation if needed.
  • OSLogType parameter was replaced with LogLevel in the Logger interface. OSLogger uses a mapping between the two types.

TriforkSwiftLogger

Motivation

TriforkSwiftLogger is a lightweight logging framework which defines a set of protocols and provides the ability to log with multiple loggers. The framework itself contains a OSLogger which can be used out of the box to log through Apple's os.log module. The logger protocols uses a defined set of logging levels to control logs for different configurations.

Installation ⬇️

Add https://github.com/trifork/TriforkSwiftLogger.git to your Xcode project file and start using OSLogger

Configuration

You can customize the default configuration for the logger by setting the config parameter. You can also mutate the default config by setting a single parameter on the OSLoggerConfig object.

MultiLogger

You can implement multiple LoggerProtocol classes and initialize a MultiLogger with multiple logger. The MultiLogger will invoke all loggers when logging.

NOTE: The MultiLogger does not have any configurations. It is up to the LoggerProtocol implementation to handle the behaviour of the different logging functions.

Log

let logger = OSLogger()
logger.debug("Hello!", category: "my-custom-category")
logger.default("Hello!")
logger.info("Hello!")
logger.error("Hello!")
logger.fault("Hello!")

let multiLogger = MultiLogger(loggers: [OSLogger(), MyCustomLogger()])
multiLogger.info("Hello!", category: "my-custom-category") // the info-function will be invoked for both OSLogger and MyCustomLogger.

TRIFORK

Description

  • Swift Tools 5.2.0
View More Packages from this Author

Dependencies

  • None
Last updated: Mon Oct 21 2024 14:08:22 GMT-0900 (Hawaii-Aleutian Daylight Time)