Skip to content

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

@titusfortner

Description

@titusfortner

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions