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

geth: Implement log rotation using lumberjack (#229) #524

Closed
wants to merge 1 commit into from
Closed

geth: Implement log rotation using lumberjack (#229) #524

wants to merge 1 commit into from

Conversation

pedropombeiro
Copy link
Contributor

geth: Implement log rotation using lumberjack.

Introduce a lumberjack layer that rotates the logs every 2MB (16MB in debug log level) or 28 days. A maximum of 3 backup log files are kept.

Closes #229

geth/log/log.go Outdated
return err
logger.ljWriter = &lumberjack.Logger{
Filename: filename,
MaxBackups: 3, // number of backups
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: maybe we could describe it as // number of backup files to denote that backup = file in this case. It may not be obvious.

handler, err := log.FileHandler(filename, log.TerminalFormat(false))
if err != nil {
return err
logger.ljWriter = &lumberjack.Logger{
Copy link
Contributor

Choose a reason for hiding this comment

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

How does lubmerjack report problems with e.g. creating a file? We used to have some issues with creating logs files via status-go, thus we have this code: https://github.com/status-im/status-react/blob/6d5251ad2072c949c0608acde4144d4f4cff0d11/modules/react-native-status/ios/RCTStatus/RCTStatus.m#L221-L226.

I will try to test a case when a new log file is created before merging this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lumberjack errors will not be reported, since the geth logger discards the return value from io.Writer. There's no reason why keeping the code you mentioned wouldn't work though, unless I'm missing something. The code you mentioned is meant to address the scenario where a user/something changes the permissions on a log file, right?

By the way, noticed that I used v1 of lumberjack, but a v2 is available and recommended, so I'll update that.

Copy link
Contributor

Choose a reason for hiding this comment

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

There's no reason why keeping the code you mentioned wouldn't work though, unless I'm missing something. The code you mentioned is meant to address the scenario where a user/something changes the permissions on a log file, right?

iOS is a very specific platform. I don't remember what exactly was the problem but ultimately the log file needed to be created in Objective-C before status-go started using it. We just need to test it as a whole and figure out a better solution if there will be a problem.

By the way, noticed that I used v1 of lumberjack, but a v2 is available and recommended, so I'll update that.

👍

@divan
Copy link
Contributor

divan commented Jan 17, 2018

I believe we don't have to manage log rotation from within our code and the original issue is outdated. We use logs only for debug/test sessions and benefits of using log rotation do not cover the costs of supporting this code. I've never seen a situation where our log fills up all the disk space in practice either.

@dshulyak dshulyak mentioned this pull request Jan 24, 2018
@mandrigin
Copy link
Contributor

Closing this after discussion with @pombeirp

@mandrigin mandrigin closed this Feb 5, 2018
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.

5 participants