Thanks to visit codestin.com
Credit goes to github.com

Skip to content

getwagit/Oak

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Oak

Oak

A simple logging library for Swift, inspired by Timber.

Installation

Carthage

Add the following to your Cartfile:

github "getwagit/Oak" ~> 2.2.0 

CocoaPods

Integrate Oak into your Podfile

pod 'Oak', '~> 2.2.0'

Usage

For simple debug usage plant the DebugTree in your AppDelegate.

Oak.plant(Oak.DebugTree())

Import Oak in each source file.

import Oak

And start logging like it's 1999.

Oak.v("Verbose Log")
Oak.d("Debug Log")
Oak.i("Info Log")
Oak.w("Warn Log")
Oak.e("Error Log")
Oak.wtf("Wtf Log")

Advanced

You can create your own trees to specify how logging should be done.

struct ProdTree: OakTree {
    func log(priority: Int, _ file: String, _ function: String, _ line: Int, _ message: String) {
        if(priority < Oak.Priority.ERROR) { // Use the priority to filter logs.
            return
        }
        async({ // Dispatch logs asynchronously using Oak's queue.
            let fileName = self.fileName(file) // Helper method to extract the file name.
            let priorityName = Oak.Priority.asString(priority) // Convert priority to a String.
            
            // ...
            // Do whatever you like with the data, e.g. send infos to a logging endpoint or prompt beta users to report the bug.
        })
    }
}

Plant trees depending on your environment: Add -DDEBUG to the debug entry at Build settings -> Swift Compiler - Custom Flags -> Other Swift Flags.

#if DEBUG
  Oak.plant(Oak.DebugTree())
#else
  Oak.plant(ProTree())
#endif

Contributing

Contributions are welcome! Please use the branch develop as base/target. If you modifiy the project.pbxproj file, use xUnique.

License

Oak is available under the MIT license.

About

A simple logging library for iOS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published