Skip to content

FileWriter MaxBackups description is misleading :v #109

@hisorange

Description

@hisorange

Heyho,

Awesome lib! Just found a bit of a feature description mismatch.

The FileWriter claims that MaxBackups=0 keeps all old log files, but the code never had this option implemented, setting the value to 0 actually removes everything but the newest.

Checked out the history, and that was always the behavior. And I think allowing an infinitely growing log trail is more dangerous than not. So, my only recommendation would be to update phrasing as it seems like that everyone was using it with some value until now.

Relevant source snippet

if w.Cleaner != nil {
	w.Cleaner(w.Filename, w.MaxBackups, matches)
} else {
	for i := 0; i < len(matches)-w.MaxBackups-1; i++ {
		os.Remove(filepath.Join(dir, matches[i].Name()))
	}
}

Oh, and thanks for the hard work, and have a wonderful day!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions