Files
WWDC/TranscriptIndexingService/TranscriptIndexingService.swift
T
Guilherme Rambo cb630b16c5 Moved all logging to os_log
Unchecked delorean from arguments

Fixed typo

Adds custom SwiftLint rule discouraging the usage of non-os_log logging
2018-05-13 20:26:04 -03:00

35 lines
1.1 KiB
Swift

//
// TranscriptIndexingService.swift
// WWDC
//
// Created by Guilherme Rambo on 28/05/17.
// Copyright © 2017 Guilherme Rambo. All rights reserved.
//
import Foundation
import ConfCore
import RealmSwift
import os.log
final class TranscriptIndexingService: NSObject, TranscriptIndexingServiceProtocol {
private var transcriptIndexer: TranscriptIndexer!
private let log = OSLog(subsystem: "TranscriptIndexingService", category: "TranscriptIndexingService")
func indexTranscriptsIfNeeded(storageURL: URL, schemaVersion: UInt64) {
if transcriptIndexer == nil {
do {
let config = Realm.Configuration(fileURL: storageURL, schemaVersion: schemaVersion)
let storage = try Storage(config)
transcriptIndexer = TranscriptIndexer(storage)
} catch {
os_log("Error initializing indexing service: %{public}@", log: self.log, type: .fault, String(describing: error))
return
}
}
transcriptIndexer.downloadTranscriptsIfNeeded()
}
}