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

Log files blank after restart #27

Closed
thepixelmonk opened this issue May 3, 2019 · 7 comments
Closed

Log files blank after restart #27

thepixelmonk opened this issue May 3, 2019 · 7 comments
Labels

Comments

@thepixelmonk
Copy link

I seem to be running into a strange issue. When I first start up my program, with an empty logs folder, it creates babblebot_rCURRENT.log and logs to the file. If I stop my program, and start it again, I now see babblebot_r00000.log and babblebot_rCURRENT.log in my logs folder, but both are completely blank and no new output is appended. I still see log output in stdout.

@thepixelmonk
Copy link
Author

For now I'm just gonna have to turn off rotation and have an ever-increasing log file for each run of the program. Something's really wonky with the rotation.

@emabee
Copy link
Owner

emabee commented May 6, 2019

May I ask which version you‘re using, and which platform? I‘ll check as soon as possible, right now I‘m on a trip without the equipment.

@emabee
Copy link
Owner

emabee commented May 6, 2019

The logger initialization would be helpful, too.

@thepixelmonk
Copy link
Author

I'm using version ^0.11.4 on arch linux. Initialization looks like:

Logger::with_env_or_str("babblebot")
        .log_to_file()
        .directory("logs")
        .rotate(1000000, Cleanup::Never)
        .duplicate_to_stderr(Duplicate::Warn)
        .start()
        .unwrap_or_else(|e| panic!("Logger initialization failed with {}", e));

@emabee
Copy link
Owner

emabee commented May 15, 2019

The bug occurs when rotate() was used without append().

Fixed with 0.11.5 which is available now on crates.io

@emabee emabee closed this as completed May 15, 2019
@thepixelmonk
Copy link
Author

thanks!

so it sounds like I should be using append() with rotate()? or else the log files will be cleared each time the program is run?

@emabee
Copy link
Owner

emabee commented May 16, 2019

This would have been a work-around with 0.11.4.
With 0.11.5, no logs will get lost:

  • with rotate and without append, the log file is rotated on each program start, and when the rotate-criterion is fulfilled
  • with rotate and append, logs are appended to an existing rCURRENT log file on program start, and rotation happens only when the rotate-criterion is fulfilled.

emabee added a commit that referenced this issue May 16, 2019
- add a corresponding set of unit tests to FileLogWriter (issue #28)
- fix some new clippies
@emabee emabee added the bug label Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants