-
Notifications
You must be signed in to change notification settings - Fork 110
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
[RSDK-9261] Initial clean up of webcam.go #4555
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, definitley merge in after the camera interface pr, and one request about the two loggers that maybe would be bets left to a follow up pr, feel free to comment exactly that.
logger logging.Logger | ||
originalLogger logging.Logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we try to just have one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the separation is used for log search when path/label changes during reconnects.
c.logger = c.originalLogger.WithFields("camera_label", c.targetPath)
I think we can preserve the log structure for queryablity with multiple fields. something like:
logger: logger.WithFields(logrus.Fields{
"camera_name": conf.ResourceName().ShortName(),
"camera_label": c.targetPath,
}),
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the "camera_label" logger anywhere in NewWebCam, where are you looking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It happens in reconnectCamera
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Talked to @dgottlieb and we now have the adapter support between the zap logger and our rdk logger i.e. we can assign the return value of WithFields
to logger
instead of having to use originalLogger
to do so.
logger logging.Logger | ||
originalLogger logging.Logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the separation is used for log search when path/label changes during reconnects.
c.logger = c.originalLogger.WithFields("camera_label", c.targetPath)
I think we can preserve the log structure for queryablity with multiple fields. something like:
logger: logger.WithFields(logrus.Fields{
"camera_name": conf.ResourceName().ShortName(),
"camera_label": c.targetPath,
}),
logger logging.Logger | ||
originalLogger logging.Logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It happens in reconnectCamera
here.
Summary
Let's put the numerous private helpers above their caller and arrange this file to be more readable. Additionally we remove some vestigial logic that doesn't belong anymore.
95% of changes are syntax, var renaming, function rearranging, comment additions and updates.
The only three semantic changes made:
Manual testing
Tested using
go run
with two webcams. Made sure hot swap and discovery and stream look good.Tip for reviewing
Diff best viewed in split mode
Reminder for myself to merge in the Go interface PR before this one to avoid conflicts with the more high priority one