Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: printing of version info #15

Merged
merged 5 commits into from
Jan 8, 2025
Merged

fix: printing of version info #15

merged 5 commits into from
Jan 8, 2025

Conversation

synackd
Copy link
Collaborator

@synackd synackd commented Jan 8, 2025

Version info was not getting set correctly in Goreleaser and therefore was not being printed upon plugin initialization. This PR corrects this, as well as:

  • Prints a summary of version info at info logging level upon plugin init
  • Prints detailed version info at debug level upon plugin init (i.e. when CoreDHCP is run with -L debug)
  • Formats the detailed version info as log message fields to align with CoreDHCP logging standard
  • Adds compiler, CPU architecture, and OS information to the detailed version info

This allows more information to be available when troubleshooting.

The following represents example logging output when debugging is enabled:

[...]
time="2025-01-08T18:22:38Z" level=info msg="initializing coresmd/coresmd 0.2.1-SNAPSHOT-e6a18e4 (dirty), built 2025-01-08T18:09:41Z" prefix="plugins/coresmd"                                               
time="2025-01-08T18:22:38Z" level=debug msg="detailed version info" arch=amd64 branch="synackd/fix-version" build_host=ochami-vm build_timestamp="2025-01-08T18:09:41Z" build_user=root commit=e6a18e4ef5ee108ee46e4770dc20f5709ab0bf60 go_version=go1.23.2 os=linux prefix="plugins/coresmd" state=dirty tag=v0.2.1 version=0.2.1-SNAPSHOT-e6a18e4 
[...]
time="2025-01-08T18:22:38Z" level=info msg="initializing coresmd/bootloop 0.2.1-SNAPSHOT-e6a18e4 (dirty), built 2025-01-08T18:09:41Z" prefix="plugins/bootloop"                                             
time="2025-01-08T18:22:38Z" level=debug msg="detailed version info" arch=amd64 branch="synackd/fix-version" build_host=ochami-vm build_timestamp="2025-01-08T18:09:41Z" build_user=root commit=e6a18e4ef5ee108ee46e4770dc20f5709ab0bf60 go_version=go1.23.2 os=linux prefix="plugins/bootloop" state=dirty tag=v0.2.1 version=0.2.1-SNAPSHOT-e6a18e4
[...]

Each plugin uses its own logVersion function that logs the info summary
at info level upon plugin init, then prints the detailed version info at
debug level, with each item being a field in the log message.
Copy link
Member

@alexlovelltroy alexlovelltroy left a comment

Choose a reason for hiding this comment

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

Good Catch

@alexlovelltroy alexlovelltroy merged commit ba9b7bc into main Jan 8, 2025
@synackd synackd deleted the synackd/fix-version branch January 8, 2025 19:44
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants