Move NSDateFormatter to instance var. Add timestamp to dispose
This commit is contained in:
parent
9b37a36001
commit
c90511b99b
|
|
@ -13,9 +13,11 @@ class Debug_<O: ObserverType> : Sink<O>, ObserverType {
|
|||
typealias Parent = Debug<Element>
|
||||
|
||||
private let _parent: Parent
|
||||
private let _timestampFormatter = NSDateFormatter()
|
||||
|
||||
init(parent: Parent, observer: O) {
|
||||
_parent = parent
|
||||
_timestampFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
|
||||
super.init(observer: observer)
|
||||
}
|
||||
|
||||
|
|
@ -26,14 +28,12 @@ class Debug_<O: ObserverType> : Sink<O>, ObserverType {
|
|||
? String(eventText.characters.prefix(maxEventTextLength / 2)) + "..." + String(eventText.characters.suffix(maxEventTextLength / 2))
|
||||
: eventText
|
||||
|
||||
let format = NSDateFormatter()
|
||||
format.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
|
||||
print("\(format.stringFromDate(NSDate())): [\(_parent._identifier)] -> Event \(eventNormalized)")
|
||||
print("\(_timestampFormatter.stringFromDate(NSDate())): [\(_parent._identifier)] -> Event \(eventNormalized)")
|
||||
forwardOn(event)
|
||||
}
|
||||
|
||||
override func dispose() {
|
||||
print("[\(_parent._identifier)] dispose")
|
||||
print("\(_timestampFormatter.stringFromDate(NSDate())): [\(_parent._identifier)] dispose")
|
||||
super.dispose()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue