Commit Graph

88 Commits

Author SHA1 Message Date
Santiago Gil
0cbc235297 Add support for setting a custom prefix format 2021-04-09 20:11:44 +02:00
xiaobfly
4fca1b9673 fixed filename extension 2021-04-01 17:21:19 +08:00
Sergiu Deitsch
7f8a48b3bf
Merge pull request #595 from r-barnes/richard/ctr_type_fix
Change counter type to uint64
2021-03-31 09:43:14 +02:00
Richard Barnes
bf3e5a80ae Change counter type to uint64 2021-03-31 02:28:29 +02:00
Sergiu Deitsch
01f3e543e3 use C++ headers 2021-03-31 02:24:22 +02:00
Sergiu Deitsch
3533c22d21 handle --max_log_size overflow 2021-03-30 23:16:40 +02:00
Sergiu Deitsch
4fa737b62a
Merge pull request #400 from guoyuhong/fixWebmailer
Fix logmailer problem for dynamic lib use of glog.
2021-02-13 11:57:07 +01:00
Sergiu Deitsch
7bba6030c2
Merge pull request #592 from aesophor/fix-logcleaner-file-ext
src/logging.cc: Make LogCleaner aware of filename extension (#589)
2021-02-13 11:48:23 +01:00
Marco Wang
fe1287dd5d src/logging.cc: Fix a typo in comment
Signed-off-by: Marco Wang <m.aesophor@gmail.com>
2020-10-10 00:06:11 +08:00
Marco Wang
431d74c802 src/logging.cc: Make LogCleaner aware of filename extension (#589)
Previously, LogCleaner::IsLogFromCurrentProject() did not consider
the custom file extension set with SetLogFilenameExtension().

This PR fixes it.

Signed-off-by: Marco Wang <m.aesophor@gmail.com>
2020-10-09 22:40:12 +08:00
Marco
d82641f709
Merge branch 'master' into encapsulate-log-cleaner 2020-10-03 09:52:23 +08:00
Yuhong Guo
b55437ac10 Fix logmailer problem for dynamic lib. 2020-10-03 01:01:05 +02:00
Sergiu Deitsch
f28ae960c3
Merge pull request #573 from msamoila/msamoila-use-utc-time
Add FLAGS_log_utc_time; when 'true' the time will be written in log in UTC, resolves #571
2020-09-29 22:25:02 +02:00
Sergiu Deitsch
fa0d50f9fc
Merge pull request #570 from jiuqiant/patch-1
Connect glog to Andorid logging API
2020-09-29 22:22:12 +02:00
Sergiu Deitsch
40ab822812
Merge pull request #438 from d-uspenskiy/master
Add extra information in log file header (application build/version, actual duration time)
2020-09-29 22:18:24 +02:00
Sergiu Deitsch
8ee2bb5b31
Merge pull request #553 from huangqinjin/android
Output to logcat on Android
2020-09-29 22:11:54 +02:00
M Samoila
909069ea82 Add FLAGS_log_utc_time; when 'true' the time will be written in log in UTC 2020-09-01 10:55:53 -07:00
Jiuqiang Tang
64650ef2ed
Connect glog to Andorid logging API
In LogMessage::Flush(), write to __android_log_write() so that the messages can be seen via "adb logcat".

This is already a patch in the Google MediaPipe's repo: https://github.com/google/mediapipe/blob/master/third_party/com_github_glog_glog_9779e5ea6ef59562b030248947f787d1256132ae.diff.
2020-08-21 20:24:00 -07:00
huangqinjin
0a12a96cee Output to logcat on Android 2020-05-11 23:59:00 +08:00
huangqinjin
d8998fe4f6 Make message text null-terminated 2020-05-11 22:33:17 +08:00
Dmitry Uspenskiy
ceb7163880 Add extra information in log file header (application build/version, actual duration time) 2020-03-25 09:55:32 +01:00
Sergiu Deitsch
28321d8959
Merge pull request #503 from alexsmac/fix-custom-logger-deletion
Fix missing deletion of custom Logger
2020-03-25 09:52:26 +01:00
Marco
5b4fb63d27
Prepend the year to each glog line (#516) (#530)
* Prepend the year to each glog line (#516)

This PR fixes issue #516 by prepending the year to each glog line.

Previous format of each line in a log file:
[IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg

New format:
[IWEF]yyyymmdd hh:mm:ss.uuuuuu threadid file:line] msg

* Fix logging_unittest for PR #530

Since the format of each glog line has been changed,
the logging_unittest must also be updated.
2020-03-25 09:36:28 +01:00
Marco Wang
36fa99ba2c src/logging.cc: check the entire filename format 2019-12-09 08:48:41 +08:00
Alex Stewart
0a6704b439 Fix missing deletion of custom Logger
- If the user specifies a custom Logger via SetLogger(), the docs state
  that the logging module takes ownership of it.  Prior to this change,
  the logging library was not deleting a custom logger when the
  LogDestination which owns it was destroyed.
2019-12-02 16:55:08 +00:00
Marco Wang
7764e4a8b4 src/logging.cc: match logfile with base_filename 2019-12-01 22:06:12 +08:00
Marco Wang
3b5f2807f4 src/logging.cc: encapsulate log cleaner 2019-12-01 19:12:06 +08:00
Ezequiel Lara Gomez
58d7f873dc Added fixed log name support, take 2 (#489)
* 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
2019-11-06 12:49:01 +01:00
yww
e58e596f13 src/logging.cc: fix wrong assignment 2019-11-04 14:35:26 +08:00
Sergiu Deitsch
e0a2521e3d
Merge pull request #482 from google/revert-19-master
Revert "Added fixed log name support"
2019-11-01 13:26:53 +01:00
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
Sergiu Deitsch
15fb5ca5b6
Revert "Added fixed log name support" 2019-11-01 12:01:41 +01:00
Sergiu Deitsch
5792d60d68
Merge pull request #441 from asekretenko/useconds
Extend the LogSink interface to be able to pass microseconds
2019-10-31 23:43:50 +01:00
Sergiu Deitsch
44f6079fad
Merge pull request #19 from ezegomez/master
Added fixed log name support
2019-10-31 23:40:55 +01:00
Sergiu Deitsch
1227cf4dab
Merge pull request #312 from ruslo/pr.api21
Fix build for Android API < 21
2019-10-31 22:52:04 +01:00
Andrei Sekretenko
94a54120de Extended the LogSink interface to be able to pass microseconds. 2019-03-27 18:27:31 +01:00
Peter Mutsaers
e5588de96d remove time from raw logging 2019-01-29 23:38:03 +01:00
Victor Costan
0989ffadb8 Fix unused variable warning in GCC. 2018-12-25 16:54:08 -08:00
Roman Gershman
6adf6d7ae5 fix debug build using gcc -fsanitize=undefined (#374) 2018-12-12 10:16:49 +01:00
NeroBurner
06a8ee0976 logging: fix basetsd on case sensitive sytems 2018-06-01 14:50:06 +02:00
Ruslan Baratov
d064ab8d0a Fix build for Android API < 21 2018-04-22 23:54:24 +03:00
Sergiu Deitsch
2f493d292c
Merge pull request #302 from Nazg-Gul/missing-prototype
Resolve missing prototype warning
2018-03-21 13:45:06 +01:00
Sergey Sharybin
e35bb111c3 konsole family of terminfo supports colored output
Glog was missing colored output when running in terminal
who is set to konsole* TERM, even though the terminal
itself supports colored output.

Add extra terminfo to the check function, so now output
from Glog is properly colored.
2018-03-20 09:49:07 +01:00
Fumitoshi Ukai
9f8a9a9a0d Shell escape arguments to /bin/mail. 2017-10-31 13:04:26 +09:00
Sergiu Deitsch
2fe6508e53 fixed gcc logging failure 2017-10-11 00:45:08 +02:00
Shinichiro Hamaji
a835da8e08 Merge pull request #158 from sergiud/zero-allocation
[RFC] reduce heap memory allocations to zero
2017-07-06 14:58:37 +09:00
Shinichiro Hamaji
96f6656551 Merge pull request #145 from pixelb/rate-limit-posix-fadvise
rate limit calls to posix_fadvise()
2017-07-06 14:52:13 +09:00
Hans-Andreas Engel
2df0ca34aa reduce memory allocations to zero 2017-07-06 00:02:38 +02:00
Andrew Schwartzmeyer
d1f49ba5aa Support signal handler on Windows 2017-06-27 10:50:20 -07:00
Pádraig Brady
dacd296796 rate limit calls to posix_fadvise()
There can be a large kernel overhead involved in POSIX_FADV_DONTNEED.
There is no point in calling this per item logged, so rate limit
to at most once per 2MiB written.

With a simple test program that logs 100K items at WARNING level:

Before:

  $ time strace -c -e fadvise64 log.test \
    -log_dir=/dev/shm -logtofiles=true -logtostderr=false
  % time     seconds  usecs/call     calls    errors syscall
  ------ ----------- ----------- --------- --------- ----------------
  100.00   12.522509         125     99957           fadvise64
  ------ ----------- ----------- --------- --------- ----------------
  real    0m52.671s
  user    0m2.194s
  sys     0m44.022s

After:

  $ time strace -c -e fadvise64 log.test \
    -log_dir=/dev/shm -logtofiles=true -logtostderr=false

  % time     seconds  usecs/call     calls    errors syscall
  ------ ----------- ----------- --------- --------- ----------------
  100.00    0.000759         152         5           fadvise64
  ------ ----------- ----------- --------- --------- ----------------
  real    0m4.206s
  user    0m1.436s
  sys     0m3.153s

Fixes issue #84
2016-12-09 19:45:34 +00:00