-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
log/logr/v2 with logr, zapr deps updated to v1.2.2 #51
base: master
Are you sure you want to change the base?
Conversation
Note: This is a breaking change, hence versioned under /v2 to be imported as "github.com/packethost/pkg/log/logr/v2" With this change, returning *PacketLogr as a logr.Logger isn't possible, since logr.Logger is of type struct and it does not provide the methods that old logr.Logger interface would declare. https://github.com/go-logr/logr/blob/v1.2.2/logr.go#L230 https://github.com/go-logr/logr/blob/v0.4.0/logr.go#L148 The NewPacketLogr() is updated to return type *PacketLogr which embeds the logr.Logger struct type, it inherits various methods of the logr.Logger, although methods expecting a logr.Logger would need to reference the *PacketLogr.Logger struct field. The go-logr/logr v0.4.0 was an BETA API and is worth moving away from, https://github.com/go-logr/logr/blob/v0.4.0/logr.go#L20
Codecov Report
@@ Coverage Diff @@
## master #51 +/- ##
=======================================
Coverage 74.56% 74.56%
=======================================
Files 6 6
Lines 346 346
=======================================
Hits 258 258
Misses 70 70
Partials 18 18 Continue to review full report at Codecov.
|
github.com/go-logr/logr v0.4.0 -> v1.2.2 github.com/go-logr/zapr v0.4.0 -> v1.2.2 github.com/bmc-toolbox/bmclib v0.4.14 -> v0.4.16 packethost/pkg/log/logr -> packethost/pkg/log/logr/v2 bmclib updated in this change becuse of the indirect (bmclib v0.4.14) dependency on the on logr v0.4.0. expects PR merge: packethost/pkg#51
github.com/go-logr/logr v0.4.0 -> v1.2.2 github.com/go-logr/zapr v0.4.0 -> v1.2.2 github.com/bmc-toolbox/bmclib v0.4.14 -> v0.4.16 packethost/pkg/log/logr -> packethost/pkg/log/logr/v2 bmclib updated in this change becuse of the indirect (bmclib v0.4.14) dependency on the on logr v0.4.0. expects PR merge: packethost/pkg#51
Hey @joelrebel, we aren't really using semantic versioning in this module. we're still at v0.0.0. And with that being that case do we really need to move to v2? moving to v2 feels like we would be taking on the tradeoffs of backward compatibility, support, and maintainability of a stable version. Also, this logr package, in my opinion, should be deprecated. The only consumer I'm aware of is PBnJ. And PBnJ should just use go-logr directly. |
@jacobweinstock, The reasoning for v2 is keep the current code around, while having the newer version with breaking changes available under Deprecating this package would be ideal for lesser indirections and since the multi module nature of this repository makes it harder to maintain. The main motivation for this is tinkerbell/pbnj#114 |
resolves #50
Note: This is a breaking change, hence versioned under /v2
to be imported as
github.com/packethost/pkg/log/logr/v2
The current version of "github.com/packethost/pkg/log/logr" returns
*PacketLogr
as alogr.Logger
,which isn't possible anymore since in logr
v1.2.2
logr.Logger
is of type struct and it does not providethe methods that old
logr.Logger
interface would declare.https://github.com/go-logr/logr/blob/v1.2.2/logr.go#L230
https://github.com/go-logr/logr/blob/v0.4.0/logr.go#L148
With change, the
NewPacketLogr()
returns type*PacketLogr
which embeds the
logr.Logger
struct type, it inherits various methodsof the
logr.Logger
, although methods expecting alogr.Logger
would need toreference the
*PacketLogr.Logger
struct field.The go-logr/logr v0.4.0 was an BETA API and is worth moving away from,
https://github.com/go-logr/logr/blob/v0.4.0/logr.go#L20