GithubHelp home page GithubHelp logo

asharijuang / speedlog Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kostiakoval/speedlog

0.0 2.0 0.0 122 KB

Fast Swift debug logs

License: MIT License

Swift 88.99% Objective-C 3.23% Ruby 7.78%

speedlog's Introduction

SpeedLog - ๐Ÿš€๐ŸŒ

CI Status Version Carthage compatible License Platform

SpeedLog - Fast Debug logging, easy to disable and improve Swift performance optimization

The Swift print statements aren't emitted when compiling in Release mode with enabled optimization. This prevents Swift from performing optimal code optimization.

The SpeedLog allows you to remove print when the logs are disabled. This allows Swift compiler to perform optimal code optimization and increase application performance.

Features

  • Improves Swift code optimization
  • Easy to disable
  • Reach formatting
  • Coloured console output
  • Custom UIColor representation

Usage

import SpeedLog
SpeedLog.print("Hello")
SpeedLog.print(["Super"], ["Speed"])

Log output Styling

SpeedLog.mode = .FuncName
SpeedLog.print("Show only FunctionName")
//myFunc(): Show only FunctionName

SpeedLog.mode = [.FuncName, .FileName]
SpeedLog.print("Show FunctionName and File name")
//AppDelegate.myFunc(): Show FunctionName and File name

SpeedLog.mode = [.FuncName, .FileName, .Line]
SpeedLog.print("Show 3 options :)")
//AppDelegate.myFunc()[36]: Show 3 options :)

SpeedLog.mode = .FullCodeLocation
SpeedLog.print("Show fullCode, same as above")
//AppDelegate.myFunc()[39]: Show fullCode, same as above

SpeedLog.mode = .AllOptions
SpeedLog.print("Enable All Features")
//2015-11-26 19:32:33.687 AppDelegate.myFunc()[27]: Enable All Features

UIColor log

SpeedLog has nice UIColor log style.
All you need to do is enable it once by calling SpeedLog.enableVisualColorLog()

SpeedLog.enableVisualColorLog()
SpeedLog.print("Visual:", c)

SpeedLog.disableVisualColorLog()
SpeedLog.print("Original Restored:", c)

P.S - You also need to install XcodeColors Xcode Plugin. Use Alcatraz to install it.

###Enables Log

To enables logs you need to add a Swift Compiler ENABLE_LOG flag

  1. Go to: Build Settings -> Swift Compiler - Custom Flags
  2. Add -D ENABLE_LOG flag

If you use use CocoaPods or Carthage you need to enable it for SpeedLog framework, not the project itself.

See more details at Stackoverflow

Installation

###CocoaPods

To install it, simply add the following line to your Podfile:

use_frameworks!
pod "SpeedLog"

###Carthage

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

github "kostiakoval/SpeedLog"

* Carthage builds frameworks in Release mode. This mean if you run carthage update and include SpeedLog.framework to the project no output will be printed to console, because it's not printed in release mode.

How to use Carthage with SpeedLog:

  • Runcarthage checkout
  • Open Carthage/Checkouts/SpeedLog and add SpeedLog.xcodeproj to your project.

Manual

Copy the SpeedLog.swift file into your project

Colors

In order to use colorised console you need to install XcodeColors Xcode plugin.
Use Alcatraz to install it. Go to:
Xcode -> Window -> Package Manager -> Search for XcodeColors and install it

Future Features

There are many logging libs I like:

But there is one problem with all of them - it's not possible to disable them before compiling Swift code.

Next step is:
Get the best features from those libs and integrate them into SpeedLog

To Do:

  • Different log levels (debug, info, verbose, etc)
  • Log to a file
  • Lazy code evaluation (@autoclosure) for log

Contribute

Please open an issue with bugs and missing features, functionality or ideas for improvements.
Also you can contribute by following these guidelines:

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create pull request

Author

Kostiantyn Koval, thats me :)

Thanks to Arthur Ariel Sabintsev for his PrintlnMagic lib

License

SpeedLog is available under the MIT license. See the LICENSE file for more info.

speedlog's People

Contributors

kostiakoval avatar phimage avatar coutar-t avatar calvinchengx avatar

Watchers

James Cloos avatar Ashari Juang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.