Swiftpack.co - Package - e-sites/Lithium

Lithium

Lithium is part of the E-sites iOS Suite.


The E-sites logging framework.

forthebadge forthebadge

Platform CocoaPods Compatible Travis-ci Carthage compatible

Installation

CocoaPods

Podfile:

pod 'Lithium'

And then

pod install

Carthage

Cartfile:

github "e-sites/Lithium"

And then

carthage update

Implementation

Initialization

import Lithium
let logger = Lithium.Logger()

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    logger.theme = EmojiLogTheme()
    // logger.theme = NoColorsLogTheme() // If you don't have the XcodeColors plugin installed
    #if !DEBUG
    logger.enabled = false
    #endif
    
    // ... The rest of the launch stuff
    
    return true
}

Logging

public func error(_ items:Any...)
public func warning(_ items:Any...,)    
public func exe(_ items:Any...)    
public func debug(_ items:Any...)    
public func info(_ items:Any...)    
public func success(_ items:Any...)    
public func verbose(_ items:Any...)
public func log(_ items:Any...)    
public func colorLog(_ foregroundColor: String, backgroundColor:String?=nil, _ items:Any...)
public func request(_ method: String, _ url:String, _ parameters:String?=nil)
public func response(_ method: String, _ url:String, _ parameters:String?=nil)

public func table<O>(object:O, shouldPrint:Bool=true)
public func table<O>(object: O, shouldPrint:Bool=true)
public func table<V>(array: [V], shouldPrint:Bool=true)
public func table<V>(dictionary: [String: V], title: String, shouldPrint: Bool)

Crashlytics

You can also automatically log to crashlytics:

Fabric.with([Crashlytics.self])

logger.logProxy = { _, _, message, _ in
    CLSLogv("%@", getVaList([ message ]))
}