Skip to content

Add Context to logging for JSON and TEXT formats #7705

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

Merged
merged 4 commits into from
Apr 28, 2025
Merged

Conversation

AlexFenlon
Copy link
Contributor

Proposed changes

  • Add source to JSON and Text log output to give context similar to glog

JSON
before

{"time":"2025-04-25T15:50:33.813809341Z","level":"DEBUG","msg":"The queue has 6 element(s)"}

after

{"time":"2025-04-28T09:38:53.881957803Z","level":"DEBUG","source":{"file":"task_queue.go","line":77},"msg":"The queue has 6 element(s)"}

TEXT
before

time=2025-04-28T09:39:36.565Z level=DEBUG msg="The queue has 6 element(s)"

after

time=2025-04-25T15:57:36.855Z level=DEBUG source=task_queue.go:77 msg="The queue has 6 element(s)"

Solves: #7574

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

@AlexFenlon AlexFenlon requested a review from a team as a code owner April 28, 2025 11:25
@AlexFenlon AlexFenlon linked an issue Apr 28, 2025 that may be closed by this pull request
@github-actions github-actions bot added the go Pull requests that update Go code label Apr 28, 2025
@AlexFenlon AlexFenlon moved this from Todo ☑ to In Review 👀 in NGINX Ingress Controller Apr 28, 2025
Copy link

codecov bot commented Apr 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 52.31%. Comparing base (ed19da4) to head (49cd1d6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7705      +/-   ##
==========================================
+ Coverage   52.29%   52.31%   +0.01%     
==========================================
  Files          89       89              
  Lines       21326    21338      +12     
==========================================
+ Hits        11153    11163      +10     
- Misses       9707     9709       +2     
  Partials      466      466              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AlexFenlon AlexFenlon merged commit f0a5755 into main Apr 28, 2025
81 checks passed
@AlexFenlon AlexFenlon deleted the logging-with-source branch April 28, 2025 13:18
@AlexFenlon AlexFenlon added the enhancement Pull requests for new features/feature enhancements label Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Pull requests for new features/feature enhancements go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: logFormat=json creates events without contextual information
3 participants