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(log): make Lmodule option as deprecated and add Lintermediatefile model to enhance log library #91

Merged
merged 6 commits into from
Dec 14, 2023

Conversation

CarlJi
Copy link
Contributor

@CarlJi CarlJi commented Nov 28, 2023

This PR mainly focus:

  • Remove the Lmodule model, which appears to be adapted to the old Go path style. Currently, it is causing a bug where the entire file path is printed even when the Lshortfile option is used if the code path does not include "src".
  • Introduce the Lintermediatefile model and set it as the default option for Std Logger.

Now, when using the Std logger, the output prefix will look like the following, which includes the last two path elements of the file. This change aims to make it more IDE-friendly.

2023/11/29 15:35:29.223563 [INFO] log/logext_test.go:81: hello world

Additionally, if the compilation includes the -trimpath parameter, the output prefix will exclude the module path prefix, resulting in a cleaner file path display.

Copy link

codecov bot commented Nov 28, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (1628f8b) 77.85% compared to head (169cb19) 71.70%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #91      +/-   ##
==========================================
- Coverage   77.85%   71.70%   -6.15%     
==========================================
  Files          23       24       +1     
  Lines        1644     1930     +286     
==========================================
+ Hits         1280     1384     +104     
- Misses        324      499     +175     
- Partials       40       47       +7     

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

@CarlJi CarlJi force-pushed the log_enhance branch 2 times, most recently from 2ab2da3 to 1fd3ac7 Compare November 29, 2023 07:18
@CarlJi CarlJi requested a review from xushiwei November 29, 2023 07:42
@CarlJi CarlJi changed the title feat(log): remove Lmodule and add Lintermediatefile model to enhance log library feat(log): make Lmodule option as deprecated and add Lintermediatefile model to enhance log library Dec 11, 2023
log/logext.go Outdated
Lshortfile // final file name element and line number: d.go:23. overrides Llongfile
// Deprecated: recommend to use Lintermediatefile option instead.
Lmodule // module name
Lintermediatefile // final file format output is typically in the format c/d.go:23, which includes the last two paths. If the compilation includes the '-trimpath' parameter, this format will just exclude the module path prefix.
Copy link
Contributor

Choose a reason for hiding this comment

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

don't change values of existed symbols such as Llevel.

@xushiwei xushiwei merged commit bae6651 into qiniu:main Dec 14, 2023
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants