imroc / req

Simple Go HTTP client with Black Magic
https://req.cool
MIT License
4.24k stars 346 forks source link

Allow logger creation from an existing standard logger #345

Closed dbhoot closed 5 months ago

dbhoot commented 5 months ago

Previously

You could not create a req.Logger from a log.Logger. Instead, you have to create one from an io.Writer.

Unfortunately, there are situations when you do not have access to the underlying io.Writer for your .Logger. This limits your ability to set the client logger using the tooling of your choice.

Now

You can usually convert your .Logger into a log.Logger. With this PR, you're now able to create a req.Logger from a log.Logger and set your client logger as needed.

dbhoot commented 5 months ago

@imroc what are your thoughts on this change? Please review when you have a moment.

imroc commented 5 months ago

I think it's better to rename to NewLoggerFromStandardLogger, a bit longer, but no ambiguity.

dbhoot commented 5 months ago

I think it's better to rename to NewLoggerFromStandardLogger, a bit longer, but no ambiguity.

I agree. I was thinking of making that change anyway. Good call.

imroc commented 5 months ago

NewFromStandardLogger --> NewLoggerFromStandardLogger

imroc commented 5 months ago

Thanks

dbhoot commented 5 months ago

@imroc do we need a new release for this?

imroc commented 5 months ago

Released at v3.43.3