* Added fixed log name support, take 2
See https://code.google.com/p/google-glog/issues/detail?id=209 and former https://github.com/google/glog/pull/19 - this is an updated version of that patch.
It adds a flag that allows to switch behavior from base_filename + filename_extension + time_pid_string to base_filename + filename_extension, while still defaulting to the current behavior to avoid breakage in existing code. This change would allow easier log rotation schemes and better control on what's written on disk.
* Ifdef away fcntl on mingw
* Use the defined HAVE_FCNTL instead
* ifdef away tests as well
add have_sys_wait for wait() on mingw.
* OS_WINDOWS bug in fseeking to the end, only triggered here
* 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"
When glog 0.4.0 is built using musl instead of glibc, the compilation
for this test fails because musl doesn't provide execinfo.h, which sets
HAVE_STACKTRACE to false.
Tested by building glog with musl and verifying that the build succeeds
with this patch. [See https://github.com/openwrt/packages/pull/8583]
Signed-off-by: Amol Bhave <ambhave@fb.com>
for `&CheckStackAddress`, VisualStudio emits address of a trampoline like PLT,
not the actual address of `CheckStackTrace`.
We need address of `CheckStackTrace` to guess the address range of the function.
`static` function seems to return the actual address of the function.
Fixes#421
* Fix demangling template parameter packs
Clang 4.0.1-10 and gcc 7.3.0 both mangle the function "void add<int>(int)" as
"_Z3addIJiEEvDpT_". The template parameter pack is of the form
J <template-arg>* E
The opening character for a param pack could be either I or J, as libiberty
follows [1]. This change simply adds the J case.
[1] fbd263526a/libiberty/cp-demangle.c (L3209)
* Upstream Chromium local changes to symbolize.cc
Chromium has its own fork of symbolize.cc and symbolize.h, and it has
several not-yet-upstreamed changes, that are not specific to Chromium.
This patch upstreams such a changes.
Fixed google::FindSymbol reading past end of a section
3dae0a2d7d
Fix -INT_MIN integer overflow in itoa_r().
ac4d28e9cb
Add print_unsymbolized_stack_traces gn arg.
6a2726776f
Switch to standard integer types in base/.
9b6f42934e
* Add a build option to print unsymbolized traces
This PRINT_UNSYMBOLIZED_STACK_TRACES option to cmake, and
--enable-unsymbolized-traces option to autoconf.
ReadFromOffset in symbolize.cc used to call lseek() + read() to read
data from fd. However, the fd may be reused for multiple symbolize
requests from multiple threads, and causes a race around the fd read
offset.
This updates it to use pread() to resolve the race.
Fixed these warnings:
src/logging_unittest.cc: At global scope:
src/logging_unittest.cc:1081:13: warning: 'void MyCheck(bool, bool)' defined but not used [-Wunused-function]
static void MyCheck(bool a, bool b) {
^~~~~~~
src/logging_unittest.cc:1078:13: warning: 'void MyFatal()' defined but not used [-Wunused-function]
static void MyFatal() {
^~~~~~~
If the getpwuid_r method doesn't find an entry with the given ID, it
will still return success (0), but the *result will be set to NULL.
This checks the |result| value so it won't crash if it doesn't find
the entry.
This normally shouldn't ever happen, but it can somehow happen on
iOS simulators.