Logging Kit

LoggingKit is a framework for micro-logging based on logging service providers.

Characteristics

  • x] Identify your own magazine suppliers.
  • The combination is ready.
  • x] Comes with OSLogProvider pre-installed, which uses os_log under the hood.

Example

An example application is the best way to see the LoggingKit in action. Just open LoggingKit.xcodeproj and run the sample diagram.

After you launch the application, you should see some log messages in the Xcode terminal and in Console.app for the device on which you launched the application.

Equipment

SwiftPackage Manager

For integration with the Apple Swift package manager, add the following as a dependency on your .fast package

Search: [
.package(url: https://github.com/alexanderwe/LoggingKit.git, from: 2.0.0)
]

You can also go to the Xcode project, select Swift Packages and click the + icon to find LoggingKit.

Manual

If you prefer not to use one of the dependencies listed above, you can manually integrate the LoggingKit into your project. Drag the Source folder to the Xcode project.

Use

First of all, it makes sense to create LogCategory extensions to define your own categories.

Importing LoggingChit

Log Category Extension {
public var viewControllers : Protocol category { Return .init(viewControllers))
Public drive network : Protocol category {Back .init(Network) }

}

Then register your log providers in the application (application:didFinishLaunchingMetOptions:).

Importing LoggingChit

Class representative : UIR Respondent, UIApplication Delegate.

(_Application : UIApplication, hasFinishLaunchingWithOptions launchOptions : UIApplication.LaunchOptionsKey : [All] ? -> Bool {

LogService.register(logProvider : LogProvider, LogProvider …).

}


}

Then simply import LoggingKit into the files you want to use with the logging methods and use them accordingly.

Importing LoggingChit

LogService.shared.debug(Hello Debug, logCategory: .viewControllers)LogService.shared.verbose(Hello Verbose, logCategory: .viewControllers)LogService.shared.info(Hello Info, logCategory: .viewControllers)LogService.shared.warning(Hello Warning, logCategory: .viewControllers)LogService.shared.error(Hello Error, logCategory: .viewControllers)LogService.shared.error(Hello Error, logCategory: .viewControllers)LogService.shared.error(Hello Error, logCategory: .viewControllers)LogService.shared.error(Hello Error, logCategory: .viewControllers)LogService.shared.error)

Combination

If you use a combination, LoggingKit provides some extensions such as Publisher to register Self.Output and Self.Failure.

You can choose any category. The .combine category is defined by the user.

Importing LoggingChit

// logs ‘Self.output’
myPublisher.log value (logType: .info, logCategory: .combine) {
My value ($0)
}

// logs ‘self.failure’
myPublisher.logError(logCategory : .combine) {
My error is ($0)
}.

// records both Self.output and Self.failure
myPublisher.log().

Sellers

The idea behind this little frame is that you can expand it by writing your own recording providers according to the LogProvider protocol. These implementations can then be registered with the LogService.register (provider:) method.

An example implementation of LogProvider can be found in the ./Example/MyTestLogProvider.fast file.

Supplier OSLog

The recording kit comes with a pre-installed OSLogProvider. It uses os_log under the hood to record your messages. These messages can be displayed in Console.app of your macro and on the console in Xcode.

Console application

Open Console.app on your Mac, select the device whose log messages you want to view to see the messages printed by OSLogProvider.

Screenshot of the console

GitHub

You May Also Like

6 Best TV Tuner for PCs in 2020

Have you ever wondered how to watch TV directly on your computer?…

8 Best 4k 144hz monitors for 2020

The best way to enjoy the game is to build the best…

Allow Chrome to access the network in the Firewall or Antivirus Settings

Today, Google Chrome is the most popular browser in the world. With…

Fitness Guide for Women!

I want a daym sexy body! The world of fitness can be…