Skip to content

[dependencies] Remove unmaintained dependency "zap-logfmt" - #54

Merged
pfi79 merged 1 commit into
hyperledger:mainfrom
liran-funaro:remove-zap-logfmt
Jul 8, 2026
Merged

pfi79 merged 1 commit into
hyperledger:mainfrom
liran-funaro:remove-zap-logfmt

Conversation

@liran-funaro

Copy link
Copy Markdown
Contributor

The package github.com/sykesm/zap-logfmt is no longer maintained (last commit was 5 years ago).
This commit removes this dependency.

@liran-funaro
liran-funaro requested a review from a team as a code owner June 28, 2026 11:01
Signed-off-by: Liran Funaro <liran.funaro@gmail.com>
@liran-funaro

liran-funaro commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Pass all Fabric unit tests: https://github.com/liran-funaro/fabric/actions/runs/28320919435

@liran-funaro

Copy link
Copy Markdown
Contributor Author

@pfi79 , friendly ping on this whenever you get a chance to review. Thanks!

@pfi79

pfi79 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

I'll try to criticize your PR.:

  1. here is the commit that added logfmt. It seems to me that you have deleted more code than necessary in your change.
  2. I still don't like that with the removal of the library dependency, you also removed the logfmt setting. Try to keep logfmt, but remove the dependency on the library.

@liran-funaro

Copy link
Copy Markdown
Contributor Author

@pfi79 Thanks for the review.

  1. Code removal: The original zap-logfmt package consisted of just a single file. Because it has since expanded, more files needed to be cleaned up here. I only removed code introduced by that specific commit, while adding necessary logic to preserve the exact original behavior.
  2. logfmt option: As noted in Remove dependency on github.com/sykesm/zap-logfmt #53, the logfmt option isn't officially documented, and I'm not aware of any active production use. Supporting it would require extra boilerplate that we'd have to maintain solely for this edge case.

Let me know how you'd like to proceed!

Comment on lines -34 to -44
MessageKey: "", // disable
LevelKey: "", // disable
TimeKey: "", // disable
NameKey: "", // disable
CallerKey: "", // disable
StacktraceKey: "", // disable
LineEnding: "\n",
EncodeDuration: zapcore.StringDurationEncoder,
EncodeTime: func(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
enc.AppendString(t.Format("2006-01-02T15:04:05.999Z07:00"))
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you delete these settings? they were before the addition of the zap-logfmt dependency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are hard-coded in the new implementation. This is because we only have one use case for this module.
The original one was an external lib; thus, it had to be generic.

@pfi79

pfi79 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

2. logfmt option: As noted in Remove dependency on github.com/sykesm/zap-logfmt #53, the logfmt option isn't officially documented, and I'm not aware of any active production use. Supporting it would require extra boilerplate that we'd have to maintain solely for this edge case.

To make decisions on your change, I want to figure out how logfmt differs from the rest of the console and json.
Not in theory, but in fact. Where are the differences?

@liran-funaro

Copy link
Copy Markdown
Contributor Author

To make decisions on your change, I want to figure out how logfmt differs from the rest of the console and json.
Not in theory, but in fact. Where are the differences?

logfmt is similar to JSON, but the fields are presented in the logfmt format instead of JSON
For example:

ts=<epoch>  level=<lower>  name=<logger, only if LoggerName!="">  caller=<short, only if Caller.Defined>  msg="..."   [With-ctx fields]  [entry fields]  stacktrace=<..., only if ent.Stack!="", appended LAST after fields>

@pfi79

pfi79 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

To make decisions on your change, I want to figure out how logfmt differs from the rest of the console and json.
Not in theory, but in fact. Where are the differences?

logfmt is similar to JSON, but the fields are presented in the logfmt format instead of JSON For example:

ts=<epoch>  level=<lower>  name=<logger, only if LoggerName!="">  caller=<short, only if Caller.Defined>  msg="..."   [With-ctx fields]  [entry fields]  stacktrace=<..., only if ent.Stack!="", appended LAST after fields>

I'm sorry, but I don't understand.
Can you use an example, a specific example, to give an output in all 3 variants?
Please understand that it is not as clear to me as it is to you why we can get rid of LOGFMT.

@liran-funaro

Copy link
Copy Markdown
Contributor Author

@pfi79

CONSOLE  2021-03-23 22:15:21.969 UTC [orderer.consensus.etcdraft] becomePreCandidate -> INFO 001 2 became pre-candidate at term 1 channel=canalenergia node=2
JSON     {"level":"info","ts":1616537721.9689999,"name":"orderer.consensus.etcdraft","caller":"raft/raft.go:707","msg":"2 became pre-candidate at term 1","channel":"canalenergia","node":2}
LOGFMT   ts=1616537721.9689999 level=info name=orderer.consensus.etcdraft caller=raft/raft.go:707 msg="2 became pre-candidate at term 1" channel=canalenergia node=2

@liran-funaro

Copy link
Copy Markdown
Contributor Author

@pfi79 Is there any additional action item for me regarding this PR?

@pfi79 pfi79 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your hard work.

@pfi79
pfi79 merged commit 163bcc9 into hyperledger:main Jul 8, 2026
4 checks passed
@liran-funaro
liran-funaro deleted the remove-zap-logfmt branch July 8, 2026 12:00
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.

Remove dependency on github.com/sykesm/zap-logfmt

3 participants