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

Code before:
        error: Error,
        file: String = #file,
        function: String = #function,
        line: UInt = #line
    ) {
        let source: ErrorSource?
        let reason: String
        let level: Logger.Level
        switch error {
        case let debuggable as DebuggableError:
            if self.logLevel <= .trace {
                reason = debuggable.debuggableHelp(format: .long)
            } else {
                reason = debuggable.debuggableHelp(format: .short)
            }
            source = debuggable.source
            level = debuggable.logLevel
        case let abort as AbortError:
            reason = abort.reason
            source = nil
            
            if (500...599).contains(abort.status.code) {
                level = .error
            } else {
                level = .warning
            }
        case let localized as LocalizedError:
            reason = localized.localizedDescription
            source = nil
            level = .warning
        case let convertible as CustomStringConvertible:
            reason = convertible.description
            source = nil
            level = .warning
        default:
            reason = "\(error)"
            source = nil
            level = .warning
        
        self.log(
            level: level,
            .init(stringLiteral: reason),
            file: source?.file ?? file,
            function: source?.function ?? function,
            line: numericCast(source?.line ?? line)
        )
    }
}

struct MyError: DebuggableError {
    enum Value {

Review comment (suggestion):
I think this should probably be logged as a warning for all cases. There are several cases where an internal server error may occur (such as a dropped connection to a database) that may automatically be retried and be successful.  Anything logged at an error level should basically be considered something bad enough to wake people up. Since we can't work in any kind of flag for this, or configuration to choose which level, we should default to `.warning`. Anyone throwing `Abort(.internalServerError)` can alway add their own `logger.error` messages if they need.

However, this is a fairly big breaking change so I think we should throw this out to the community

Code after:
        error: Error,
        file: String = #file,
        function: String = #function,
        line: UInt = #line
    ) {
        let source: ErrorSource?
        let reason: String
        let level: Logger.Level
        switch error {
        case let debuggable as DebuggableError:
            if self.logLevel <= .trace {
                reason = debuggable.debuggableHelp(format: .long)
            } else {
                reason = debuggable.debuggableHelp(format: .short)
            }
            source = debuggable.source
            level = debuggable.logLevel
        case let abort as AbortError:
            reason = abort.reason
            source = nil
            
            if (500...599).contains(abort.status.code) {
                level = .error
            } else {
                level = .warning
            }
        case let localized as LocalizedError:
            reason = localized.localizedDescription
            source = nil
            level = .warning
        case let convertible as CustomStringConvertible:
            reason = convertible.description
            source = nil
            level = .warning
        default:
            reason = "\(error)"
            source = nil
            level = .warning
        }
        
        self.log(
            level: level,
            .init(stringLiteral: reason),
            file: source?.file ?? file,
            function: source?.function ?? function,
            line: numericCast(source?.line ?? line)
        )
    }
}