Swiftpack.co -  nakkht/logr as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
nakkht/logr
Dead simple logging library for iOS
.package(url: "https://github.com/nakkht/logr.git", from: "v0.10.0")

Logr

build status platforms codecov code size documentation

Simple logging library for iOS written in Swift

Features

  • ☑ Inferred log message tags
  • ☑ Swift Package Manager/Carthage/CocoaPods integration
  • ☑ Highly extensible
  • ☑ Logging to multiple targets/destination at the same time
  • ☑ Console logging out of the box via ConsoleTarget
  • ☑ File logging out of the box via FileTarget
  • ☑ Pure Swift 5
  • ☑ Optional file header for each file
  • ☑ Automatic file archive based on size or time span

Integration

Swift Package Manager

Once Swift package set up, add the following to your Package.swift:

dependencies: [
  .package(url: "https://github.com/nakkht/logr.git", exact: "0.9.0")
]

Usage

In your AppDelegate.swift file add:

import Logr

At the beginning of func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool configure logr service with wanted targets:

LogrService.init(with: Config(ConsoleTarget(), FileTarget()))

For more serious configuration in production, it is recommended to ommit ConsoleTarget. For example:

#if DEBUG
static let targets: [Target] = [ConsoleTarget(), FileTarget()]
#else
static let targets: [Target] = [FileTarget()]
#endif

static let config = Config(targets: targets)

LogrService.init(with: config)

The set targets will be used across the whole application.

To log messages, simply create Logr instance in class initializer and start logging. For example:

import Logr

class ViewController: UIViewController {

    private let logr = Logr()

    func logDebug() {
        logr.debug("debug message to be logged")
    }
}

Demo

Demo project can be access by opening Demo.workspace in Demo sub-folder.

Documentation

Author

Licence

This repository is under the Apache v2.0 license. Find it here.

Copyright 2020 Paulius Gudonis

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

GitHub

link
Stars: 2
Last commit: 3 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

v0.10.0
9 weeks ago

Removed

  • CocoaPods/Carthage support

Changed

  • Minimum iOS/tvOS version to 10

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API