Repository: vapor/vapor
File: Sources/Vapor/Utilities/DotEnv.swift (Swift)

Code before:
/// Dotenv files are formatted using `KEY=VALUE` syntax. They support comments using the `#` symbol.
/// They also support strings, both single and double-quoted.
///
///     FOO=BAR
///     STRING='Single Quote String'
///     # Comment
///     STRING2="Double Quoted\nString"
///
/// Single-quoted strings are parsed literally. Double-quoted strings may contain escaped newlines
/// that will be converted to actual newlines.
public struct DotEnvFile {
    /// Reads the dotenv files relevant to the environment and loads them into the process.
    ///
    ///     let environment: Environment
    ///     let elgp: EventLoopGroupProvider
    ///     let logger: Logger
    ///     try DotEnvFile.load(environment: .development, elgp, logger: logger)
    ///     print(Environment.process.FOO) // BAR
    ///
    /// - parameters:
    ///     - environment: Absolute or relative path of the dotenv file.
    ///     - eventLoopGroupProvider: Either provides an EventLoopGroup or tells the function to create a new one.
    ///     - logger: Optionally provide an existing logger.
    public static func load(
        environment: Environment = .development,
        _ eventLoopGroupProvider: Application.EventLoopGroupProvider = .createNew,
        logger: Logger = Logger(label: "dot-env-loggger")
    ) {
        let eventLoopGroup: EventLoopGroup
        
        switch eventLoopGroupProvider {
        case .shared(let group):
            eventLoopGroup = group
        case .createNew:
            eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
        }
        defer {
            switch eventLoopGroupProvider {
            case .shared:
                logger.trace("Running on shared EventLoopGroup. Not shutting down EventLoopGroup")
            case .createNew:
                logger.trace("Shutting down EventLoopGroup")
                do {
                    try eventLoopGroup.syncShutdownGracefully()
                } catch {
                    logger.error("Shutting down EventLoopGroup failed: \(error)")
                }
            }
        }
        
        let threadPool = NIOThreadPool(numberOfThreads: 1)

Review comment (suggestion):
I would change the labels here to make for a cleaner and more readable callsite.
```suggestion
        for environment: Environment = .development,
        on eventLoopGroupProvider: Application.EventLoopGroupProvider = .createNew,
```

Code after:
/// Dotenv files are formatted using `KEY=VALUE` syntax. They support comments using the `#` symbol.
/// They also support strings, both single and double-quoted.
///
///     FOO=BAR
///     STRING='Single Quote String'
///     # Comment
///     STRING2="Double Quoted\nString"
///
/// Single-quoted strings are parsed literally. Double-quoted strings may contain escaped newlines
/// that will be converted to actual newlines.
public struct DotEnvFile {
    /// Reads the dotenv files relevant to the environment and loads them into the process.
    ///
    ///     let environment: Environment
    ///     let elgp: EventLoopGroupProvider
    ///     let logger: Logger
    ///     try DotEnvFile.load(for: .development, on: elgp, logger: logger)
    ///     print(Environment.process.FOO) // BAR
    ///
    /// - parameters:
    ///     - environment: current environment, selects which .env file to use.
    ///     - eventLoopGroupProvider: Either provides an EventLoopGroup or tells the function to create a new one.
    ///     - logger: Optionally provide an existing logger.
    public static func load(
        for environment: Environment = .development,
        on eventLoopGroupProvider: Application.EventLoopGroupProvider = .createNew,
        logger: Logger = Logger(label: "dot-env-loggger")
    ) {
        // Load specific .env first since values are not overridden.
        DotEnvFile.load(path: ".env.\(environment.name)")
        DotEnvFile.load(path: ".env")
    }
    
    /// Reads the dotenv files relevant to the environment and loads them into the process.
    ///
    ///     let path: String
    ///     let elgp: EventLoopGroupProvider
    ///     let logger: Logger
    ///     try DotEnvFile.load(path: path, on: elgp, logger: logger)
    ///     print(Environment.process.FOO) // BAR
    ///
    /// - parameters:
    ///     - path: Absolute or relative path of the dotenv file.
    ///     - eventLoopGroupProvider: Either provides an EventLoopGroup or tells the function to create a new one.
    ///     - logger: Optionally provide an existing logger.
    public static func load(
        path: String,
        on eventLoopGroupProvider: Application.EventLoopGroupProvider = .createNew,
        logger: Logger = Logger(label: "dot-env-loggger")
    ) {
        let eventLoopGroup: EventLoopGroup