Skip to content

Commit fdf4848

Browse files
committedNov 1, 2019
Merge branch 'directory-selection'
2 parents 66949bf + 7d58a05 commit fdf4848

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
 

‎IntegrationSpecs/QuickELoggerObjCIntegrationSpec.swift

+68
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,74 @@ class QuickELoggerObjCIntegrationSpec: QuickSpec {
145145
}
146146
}
147147
}
148+
149+
describe("writing to other directories besides the Documents directory") {
150+
describe("tmp") {
151+
beforeEach {
152+
subject = QuickELoggerObjC(directory: .temp)
153+
154+
subject.log(message: "This is temporary and will get deleted frequently", type: .info)
155+
}
156+
157+
it("writes the log file to the temp directory") {
158+
let logMessages = getLogMessages(filename: "QuickELogger", directory: .temp)
159+
160+
expect(logMessages.count).to(equal(1))
161+
162+
let logMessage = logMessages.first!
163+
164+
expect(logMessage.id).toNot(beNil())
165+
expect(logMessage.timeStamp).toNot(beNil())
166+
167+
expect(logMessage.type).to(equal(.info))
168+
expect(logMessage.message).to(equal("This is temporary and will get deleted frequently"))
169+
}
170+
}
171+
172+
describe("Caches") {
173+
beforeEach {
174+
subject = QuickELoggerObjC(directory: .caches)
175+
176+
subject.log(message: "This can be deleted unexpectedly", type: .info)
177+
}
178+
179+
it("writes the log file to the caches directory") {
180+
let logMessages = getLogMessages(filename: "QuickELogger", directory: .caches)
181+
182+
expect(logMessages.count).to(equal(1))
183+
184+
let logMessage = logMessages.first!
185+
186+
expect(logMessage.id).toNot(beNil())
187+
expect(logMessage.timeStamp).toNot(beNil())
188+
189+
expect(logMessage.type).to(equal(.info))
190+
expect(logMessage.message).to(equal("This can be deleted unexpectedly"))
191+
}
192+
}
193+
194+
describe("Library") {
195+
beforeEach {
196+
subject = QuickELoggerObjC(directory: .library)
197+
198+
subject.log(message: "This is the top-level directory for any files that are not user data files", type: .info)
199+
}
200+
201+
it("writes the log file to the library directory") {
202+
let logMessages = getLogMessages(filename: "QuickELogger", directory: .library)
203+
204+
expect(logMessages.count).to(equal(1))
205+
206+
let logMessage = logMessages.first!
207+
208+
expect(logMessage.id).toNot(beNil())
209+
expect(logMessage.timeStamp).toNot(beNil())
210+
211+
expect(logMessage.type).to(equal(.info))
212+
expect(logMessage.message).to(equal("This is the top-level directory for any files that are not user data files"))
213+
}
214+
}
215+
}
148216
}
149217
}
150218
}

‎QuickELogger/Source/ObjC/QuickELoggerObjC.swift

+5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public class QuickELoggerObjC: NSObject {
5656
self.init(filename: filename, directory: .documents)
5757
}
5858

59+
@objc
60+
public convenience init(directory: ObjCDirectory) {
61+
self.init(filename: "QuickELogger", directory: directory)
62+
}
63+
5964
@objc
6065
public init(filename: String, directory: ObjCDirectory) {
6166
let transformedDirectory = transformDirectory(objcDirectory: directory)

0 commit comments

Comments
 (0)
Please sign in to comment.