     fileprivate var observer: NSObjectProtocol?
 
     init() {
-        dateFormatter.timeZone = TimeZone(abbreviation: "UTC") as TimeZone!
+        dateFormatter.timeZone = TimeZone(abbreviation: "UTC")!
         dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
         observer = NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: "UIApplicationWillResignActiveNotification"), object: nil, queue: nil, using: {
             [unowned self] note in

        }
    }

    private func toJsonString(data: NSData) -> String {
        if let jsonstring = NSString(data: data as Data, encoding: String.Encoding.utf8.rawValue) {
            return jsonstring as String
        } 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? NSDictionary {
            if let nsmsgdict = msgdict as? [NSObject : AnyObject] {
                mutableDict.addEntries(from: nsmsgdict)
                messageIsaDictionary = true
            }
        }
        if !messageIsaDictionary {
            mutableDict.setObject("\(message())", forKey: "rawmsg" as NSCopying)
        }
        mutableDict.setObject(level.string, forKey: "level" as NSCopying)
        mutableDict.setObject(dateFormatter.string(from: NSDate() as 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 {

        }
    }

    private func sendLogsInBuffer(stringbuffer: [String]) {
        let allMessagesString = stringbuffer.joined(separator: "\n")
        self.traceMessage(msg: "LOGGLY: will try to post \(allMessagesString)")
        if let url = URL(string: SlimLogglyConfig.logglyUrlString),
            let allMessagesData = allMessagesString.data(using: .utf8) {
            var request = URLRequest(url: url)
            request.httpMethod = "POST"
            request.httpBody = allMessagesData
            let session = URLSession.shared
            let task = session.dataTask(with: request, completionHandler: {(responsedata, response, error) in
                if let anError = error {
                    self.traceMessage(msg: "Error from Loggly: \(anError)")
                } else if let data = responsedata {
                    self.traceMessage(msg: "Posted to Loggly, status = \(String(data: data, encoding: .utf8) ?? "-")")
                } else {
                    self.traceMessage(msg: "Neither error nor responsedata, something's wrong")
                }
