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

[pkg] rotate log file #3638

Merged
merged 6 commits into from
Sep 30, 2022
Merged

[pkg] rotate log file #3638

merged 6 commits into from
Sep 30, 2022

Conversation

huof6829
Copy link
Contributor

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #2661

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Code refactor or improvement
  • [] Breaking change (fix or feature that would cause a new or changed behavior of existing functionality)
  • [] This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • [] make test
  • [] fullsync
  • [] Other test (please specify)

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • [] My code follows the style guidelines of this project
  • [] I have performed a self-review of my code
  • [] I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • [] My changes generate no new warnings
  • [] I have added tests that prove my fix is effective or that my feature works
  • [] New and existing unit tests pass locally with my changes
  • [] Any dependent changes have been merged and published in downstream modules

@huof6829 huof6829 requested a review from a team as a code owner September 14, 2022 12:09
@codecov
Copy link

codecov bot commented Sep 14, 2022

Codecov Report

Merging #3638 (a0fef85) into master (e9732a1) will decrease coverage by 0.32%.
The diff coverage is 77.90%.

@@            Coverage Diff             @@
##           master    #3638      +/-   ##
==========================================
- Coverage   74.95%   74.62%   -0.33%     
==========================================
  Files         269      264       -5     
  Lines       23819    23687     -132     
==========================================
- Hits        17854    17677     -177     
- Misses       5039     5083      +44     
- Partials      926      927       +1     
Impacted Files Coverage Δ
db/trie/mptrie/node.go 100.00% <ø> (ø)
ioctl/newcmd/action/action.go 79.62% <ø> (+0.09%) ⬆️
ioctl/newcmd/node/nodedelegate.go 70.19% <0.00%> (-0.95%) ⬇️
ioctl/newcmd/node/nodeprobationlist.go 90.90% <0.00%> (-4.33%) ⬇️
action/protocol/execution/evm/evm.go 44.57% <26.66%> (-0.86%) ⬇️
db/trie/mptrie/hashnode.go 36.36% <41.17%> (-54.55%) ⬇️
db/trie/mptrie/merklepatriciatrie.go 78.73% <46.80%> (-12.70%) ⬇️
db/trie/mptrie/leafiterator.go 62.06% <50.00%> (ø)
action/protocol/execution/evm/evmstatedbadapter.go 65.87% <64.28%> (-0.04%) ⬇️
db/trie/mptrie/extensionnode.go 89.89% <94.28%> (-3.09%) ⬇️
... and 14 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@huof6829
Copy link
Contributor Author

After reach MaxSize MB, s.log will be rotated auto. After MaxAge days it will be removed auto.
The rotated log's name has the created time like : /var/log/s-2022-09-14T19-27-26.648.log

@Liuhaai
Copy link
Member

Liuhaai commented Sep 14, 2022

pls fix the log rotate issue with logrotate

@huof6829
Copy link
Contributor Author

pls fix the log rotate issue with logrotate

It's a linux tool. cannot use in win/mac

pkg/log/log.go Outdated
RedirectStdLog bool `json:"stdLogRedirect" yaml:"stdLogRedirect"`
EcsIntegration bool `json:"ecsIntegration" yaml:"ecsIntegration"`
Zap *zap.Config `json:"zap" yaml:"zap"`
Lumberjack *lumberjack.Logger `json:"lumberjack" yaml:"lumberjack"`
Copy link
Member

Choose a reason for hiding this comment

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

move to end

stdLogRedirect: true
lumberjack:
Copy link
Member

Choose a reason for hiding this comment

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

is this included in Alpine image?

Copy link
Member

Choose a reason for hiding this comment

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

or test if logrotate can work or not

@huof6829
Copy link
Contributor Author

crond service in container cannot autorun after docker run, logrotate depends on crond and cannot effect also. I config crond autorun and correct log date-format. I test it in local, log rotate successfully. the rotate-log is like : /var/log/s-2022-09-20.log

@CoderZhi
Copy link
Collaborator

@xianhuawei @huof6829 could you try this PR in k8s?

@huof6829
Copy link
Contributor Author

@xianhuawei @huof6829 could you try this PR in k8s?

ok, we will run in testnet

@huof6829
Copy link
Contributor Author

Run smoothly in testnet.
WechatIMG43

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@huof6829 huof6829 merged commit 18064e2 into iotexproject:master Sep 30, 2022
@huof6829 huof6829 deleted the log_rotate branch September 30, 2022 07:04
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.

Better Management of Log Files
5 participants