                         showLineNumbers: false,
                         showDate: true,
                         writeToFile: logFileURL,
-                        fileLevel: logLevel
+                        fileLevel: logLevel.xcgLogLevel()
         )
     }
 


    func reportMissingLogFile() {
        let message = String(format: "[%@] Could not locate log file.", instanceType(self))
        let domain: ErrorDomain = .Logging
        let code: LoggingErrorCode = .NoLoggingFile
        let error = NSError(domain: domain.domainString(),
                            code: code.rawValue,
                            userInfo: [ NSLocalizedDescriptionKey: message ])
        logError(message: message, error: error)
    }
    
}

import Foundation
import XCGLogger

enum LogLevel: Int {

    case unknown = 0
    case verbose
    case debug
    case info
    case warning
    case error

    func xcgLogLevel() -> XCGLogger.Level {
        switch self {
        case .unknown: return XCGLogger.Level.info // default to info
        case .verbose: return XCGLogger.Level.verbose
        case .debug: return XCGLogger.Level.debug
        case .info: return XCGLogger.Level.info
        case .warning: return XCGLogger.Level.warning
        case .error: return XCGLogger.Level.error
        }
    }

}

final class LogController: NSObject {

    var logLevel: LogLevel = .info
    fileprivate var appName: String!
    fileprivate var loggingQueue: DispatchQueue!
    fileprivate var logFileURL: URL?
    fileprivate let xcgLogger = XCGLogger(identifier: XCGLogger.Constants.fileDestinationIdentifier, includeDefaultDestinations: true)

    init(forAppNamed appName: String, logLevel: LogLevel) {
        super.init()
        self.appName = appName
        self.loggingQueue = DispatchQueue(label: "com.tworingsoft.\(appName).logger-queue")
