<commit_before>import Vapor

public final class Provider: Vapor.Provider {
    public let logger: Logger
    
    public func beforeRun(_: Vapor.Droplet) {
    }
    
    public init(config: Config) throws {
        logger = Logger()
    }
    
    public init() {
        logger = Logger()
    }
    
    public init(format: LogType) {
        logger = Logger(format: format)
    }
    
    public init(file: String) {
        logger = Logger(file: file)
    }
    
    public init(format: LogType, file: String) {
        logger = Logger(format: format, file: file)
    }
    
    public func afterInit(_ drop: Droplet) {
    }
    
    public func boot(_ drop: Droplet) {
        drop.middleware.append(logger)
    }
}
<commit_msg>get setting from config file<commit_after>import Vapor

public final class Provider: Vapor.Provider {
    public let logger: Logger
    enum ConfigError: Error {
        case configNotFound
    }
    
    public func beforeRun(_: Vapor.Droplet) {
    }
    
    public init(config: Config) throws {
        guard let heimdallConfig = config["heimdall"]?.object else {
            throw ConfigError.configNotFound
        }

        guard
            let file = heimdallConfig["file"]?.string,
            let format = heimdallConfig["format"]?.string else {
                self.logger = Logger()
                return
        }

        let formatType: LogType = {
            switch format {
            case "common":
                return .common
            case "dev":
                return .dev
            case "short":
                return .short
            case "tiny":
                return .tiny
            default:
                return .combined
            }
        }()

        // TODO: call initializer based on existence of file and format
        self.logger = Logger(format: formatType)
    }
    
    public init() {
        logger = Logger()
    }
    
    public init(format: LogType) {
        logger = Logger(format: format)
    }
    
    public init(file: String) {
        logger = Logger(file: file)
    }
    
    public init(format: LogType, file: String) {
        logger = Logger(format: format, file: file)
    }
    
    public func afterInit(_ drop: Droplet) {
    }
    
    public func boot(_ drop: Droplet) {
        drop.middleware.append(logger)
    }
}

{'fraction_non_alphanumeric': 0.0910645575032065, 'fraction_numerical': 0.0, 'mean_word_length': 1.650056625141563, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, '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': '3356288', 'n_tokens_mistral': 664, 'n_tokens_neox': 647, 'n_words': 178}