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

Feat: standardize logging #213

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Feat: standardize logging #213

wants to merge 1 commit into from

Conversation

ctlong
Copy link
Member

@ctlong ctlong commented Jan 29, 2023

Description

Standardize logging across agents.

Checklist:

  • This PR is being made against the main branch, or relevant version branch
  • I have made corresponding changes to the documentation
  • I have added testing for my changes

If you have any questions, or want to get attention for a PR or issue please reach out on the #logging-and-metrics channel in the cloudfoundry slack

@chombium
Copy link
Contributor

Hi @ctlong,

I really like the idea of standardizing the logging, I have three questions though:

  1. Why not using some logging library? Do you think that we need our custom solution, because we have some special logging needs?
  2. What's the meaning of a session? Can you give some examples how it should be used?
  3. I was expecting to see a log level: ERROR, INFO, DEBUG etc. as well and based on the level, the appropriate messages to be written to the log. Do you plan to add log level as well?

This looks like a wip to me, so I want to know what are the ideas how it should work ;)

@ctlong
Copy link
Member Author

ctlong commented Feb 2, 2023

@chombium this is definitely a WIP 😅. I left it in draft format for that reason, but also didn't expect anyone to look at it so quickly.

As to your questions:

  1. I'm happy to use a logging library instead. I started this way partly because I was curious to see if this was easy without a logging library, and partly because it was hard to choose a logging library out of everything available.
  2. In my head starting a session represents entering some area of the code, and adding a new prefix to the existing prefixes to represent that. (i.e. after logr := logr.Session("egress"), logr.Infof("my log line") will output <timestamp> INFO egress: my log line)
  3. This code already includes log levels, check out the individual methods. (i.e. Infof, Errorf)

@chombium
Copy link
Contributor

chombium commented Feb 7, 2023

Thanks for the clarification @ctlong. Thb I'm also not sure if we need some logging library...

When I've written about log levels, I meant that the user sets a log level and it doesn't get the log messages which are with lower priority than this level. A parameter with which the "log chattiness" of the app can be controlled.
For example:

  • ERROR: prints only errors
  • WARNING: prints errors and warnings
  • INFO: prints errors, warnings and info messages
  • DEBUG: prints everything

@ctlong
Copy link
Member Author

ctlong commented Feb 8, 2023

When I've written about log levels, I meant that the user sets a log level and it doesn't get the log messages which are with lower priority than this level. A parameter with which the "log chattiness" of the app can be controlled.
For example:

ERROR: prints only errors
WARNING: prints errors and warnings
INFO: prints errors, warnings and info messages
DEBUG: prints everything

Thanks for clarifying! Yeah, I agree that makes sense compared to using conditionals throughout code to check whether to run an log.Infof or whatever 😄.

@ctlong
Copy link
Member Author

ctlong commented Feb 8, 2023

Just amended the commit to include log levels.

@ctlong ctlong changed the title Standardize logging Feat: standardize logging Feb 27, 2023
@ctlong
Copy link
Member Author

ctlong commented Mar 23, 2023

Now planning to wait until structured logging comes to the Go standard library (expected in Go 1.21).

@ctlong ctlong moved this from Inbox to Issue - Triage complete. Needs fix. in DEPRECATED App Platform - Logging and Metrics Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Waiting for Changes | Open for Contribution
DEPRECATED App Platform - Logging and...
Issue - Triage complete. Needs fix.
Development

Successfully merging this pull request may close these issues.

None yet

2 participants