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

Add support for automatic removal of old logs #432

Merged
merged 14 commits into from
Nov 1, 2019

Commits on Feb 17, 2019

  1. Add support for automatic removal of old logs

    GetOverdueLogNames(string log_directory, int days) will check all
    filenames under log_directory, and return a list of files whose last modified time is
    over the given days (calculated using difftime()).
    
    So that we can easily for unlink all files stored in the returned vector.
    aesophor committed Feb 17, 2019
    Configuration menu
    Copy the full SHA
    5747841 View commit details
    Browse the repository at this point in the history

Commits on Feb 18, 2019

  1. Configuration menu
    Copy the full SHA
    4dd1386 View commit details
    Browse the repository at this point in the history

Commits on Aug 21, 2019

  1. Configuration menu
    Copy the full SHA
    d8d0c14 View commit details
    Browse the repository at this point in the history
  2. embed dirent.h in project

    aesophor committed Aug 21, 2019
    Configuration menu
    Copy the full SHA
    55cfc38 View commit details
    Browse the repository at this point in the history
  3. Add support for automatic removal of old logs

    In this commit, at the end of LogFileObject::Write,
    it will perform clean up for old logs.
    
    It uses GetLoggingDirectories() and for each file in each
    directory, it will check if a file is a log file produced by glog.
    If it is, and it is last modified 3 days ago, then it will unlink()
    this file. (It will only remove the project's own log files,
    it won't remove the logs from other projects.)
    
    Currently it is hardcoded to 3 days, I'll see if this can be
    implemented in a more flexible manner.
    aesophor committed Aug 21, 2019
    Configuration menu
    Copy the full SHA
    7af21ae View commit details
    Browse the repository at this point in the history
  4. Implement old log cleaner

    The log cleaner can be enabled and disabled at any given time.
    By default, the log cleaner is disabled.
    
    For example, this will enable the log cleaner and delete
    the log files whose last modified time is >= x days
    google::EnableLogCleaner(x days);
    
    To disable it, simply call
    google::DisableLogCleaner();
    
    Please note that it will only clean up the logs produced for
    its own project, the log files from other project will be untouched.
    aesophor committed Aug 21, 2019
    Configuration menu
    Copy the full SHA
    cbfd1e3 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    5eef96f View commit details
    Browse the repository at this point in the history
  6. logging: log_cleaner: remove the range-based loops

    Also replaced the hardcoded overdue days with the correct variable.
    aesophor committed Aug 21, 2019
    Configuration menu
    Copy the full SHA
    b8a61d7 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    6dc3e0f View commit details
    Browse the repository at this point in the history

Commits on Aug 22, 2019

  1. logging: log_cleaner: Remove redundant filename stripping

    Previously the full path to a file is passed into IsGlogLog(),
    and then std::string::erase() is used to get the filename part.
    If a directory name contains '.', then this function will be unreliable.
    
    Now only the filename it self is passed into IsGlogLog(),
    so this problem will be eradicated.
    aesophor committed Aug 22, 2019
    Configuration menu
    Copy the full SHA
    6cb55b2 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    3d715d7 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4136403 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    a1a9dc8 View commit details
    Browse the repository at this point in the history
  5. logging: IsGlogLog: match filename keyword by keyword

    Splitting a filename into tokens by '.' causes problems
    if the executable's filename contains a dot.
    
    Filename should be matched keyword by keyword in the following
    order:
    1. program name
    2. hostname
    3. username
    4. "log"
    aesophor committed Aug 22, 2019
    Configuration menu
    Copy the full SHA
    77a1f39 View commit details
    Browse the repository at this point in the history