 open class Slim {
 
     var logDestinations: [LogDestination] = []
-    var cleanedFilenamesCache:NSCache<AnyObject,AnyObject> = NSCache<AnyObject,AnyObject>()
+    var cleanedFilenamesCache: NSCache<AnyObject, AnyObject> = NSCache()
 
     init() {
+        
         if SlimConfig.enableConsoleLogging {
             logDestinations.append(ConsoleDestination())
+        }
+        
+        if SlimConfig.enableCloudLogging {
+            logDestinations.append(SlimLogglyDestination())
         }
     }
 

        }
    }

    fileprivate func cleanedFilename(_ filename:String) -> String {
        if let cleanedfile:String = cleanedFilenamesCache.object(forKey:filename as AnyObject) as? String {
            return cleanedfile
        } else {
            var retval = ""
            let items = filename.characters.split{$0 == "/"}.map(String.init)
            
            
            if items.count > 0 {
                retval = items.last!
            }
            cleanedFilenamesCache.setObject(retval as AnyObject, forKey:filename as AnyObject)
            return retval
        }
    }

    fileprivate func isSourceFileEnabled(_ cleanedFile:String) -> Bool {
        switch SlimConfig.sourceFilesThatShouldLog {
            case .all:
                return true
            case .none:
                return false
            case .enabledSourceFiles(let enabledFiles):
                if enabledFiles.contains(cleanedFile) {
                    return true
                } else {
                    return false
                }
        }
    }
}

            return "FATAL"
        }
    }
}

public protocol LogDestination {
    func log<T>( _ message: @autoclosure () -> T, level: LogLevel, filename: String, line: Int)
}

private let slim = Slim()
