-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from kostiakoval/0.2.0
0.2.0
- Loading branch information
Showing
19 changed files
with
395 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions
27
Example/MyPlayground.playground/Pages/Readme.xcplaygroundpage/Contents.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//: [Previous](@previous) | ||
|
||
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 |
6 changes: 6 additions & 0 deletions
6
Example/MyPlayground.playground/Pages/Readme.xcplaygroundpage/timeline.xctimeline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Timeline | ||
version = "3.0"> | ||
<TimelineItems> | ||
</TimelineItems> | ||
</Timeline> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<playground version='5.0' target-platform='ios'> | ||
<timeline fileName='timeline.xctimeline'/> | ||
<playground version='6.0' target-platform='ios'> | ||
<pages> | ||
<page name='Playground'/> | ||
<page name='Readme'/> | ||
</pages> | ||
</playground> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// Colors.swift | ||
// SpeedLog | ||
// | ||
// Created by Kostiantyn Koval on 23/11/15. | ||
// Copyright © 2015 Kostiantyn Koval. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
/// RGBColorType representation | ||
protocol RGBColorType { | ||
|
||
/// Return RGB color represenation. | ||
/// Example R: 200, G: 125, G: 255 | ||
var colorCode: String { get } | ||
} | ||
|
||
struct ColorLog { | ||
struct Key { | ||
private static let Escape = "\u{001b}[" | ||
private static let Fg = "fg" | ||
static let Bg = "bg" | ||
|
||
static let StartFg = "\(Escape)\(Fg)" | ||
static let StartBg = "\(Escape)\(Bg)" | ||
|
||
static let ResetFG = Escape + "fg;" // Clear any foreground color | ||
static let ResetBG = Escape + "bg;" // Clear any background color | ||
static let Reset = Escape + ";" // Clear any foreground or background color | ||
} | ||
|
||
/// String with a Font color | ||
static func font<T>(color: RGBColorType, object: T) -> String { | ||
return "\(Key.StartFg)\(color.colorCode);\(object)\(Key.Reset)" | ||
} | ||
|
||
/// String with a Background color | ||
static func background<T>(color: RGBColorType, object: T) -> String { | ||
return "\(Key.StartBg)\(color.colorCode);\(object)\(Key.Reset)" | ||
} | ||
|
||
/// String with both Background and Font color | ||
static func colored<T>(font: RGBColorType, background: RGBColorType, object: T) -> String { | ||
let string = | ||
"\(Key.Escape)fg\(font.colorCode);" + | ||
"\(Key.Escape)bg\(background.colorCode);" + | ||
"\(object)\(Key.Reset)" | ||
|
||
return string | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// Swizzling.swift | ||
// SpeedLog | ||
// | ||
// Created by Kostiantyn Koval on 24/11/15. | ||
// Copyright © 2015 Kostiantyn Koval. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
extension NSObject { | ||
|
||
class func swizzleMethods(origSelector: Selector, withSelector: Selector, forClass: AnyClass) { | ||
let originalMethod = class_getInstanceMethod(forClass, origSelector) | ||
let swizzledMethod = class_getInstanceMethod(forClass, withSelector) | ||
|
||
method_exchangeImplementations(originalMethod, swizzledMethod) | ||
} | ||
|
||
func swizzleMethods(origSelector: Selector, withSelector: Selector) { | ||
let aClass: AnyClass! = object_getClass(self) | ||
NSObject.swizzleMethods(origSelector, withSelector: withSelector, forClass: aClass) | ||
} | ||
} |
Oops, something went wrong.