C++ implementation of the Google logging module
Go to file
Marco a6f7be14c6 Add support for automatic removal of old logs (#432)
* 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.

* Replaced the lines that require C++11

* embed dirent.h in project

* 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.

* 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.

* logging: log_cleaner: Use blackslash for windows dir delim

* logging: log_cleaner: remove the range-based loops

Also replaced the hardcoded overdue days with the correct variable.

* Add Marco Wang to AUTHORS and CONTRIBUTORS

* 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.

* logging: log_cleaner: improve readability

* Add google::EnableLogCleaner() to windows logging.h

* logging: log_cleaner: Remove perror message

* 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"
2019-11-01 12:20:11 +01:00
.bazelci Don't test on Ubuntu 14.04 (#446) 2019-04-24 10:48:51 +09:00
bazel Fix stacktrace on bazel build. (#347) 2019-04-12 10:09:41 +09:00
cmake glog: release 0.4.0 2019-01-22 21:00:50 +09:00
doc fix glog.html link to gflags repository 2018-07-02 11:54:44 +02:00
m4 build: remove automake temporaries 2018-12-19 11:54:06 +00:00
packages glog: release 0.4.0 2019-01-22 21:00:50 +09:00
src Add support for automatic removal of old logs (#432) 2019-11-01 12:20:11 +01:00
toolchains ci: add clang-cxx17 toolchain 2018-12-13 07:49:59 +01:00
.gitignore Build with Bazel. 2017-12-14 00:58:33 -08:00
.travis.ubuntu.sh ci: add appveyor and travis config 2018-10-15 13:34:52 +02:00
.travis.yml ci: add clang-cxx17 toolchain 2018-12-13 07:49:59 +01:00
appveyor.yml ci: add appveyor and travis config 2018-10-15 13:34:52 +02:00
AUTHORS Add support for automatic removal of old logs (#432) 2019-11-01 12:20:11 +01:00
autogen.sh build: remove NEWS realated things 2018-12-19 12:02:35 +00:00
BUILD Hide certain header files from the cc_library(). 2017-12-14 00:58:33 -08:00
ChangeLog Update ChangeLog to record release dates at least 2019-01-23 12:24:15 +09:00
CMakeLists.txt Changed the order of conditions 2019-09-02 13:28:18 +09:00
configure.ac glog: release 0.4.0 2019-01-22 21:00:50 +09:00
CONTRIBUTING.md Add the typical Google contributors and authors files. 2015-03-16 10:50:32 +00:00
CONTRIBUTORS Add support for automatic removal of old logs (#432) 2019-11-01 12:20:11 +01:00
COPYING A bug fix for Windows: Use GetSystemTimeAsFileTime instead of GetSystemTime. SYSTEMTIME's mSecond is not a unix time but like tm.tm_sec. 2009-04-09 07:49:44 +00:00
Dockerfile.ubuntu.template ci: add appveyor and travis config 2018-10-15 13:34:52 +02:00
glog-config.cmake.in cmake: do not introduce a policy stack in the package config 2018-02-23 10:16:24 +01:00
INSTALL update all README naming 2018-12-18 07:00:06 +00:00
libglog.pc.in Generation of pkg-config metadata file. 2009-04-10 05:49:58 +00:00
Makefile.am Merge pull request #88 from kekstee/master 2019-10-31 22:56:05 +01:00
README.md fix appveyor link (#424) 2019-01-28 14:06:21 +09:00
README.windows Update Windows readme for CMake 2017-07-26 11:35:04 -07:00
WORKSPACE Use gflags 2.2.2 in Bazel build 2018-11-19 09:57:51 +01:00

Build Status Grunt status

This repository contains a C++ implementation of the Google logging module. Documentation for the implementation is in doc/.

See INSTALL for (generic) installation instructions for C++: basically

./autogen.sh && ./configure && make && make install