Skip to content

Add support for deleting old logs #36

Closed
@isaoa

Description

Hi,
Can we add a support for deleting old logs?
As of now, log just keeps accumulating until it takes entire disk space.
If we set the max log size to 10MB, glog keeps generating 10MB log files never deleting.
I'd like to keep only latest 4 logs (of 10MB or smaller).

I know there are tools which can be run to do the cleanup such as logrotate.
We make Windows DLL which runs on embedded machine made by another company. We don't have control on this embedded machine, so we cannot run any program to rotate the log.

I've added RotateLogFile function which checks for number of log files and deletes old logs.
RotateLogFile is run in LogFileObject::Write as it log is rolled over and new log file is created (when max_log_size is reached).

so if we have following 4 logs,

log_20150617-141944.8600
log_20150618-166949.8600
log_20150619-119953.8600
log_20150620-107957.8600

And if a new one is created, the oldest one is deleted leaving 4 logs
log_20150617-141944.8600 <-Deleted
log_20150618-163949.8600
log_20150619-112953.8600
log_20150620-101957.8600
log_20150621-103957.8600 <-- Created

Has this feature been considered before? Can you add this?

Thanks,

Isao

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions