Latest 1.0.1
Homepage https://github.com/leoneparise/BackLogger
License MIT
Platforms ios 8.2
Authors

Background Log Manager

Did you like background log manager? Give a ⭐️

Carthage compatible

How it works

How it works

BackLogger is a simple log manager that uses a superfast SqlLite database to store your logs.

  • [x] Four types of log: debug, info, warn, error
  • [x] Log file, function, line
  • [x] Swift 3.0
  • [x] Really Fast!
  • [x] Nice log viewer interface
  • [x] Log drivers: Console and Sql drivers included. You can write your own driver if you need
  • [x] Highly customizable
  • [x] Well documented
  • [x] and more…

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate BackLogger into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'BackLogger'

Then, run the following command:

$ pod install

If you want to use our log viewer add this line to your Podfile:

pod 'BackLogger/UI'

Backlogger UI requires minimum iOS 9.

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate SideMenu into your Xcode project using Carthage, specify it in your Cartfile:

github "leoneparise/backlogger" "master"

Usage

Backlogger provides 4 log functions:

debug(message:String)
info(message:String)
warn(message:String)
error(message:String)

Under the hood, these functions uses LogManager shared instance to log your data. LogManager is the Backlogger’s main class and has the following signature:

public class LogManager {
  /// Callback used to receive a log event. This function is called when ANY LogManager saves a log.
  public var didLog: DidLogCallback?

  /// Drivers
  public var drivers: [LogDriver]

  /// Main driver is always the first driver in drivers attribute.
  public var mainDriver: LogDriver?

  /// Share instance. Can be customized to meed your needs
  public static var shared: LogManager

  /// Get all logs. Depends if the mainDriver provides this feature
  public func all(byType type: LogType? = nil, offset: Int = 0) -> [LogEntry]?

  /// Log into all drivers
  public func log(file: String = #file, line: UInt = #line, function: String = #function, type: LogType = .debug, message: String)  
}

To disable the log database in prodution, put this code in your application(_:didFinishLaunchWithOptions:) method:

if let sqlLogDriver = SqlLogDriver(), let consoleLogDriver = ConsoleLogDriver() {
    #if DEBUG
        LogManager.shared.drivers = [sqlLogDriver, consoleLogDriver]
    #else
        LogManager.shared.drivers = [consoleLogDriver]
    #endif
}

If you want to receive log events, you can use the NotificationCenter and listen to Notification.Name.LogManagerDidLog notification. The object is the LogEntry struct used to store logs. You can achieve the same result setting the function didLog in ANY LogManager instance.

Backlogger UI

To view your logs you can use our Log Viewer view controller. Just instantiate our BackLoggerViewController and prent in your code:

self.present(BackLoggerViewController(), animated: true)

TODO

  • [x] Save to server in background
  • [x] Evict past logs
  • [x] Filter and search in Log Viewer View Controller.

Latest podspec

{
    "name": "BackLogger",
    "version": "1.0.1",
    "license": {
        "type": "MIT"
    },
    "homepage": "https://github.com/leoneparise/BackLogger",
    "authors": {
        "Tony Million": "[email protected]"
    },
    "summary": "Background Log Manager",
    "source": {
        "git": "https://github.com/leoneparise/BackLogger.git",
        "tag": "1.0.1"
    },
    "platforms": {
        "ios": "8.2"
    },
    "default_subspecs": "Core",
    "pushed_with_swift_version": "3.0",
    "subspecs": [
        {
            "name": "Core",
            "source_files": "BackLogger/*.swift",
            "dependencies": {
                "SQLite.swift": [],
                "SwiftDate": []
            },
            "frameworks": "Foundation"
        },
        {
            "name": "UI",
            "platforms": {
                "ios": "9.0"
            },
            "source_files": "BackLoggerUI/*.swift",
            "resources": [
                "BackLoggerUI/**/*.xib"
            ],
            "frameworks": "UIKit",
            "dependencies": {
                "BackLogger/Core": []
            }
        }
    ]
}

Pin It on Pinterest

Share This