Skip to content

Conversation

@jasperblues
Copy link

I'm not sure if this will be useful to others (hopefully, as it will alleviate our need to sync with upstream) however I needed to add support for DELETE with a JSON request body. (API didn't strictly adhere to spec).

For uniformity, provided also for GET. (In the past I have seen GET reqs with url encoded params along with a serialized body - this would not be supported).

@jasperblues
Copy link
Author

jasperblues commented Sep 28, 2021

@3lvis After the above PR, have another, which is the introduction of an ErrorLogger:

import Foundation

public protocol ErrorLogger {

    func log(_ message: String)

    func flush()

}

class ConsoleErrorLogger : ErrorLogger {

    func log(_ message: String) {
        print(message)
    }

    func flush() {} // Not required for console 

}

Default (provided) implementation logs to console, just as currently, custom version can, for example, log to Sentry.

@mkll
Copy link

mkll commented Sep 29, 2021

@jasperblues It seems to me that the name chosen is not entirely successful. We can log not only errors, but any messages in general, right?

Maybe a name like Logger would be more appropriate?

@mkll
Copy link

mkll commented Sep 29, 2021

After all, the name ErrorHandler implies an error handler, not simple message logging. I mean error trapping, recovery, etc.

@jasperblues
Copy link
Author

Ah yes @mkll you're right, that was a terrible choice! ErrorLogger would be better. (This only intercepts the logging that occurs on error, rest of the console logging is left alone).

@jasperblues
Copy link
Author

(More complicated, but better) A LogProvider that emits a (non-shared) instance of ErrorLogger will to prevent two errors being logged at the same time from entangling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants