 
 class SlimLogglyDestination: LogDestination {
 
-    var userid:String?
+    var userid: String?
     fileprivate let dateFormatter = DateFormatter()
-    fileprivate var buffer:[String] = [String]()
+    fileprivate var buffer: [String] = []
     fileprivate var backgroundTaskIdentifier: UIBackgroundTaskIdentifier = UIBackgroundTaskInvalid
-    fileprivate lazy var standardFields:NSDictionary = {
-        let dict = NSMutableDictionary()
+    fileprivate lazy var standardFields: [String: String] = {
+        var dict: [String: String] = [:]
         dict["lang"] = Locale.preferredLanguages[0]
         if let infodict = Bundle.main.infoDictionary {
             if let appname = infodict["CFBundleName"] as? String {

        }
    }

    private func traceMessage(msg:String) {
        if SlimConfig.enableConsoleLogging && SlimLogglyConfig.logglyLogLevel == LogLevel.trace {
            print(msg)
        }
    }
}


        }
    }

    private func toJsonString(data: Data) -> String {
        if let jsonstring = String(data: data, encoding: .utf8) {
            return jsonstring
        } else {
            return ""
        }
    }

    func generateRandomNumberAsString() -> String {
        return String(arc4random_uniform(999999))
    }

    func log<T>( _ message: @autoclosure () -> T, level: LogLevel, filename: String, line: Int) {
        if level.rawValue < SlimLogglyConfig.logglyLogLevel.rawValue {
            // don't log
            return
        }

        var jsonstr = ""
        let mutableDict: NSMutableDictionary = NSMutableDictionary()
        var messageIsaDictionary = false
        if let msgdict = message() as? [NSObject : AnyObject] {
            mutableDict.addEntries(from: msgdict)
            messageIsaDictionary = true
        }
        if !messageIsaDictionary {
            mutableDict.setObject("\(message())", forKey: "rawmsg" as NSCopying)
        }
        mutableDict.setObject(level.string, forKey: "level" as NSCopying)
        mutableDict.setObject(dateFormatter.string(from: Date()), forKey: "timestamp" as NSCopying)
        mutableDict.setObject("\(filename):\(line)", forKey: "sourcelocation" as NSCopying)
        mutableDict.addEntries(from: standardFields as [NSObject : AnyObject])
        if let user = self.userid {
