Skip to content
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

Change samples to use log instead of glog. #581

Merged
merged 3 commits into from
Apr 4, 2018
Merged

Change samples to use log instead of glog. #581

merged 3 commits into from
Apr 4, 2018

Conversation

mdemirhan
Copy link
Contributor

Fixes Issue #347

Proposed Changes

Chris Broadfoot proposed to use the standard log library rather than glog. Reasons being:

  • glog is overly complicated
  • pollutes global flags
  • is really only suitable for use internally at Google
  • no longer maintained

Instead of glog, we will use the standard go log library. If users want to swap it out for something custom, they can go for it.

Testing

I manually tested all the samples to ensure that the logs are showing up and apps are not crashing.
@vaikas-google I couldn't fully test gitwebhook sample. I was able to start it and see the startup log message, but I didn't go through the full DNS setup and see it working end-to-end. Let me know if you have any concerns.

@google-prow-robot google-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 4, 2018
fmt.Fprintf(w, "%s not found for ticker : %s \n",resource, stockId)
if err != nil {
fmt.Fprintf(w, "%s not found for ticker : %s \n", resource, stockId)
return
Copy link

Choose a reason for hiding this comment

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

good catch

Copy link
Contributor

@grantr grantr left a comment

Choose a reason for hiding this comment

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

Thanks @mdemirhan! I noticed sample/helloworld/updated_configuration.yaml still has the glog startup args in it. Also, would it be worth adding a "Best Practices" section to samples/README.md explaining that we prefer log?

@@ -73,7 +72,8 @@ func init() {

func main() {
flag.Parse()
glog.Info("Telemetry sample started.")
log.SetPrefix("TelemetrySample: ")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why set prefix here but not in the other samples?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No reason really. The prefix seems like a nice touch but doesn't really make or break anything. That is why I didn't do it in other samples.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@grantr For the updated_configuration.yaml, this is a great catch. I will fix that.

As for why we prefer log vs glog: We didn't pick log because it is better than glog. I think the goal is to provide samples with minimal dependencies and let people pick the logging library they like the most.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 on prefix. I agree the fewer statements the better in sample code, so I'm fine with leaving it out. IIUC the telemetry sample logs from multiple processes so having prefixes might be useful for aggregated logs.

I could have been more clear on the best practices thing, sorry about that. You said it well with, "our goal is to provide samples with minimal dependencies." That's the best practice, with one example being choosing log over glog, not because log is better, but because it's one less dependency.

I may be misunderstanding your intent though. If you only want to prefer log for current samples, and allow future samples to ignore this preference, then maybe it shouldn't be mentioned at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@grantr I misunderstood you before and I thought the best practices were aimed at the users of Elafros, but not sample authors. It definitely makes sense to add such a section for sample authors. Thanks, I will add that momentarily and send an update.

Copy link
Contributor

@grantr grantr left a comment

Choose a reason for hiding this comment

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

Thanks @mdemirhan!

/lgtm

@google-prow-robot google-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 4, 2018
@google-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: grantr, mdemirhan
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: vaikas-google

Assign the PR to them by writing /assign @vaikas-google in a comment when ready.

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mdemirhan mdemirhan merged commit 5dc2be2 into knative:master Apr 4, 2018
@mdemirhan mdemirhan deleted the mdemirhan/glog branch April 4, 2018 22:09
@vaikas
Copy link
Contributor

vaikas commented Apr 4, 2018

@mdemirhan you shouldn't need to set up the DNS to test the webhook. Just creating ela resources will hit the webhook.

Edit: Misread, you were talking about the gitwebhook, ack :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants