Repository: vapor/vapor
File: Sources/Vapor/Logging/Logger+LogError.swift (Swift)

Code before:
    ///
    /// - parameters:
    ///     - error: `Error` to log.
    ///     - verbose: If `true`, extra lines of debug information will be printed containing
    ///                things like suggested fixes, possible causes, or other info.
    ///                Defaults to `true`.
    public func report(
        error e: Error,
        path: String? = nil,
        verbose: Bool = true,
        file: String = #file,
        function: String = #function,
        line: UInt = #line,
        column: UInt = #column
    ) {
        switch e {
        case let debuggable as Debuggable:
            
            let pathString: String
            if let path = path {
                pathString = " \(path)"
            } else {
                pathString = ""
            }
            
            let errorString = "\(debuggable.fullIdentifier):\(pathString) \(debuggable.reason)"
            if let source = debuggable.sourceLocation {
                error(errorString, file: source.file.lastPart, function: source.function, line: source.line, column: source.column)
            } else {
                error(errorString, file: file.lastPart, function: function, line: line, column: column)
            }
            if verbose, debuggable.suggestedFixes.count > 0 {
                let str = "Suggested fixes for \(debuggable.fullIdentifier): " + debuggable.suggestedFixes.joined(separator: " ")
                debug(str, file: file.lastPart, function: function, line: line, column: column)
            }
            if verbose, debuggable.possibleCauses.count > 0 {
                let str = "Possible causes for \(debuggable.fullIdentifier): " + debuggable.possibleCauses.joined(separator: " ")
                debug(str, file: file.lastPart, function: function, line: line, column: column)
            }
        default:
            let reason: String
            switch e {
            case let localized as LocalizedError: reason = localized.localizedDescription
            case let convertible as CustomStringConvertible: reason = convertible.description
            default: reason = "\(e)"
            }
            error(reason, file: file.lastPart, function: function, line: line, column: column)
            if verbose {
                let str = "Conform `\(type(of: e))` to `Debuggable` for better debug info."
                debug(str, file: file.lastPart, function: function, line: line, column: column)
            }

Review comment (bug):
Including the method would be nice since otherwise this could be ambiguous for multiple routes:
```swift
"\(debuggable.fullIdentifier): \(req.http.method) \(req.http.urlString): \(debuggable.reason)"
```

Code after:
    ///
    /// - parameters:
    ///     - error: `Error` to log.
    ///     - verbose: If `true`, extra lines of debug information will be printed containing
    ///                things like suggested fixes, possible causes, or other info.
    ///                Defaults to `true`.
    public func report(
        error e: Error,
        request: Request? = nil,
        verbose: Bool = true,
        file: String = #file,
        function: String = #function,
        line: UInt = #line,
        column: UInt = #column
    ) {
        switch e {
        case let debuggable as Debuggable:
            
            let requestString: String
            if let request = request {
                requestString = " \(request.http.method) \(request.http.urlString)"
            } else {
                requestString = ""
            }
            
            let errorString = "\(debuggable.fullIdentifier):\(requestString) \(debuggable.reason)"
            if let source = debuggable.sourceLocation {
                error(errorString, file: source.file.lastPart, function: source.function, line: source.line, column: source.column)
            } else {
                error(errorString, file: file.lastPart, function: function, line: line, column: column)
            }
            if verbose, debuggable.suggestedFixes.count > 0 {
                let str = "Suggested fixes for \(debuggable.fullIdentifier): " + debuggable.suggestedFixes.joined(separator: " ")
                debug(str, file: file.lastPart, function: function, line: line, column: column)
            }
            if verbose, debuggable.possibleCauses.count > 0 {
                let str = "Possible causes for \(debuggable.fullIdentifier): " + debuggable.possibleCauses.joined(separator: " ")
                debug(str, file: file.lastPart, function: function, line: line, column: column)
            }
        default:
            let reason: String
            switch e {
            case let localized as LocalizedError: reason = localized.localizedDescription
            case let convertible as CustomStringConvertible: reason = convertible.description
            default: reason = "\(e)"
            }
            error(reason, file: file.lastPart, function: function, line: line, column: column)
            if verbose {
                let str = "Conform `\(type(of: e))` to `Debuggable` for better debug info."
                debug(str, file: file.lastPart, function: function, line: line, column: column)
            }