<commit_before>//
//  SwiftyBeaver.swift
//  SwiftyBeaver
//
//  Created by <NAME> (Twitter @skreutzb) on 28.11.15.
//  Copyright © 2015 <NAME>
//  Some rights reserved: http://opensource.org/licenses/MIT
//

import Foundation

public class SwiftyBeaver {
    
    public enum Level: Int {
        case Verbose = 0
        case Debug = 1
        case Info = 2
        case Warning = 3
        case Error = 4
    }
    
    // a set of active destinations
    static var destinations = Set<BaseDestination>() //[BaseDestination]()
    
    
    // MARK: Destination Handling
    
    /// returns boolean about success
    public class func addDestination(destination: AnyObject) -> Bool {
        let dest = destination as? BaseDestination
        
        if let dest = dest {
            //print("insert hashValue \(dest.hashValue)")
            destinations.insert(dest)  // if not already in (it’s a set)
            return true
        } else {
            print("SwiftyBeaver: adding of destination failed")
            return false
        }
    }

    /// returns boolean about success
    public class func removeDestination(destination: AnyObject) -> Bool {
        let dest = destination as? BaseDestination
        
        if let dest = dest {
            destinations.remove(dest)
            return true
        } else {
            print("SwiftyBeaver: removing of destination failed")
            return false
        }
    }

    /// if you need to start fresh
    public class func removeAllDestinations() {
        destinations.removeAll()
    }
    
    /// returns the amount of destinations
    public class func countDestinations() -> Int {
        return destinations.count
    }
    
    
    // MARK: Levels
    
    public class func verbose(msg: String = "", _ path: String = __FILE__, _ function: String = __FUNCTION__, line: Int = __LINE__) {
        let level = Level.Verbose
        
        for dest in destinations {
            if let queue = dest.queue {
                if dest.minLevel.rawValue <= level.rawValue && dest.queue != nil {
                    dispatch_async(queue, {
                        dest.send(level, msg: msg, path: path, function: function, line: line)
                    })
                }
            }
        }
    }

    public class func debug(msg: String = "", _ path: String = __FILE__, _ function: String = __FUNCTION__, line: Int = __LINE__) {
        let level = Level.Debug
        
        for dest in destinations {
            if let queue = dest.queue {
                if dest.minLevel.rawValue <= level.rawValue && dest.queue != nil {
                    dispatch_async(queue, {
                        dest.send(level, msg: msg, path: path, function: function, line: line)
                    })
                }
            }
        }
    }
    
    public class func info(msg: String = "", _ path: String = __FILE__, _ function: String = __FUNCTION__, line: Int = __LINE__) {
        let level = Level.Info
        
        for dest in destinations {
            if let queue = dest.queue {
                if dest.minLevel.rawValue <= level.rawValue && dest.queue != nil {
                    dispatch_async(queue, {
                        dest.send(level, msg: msg, path: path, function: function, line: line)
                    })
                }
            }
        }
    }
    
    public class func warning(msg: String = "", _ path: String = __FILE__, _ function: String = __FUNCTION__, line: Int = __LINE__) {
        let level = Level.Warning
        
        for dest in destinations {
            if let queue = dest.queue {
                if dest.minLevel.rawValue <= level.rawValue && dest.queue != nil {
                    dispatch_async(queue, {
                        dest.send(level, msg: msg, path: path, function: function, line: line)
                    })
                }
            }
        }
    }
    
    public class func error(msg: String = "", _ path: String = __FILE__, _ function: String = __FUNCTION__, line: Int = __LINE__) {
        let level = Level.Error
        
        for dest in destinations {
            if let queue = dest.queue {
                if dest.minLevel.rawValue <= level.rawValue && dest.queue != nil {
                    dispatch_async(queue, {
                        dest.send(level, msg: msg, path: path, function: function, line: line)
                    })
                }
            }
        }
    }
}<commit_msg>Bundle recurring if statements in level methods<commit_after>//
//  SwiftyBeaver.swift
//  SwiftyBeaver
//
//  Created by <NAME> (Twitter @skreutzb) on 28.11.15.
//  Copyright © 2015 <NAME>
//  Some rights reserved: http://opensource.org/licenses/MIT
//

import Foundation

public class SwiftyBeaver {
    
    public enum Level: Int {
        case Verbose = 0
        case Debug = 1
        case Info = 2
        case Warning = 3
        case Error = 4
    }
    
    // a set of active destinations
    static var destinations = Set<BaseDestination>() //[BaseDestination]()
    
    
    // MARK: Destination Handling
    
    /// returns boolean about success
    public class func addDestination(destination: AnyObject) -> Bool {
        let dest = destination as? BaseDestination
        
        if let dest = dest {
            //print("insert hashValue \(dest.hashValue)")
            destinations.insert(dest)  // if not already in (it’s a set)
            return true
        } else {
            print("SwiftyBeaver: adding of destination failed")
            return false
        }
    }

    /// returns boolean about success
    public class func removeDestination(destination: AnyObject) -> Bool {
        let dest = destination as? BaseDestination
        
        if let dest = dest {
            destinations.remove(dest)
            return true
        } else {
            print("SwiftyBeaver: removing of destination failed")
            return false
        }
    }

    /// if you need to start fresh
    public class func removeAllDestinations() {
        destinations.removeAll()
    }
    
    /// returns the amount of destinations
    public class func countDestinations() -> Int {
        return destinations.count
    }
    
    
    // MARK: Levels
    
    public class func verbose(msg: String = "", _ path: String = __FILE__, _ function: String = __FUNCTION__, line: Int = __LINE__) {
        dispatch_send(Level.Verbose, msg: msg, path: path, function: function, line: line)
    }

    public class func debug(msg: String = "", _ path: String = __FILE__, _ function: String = __FUNCTION__, line: Int = __LINE__) {
        dispatch_send(Level.Debug, msg: msg, path: path, function: function, line: line)
    }
    
    public class func info(msg: String = "", _ path: String = __FILE__, _ function: String = __FUNCTION__, line: Int = __LINE__) {
        dispatch_send(Level.Info, msg: msg, path: path, function: function, line: line)
    }
    
    public class func warning(msg: String = "", _ path: String = __FILE__, _ function: String = __FUNCTION__, line: Int = __LINE__) {
        dispatch_send(Level.Warning, msg: msg, path: path, function: function, line: line)
    }
    
    public class func error(msg: String = "", _ path: String = __FILE__, _ function: String = __FUNCTION__, line: Int = __LINE__) {
       dispatch_send(Level.Error, msg: msg, path: path, function: function, line: line)
    }
    
    /// internal helper which dispatches send to dedicated queue if minLevel is ok
    class func dispatch_send(level: SwiftyBeaver.Level, msg: String, path: String, function: String, line: Int) {
        for dest in destinations {
            if let queue = dest.queue {
                if dest.minLevel.rawValue <= level.rawValue && dest.queue != nil {
                    dispatch_async(queue, {
                        dest.send(level, msg: msg, path: path, function: function, line: line)
                    })
                }
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.09510699536979102, 'fraction_numerical': 0.003754223501439119, 'mean_word_length': 1.7426218256691832, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7197030', 'n_tokens_mistral': 2164, 'n_tokens_neox': 2078, 'n_words': 668}