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

Default shift values not available to logfiles set from #reopen #55

Open
titusfortner opened this issue Mar 26, 2021 · 0 comments
Open

Comments

@titusfortner
Copy link

This code correctly sets @shift_age to 7 and @shift_size to 1048576

Logger::LogDevice.new(@filename)

This code will end up with those instance variables set to nil

logger = Logger::LogDevice.new(STDERR)
logger.reopen(@filename)

This could be fixed in LogDevice#initialize by setting the defaults outside of the if @filename condition, or repeating the logic in the LogDevice#reopen.

It would also make sense, though, if you can update the output to be able to also change those values if desired. This could be done by adding an attr_writer for them.

The best course of action would be to support adding/changing the values when a new output is specified. I'm adding a PR with my recommendation.

My specific use case involves a library I'm using instantiating a logger instance for me with STDOUT, and I want to change the output to a file with useful shift values.

nobu added a commit that referenced this issue Oct 9, 2024
Keep parameters already set, and do not clear at reopen to a non-file
device.

Fix #55.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant