         addLogMsgToBuffer(msg: jsonstr)
     }
 
-    private func addLogMsgToBuffer(msg:String) {
+    private func addLogMsgToBuffer(msg: String) {
         logglyQueue.async {
             self.buffer.append(msg)
             if self.buffer.count > SlimLogglyConfig.maxEntriesInBuffer {

            NotificationCenter.default.removeObserver(observer)
        }
    }
    
    private func toJson(dictionary: NSDictionary) -> NSData? {

        var err: NSError?
        do {
            let json = try JSONSerialization.data(withJSONObject: dictionary, options: JSONSerialization.WritingOptions(rawValue: 0))
            return json as NSData?
        } catch let error1 as NSError {
            err = error1
            let error = err?.description ?? "nil"

        }
    }

    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 {
