-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/Swift' into develop
- Loading branch information
Showing
17 changed files
with
234 additions
and
62 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -94,6 +94,6 @@ -(void) writeText:(char *) text { | |
printf("%s\n", text); | ||
} | ||
|
||
NS_ASSUME_NONNULL_END | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
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
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,22 @@ | ||
// | ||
// StoryTellerWrapper.swift | ||
// StoryTeller | ||
// | ||
// Created by Derek Clarkson on 17/10/16. | ||
// Copyright © 2016 Derek Clarkson. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public func STLog(_ key:AnyObject, file:String = #file, method:String = #function, line:Int32 = #line, _ messageTemplate:String, _ args:CVarArg...) { | ||
withVaList(args) { | ||
STStoryTeller.instance().record(key, file: file, method: method, lineNumber:line, message: messageTemplate, args: $0) | ||
} | ||
} | ||
|
||
public func STStartScope(_ key:AnyObject, _ block:() -> Void) { | ||
let x = STStoryTeller.instance().startScope(key) | ||
block() | ||
let _ = x | ||
// STStoryTeller.instance().endScope(key) | ||
} |
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,10 @@ | ||
// | ||
// Bridging-Header.h | ||
// StoryTeller | ||
// | ||
// Created by Derek Clarkson on 23/10/16. | ||
// Copyright © 2016 Derek Clarkson. All rights reserved. | ||
// | ||
|
||
#import "InMemoryLogger.h" | ||
#import "STStoryTeller+Internal.h" |
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 |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
// | ||
|
||
@import Foundation; | ||
|
||
@import StoryTeller; | ||
|
||
@interface InMemoryLogger : STAbstractLogger | ||
|
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,5 +1,4 @@ | ||
// | ||
// InMemoryScribe.m | ||
// StoryTeller | ||
// | ||
// Created by Derek Clarkson on 18/06/2015. | ||
|
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,13 @@ | ||
// | ||
// STStoryTeller+Internal.h | ||
// StoryTeller | ||
// | ||
// Created by Derek Clarkson on 23/10/16. | ||
// Copyright © 2016 Derek Clarkson. All rights reserved. | ||
// | ||
|
||
// Accessing internal methods for testing purposes. | ||
@interface STStoryTeller (Testing) | ||
+(void) reset; | ||
+(void) clearMatchers; | ||
@end |
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,64 @@ | ||
// | ||
// STSwiftTests.swift | ||
// StoryTeller | ||
// | ||
// Created by Derek Clarkson on 21/10/16. | ||
// Copyright © 2016 Derek Clarkson. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
@testable import StoryTeller | ||
|
||
class STSwiftTests: XCTestCase { | ||
|
||
let _inMemoryLogger = InMemoryLogger() | ||
|
||
override func setUp() { | ||
STStoryTeller.instance().logger = _inMemoryLogger | ||
} | ||
|
||
override func tearDown() { | ||
STStoryTeller.reset() | ||
} | ||
|
||
func testBaseLogging() { | ||
STStartLogging("[StoryTellerTests.STSwiftTests]") | ||
STLog(self, "Hello") | ||
validateLogLine(0, methodName: "testBaseLogging", lineNumber: #line - 1, message: "Hello") | ||
} | ||
|
||
func testScopeActive() { | ||
STStartLogging("[StoryTellerTests.STSwiftTests]") | ||
STStartScope(self) { | ||
STLog("xyz" as NSString, "Hello") | ||
} | ||
validateLogLine(0, methodName: "testBaseLogging", lineNumber: #line - 2, message: "Hello") | ||
} | ||
|
||
func testScopeNestedActive() { | ||
STStartLogging("[StoryTellerTests.STSwiftTests]") | ||
STStartScope(self) { | ||
STLog("xyz" as NSString, "Hello") | ||
} | ||
STLog("xyz" as NSString, "Hello 2") | ||
validateLogLine(0, methodName: "testBaseLogging", lineNumber: #line - 3, message: "Hello") | ||
XCTAssertEqual(1, _inMemoryLogger.log.count) | ||
} | ||
|
||
// MARK:- Internal | ||
|
||
func validateLogLine(_ atIndex:Int, methodName:String, lineNumber:Int, message:String) { | ||
|
||
if _inMemoryLogger.log.count < atIndex + 1 { | ||
XCTFail("Not enough log lines") | ||
return | ||
} | ||
|
||
let fullFilename:NSString = #file | ||
let filename = fullFilename.lastPathComponent | ||
let expected = "\(filename):\(lineNumber) \(message)" | ||
let loggedMsg = _inMemoryLogger.log[atIndex] | ||
let idx = loggedMsg.index(loggedMsg.startIndex, offsetBy: 13) | ||
XCTAssertEqual(expected, loggedMsg.substring(from:idx)) | ||
} | ||
} |
Oops, something went wrong.