Skip to content

feat: Enable line numbers for logs when using RUST_LOG#3211

Merged
Bravo555 merged 1 commit intothin-edge:mainfrom
Bravo555:improve/log-line-numbers
Oct 29, 2024
Merged

feat: Enable line numbers for logs when using RUST_LOG#3211
Bravo555 merged 1 commit intothin-edge:mainfrom
Bravo555:improve/log-line-numbers

Conversation

@Bravo555
Copy link
Copy Markdown
Member

@Bravo555 Bravo555 commented Oct 29, 2024

Proposed changes

RUST_LOG can be used to more precisely control logging configuration and is undocumented and used by developers. For this reason, I think when using it we can enable line numbers to show the location of the log statement to more easily find relevant code.

Example (issue #2739):

Start tedge-mapper with RUST_LOG:

RUST_LOG=info tedge-mapper c8y

Publish a message to trigger some error log:

tedge mqtt pub -r te/device/child1///cmd/config_update ''

tedge-mapper-c8y output:

2024-10-29T09:58:14.710505474Z ERROR c8y_mapper_ext::converter: crates/extensions/c8y_mapper_ext/src/converter.rs:139: Mapping error: EOF while parsing a value at line 1 column 0

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue


Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s)
  • I ran cargo fmt as mentioned in CODING_GUIDELINES
  • I used cargo clippy as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

RUST_LOG can be used to more precisely control logging configuration and
is undocumented and used by developers. For this reason, I think when
using it we can enable line numbers to show the location of the log
statement to more easily find relevant code.

Example (issue thin-edge#2739):

```sh
tedge mqtt pub -r te/device/child1///cmd/config_update ''
```

tedge-mapper-c8y output:

```
2024-10-29T09:58:14.710505474Z ERROR c8y_mapper_ext::converter: crates/extensions/c8y_mapper_ext/src/converter.rs:139: Mapping error: EOF while parsing a value at line 1 column 0
```

Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
@Bravo555 Bravo555 added the theme:developer-exp Theme: improve developer experience label Oct 29, 2024
@Bravo555 Bravo555 temporarily deployed to Test Pull Request October 29, 2024 10:04 — with GitHub Actions Inactive
@codecov
Copy link
Copy Markdown

codecov bot commented Oct 29, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...mon/tedge_config/src/system_services/log_config.rs 0.00% 2 Missing ⚠️
Additional details and impacted files

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Copy Markdown
Contributor

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
525 0 2 525 100 1h32m59.233865s

Copy link
Copy Markdown
Contributor

@didier-wenzek didier-wenzek left a comment

Choose a reason for hiding this comment

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

Approved

@Bravo555 Bravo555 added this pull request to the merge queue Oct 29, 2024
Merged via the queue into thin-edge:main with commit 422d710 Oct 29, 2024
@reubenmiller reubenmiller changed the title Enable line numbers for logs when using RUST_LOG feat: Enable line numbers for logs when using RUST_LOG Dec 16, 2024
@Bravo555 Bravo555 deleted the improve/log-line-numbers branch June 3, 2025 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme:developer-exp Theme: improve developer experience

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants