Compare commits

..

901 Commits
v0.1 ... master

Author SHA1 Message Date
Ahmed Hani
4f007d9621
fix: truncate single log file upon reopening (#1143) 2025-02-20 17:49:33 +01:00
stdpain
7fcf58afa6
feat(signalhandler): add LWP ID to dump info (#1146)
LWP can help identifying the corresponding thread in a debugger more easily.
2025-02-16 15:51:26 +01:00
Rodrigo Queiro
ca390c4718
Revert "Add deprecation notice (#1150)" (#1152)
This reverts commit 575fb19092.
2025-02-04 10:05:23 +01:00
Rodrigo Queiro
575fb19092
Add deprecation notice (#1150) 2025-02-04 12:59:45 +09:00
dependabot[bot]
6c5c692c8e
build(deps): bump codecov/codecov-action from 4 to 5 (#1140)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4 to 5.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v4...v5)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-18 18:01:35 +01:00
Takeshi Watanabe
1f0f3d6829
fix(cmake): enable symbolization on macOS (#1138) 2024-11-05 16:22:00 +01:00
Rodrigo Queiro
2075ae813b
Migrate to rules_cc (#1136)
See #1135. Not sure if this will work because the error only repros on
Windows with a specific Bazel version.
2024-10-16 10:08:53 +02:00
Sergiu Deitsch
de309c08c0
fix(clang-tidy): remove deprecated option (#1132) 2024-09-14 13:08:24 +02:00
Yun Peng
be06647ac2
fix(bazel): specify dependencies in MODULE.bazel (#1131)
With WORKSPACE disabled, all dependencies must be specified in MODULE.bazel.
2024-09-14 12:35:18 +02:00
kang jinci
b3b9eb987f
chore: add MODULE.bazel.lock to .gitignore (#1120) 2024-08-03 09:45:25 +02:00
Sergiu Deitsch
2714c2a258
Merge branch '0.7.x' 2024-08-02 21:54:14 +02:00
Sergiu Deitsch
6d92a2e5a1
bump version patch 2024-08-02 21:53:11 +02:00
Sergiu Deitsch
6703865b78
Merge branch '0.7.x' 2024-08-02 21:47:32 +02:00
Shuai Zhang
175b54d4fa
feat(bazel): enable symbolization (#1116)
Symbolization support on Linux and BSD requires link.h which is usually
provided by the GNU C Library (glibc). Assume the header to be present
at all times by unconditionally defining HAVE_SYMBOLIZE on the
corresponding platforms.
2024-08-02 20:57:43 +02:00
Shuai Zhang
65896fe00d
feat(bazel): enable symbolization (#1116)
Symbolization support on Linux and BSD requires link.h which is usually
provided by the GNU C Library (glibc). Assume the header to be present
at all times by unconditionally defining HAVE_SYMBOLIZE on the
corresponding platforms.
2024-08-02 20:38:49 +02:00
Vertexwahn
570c7e4e1d
docs: update to Bzlmod usage (#1099) 2024-07-07 13:54:19 +02:00
Sergiu Deitsch
45f99f5e1a
make operator<< overload constexpr (#1106) 2024-06-13 23:01:34 +02:00
Sergiu Deitsch
2bd06dbe36
ci(deps): update to gtest 1.14 (#1105) 2024-06-13 01:40:15 +02:00
Sergiu Deitsch
409e19881d
cmake: require gtest 1.11 (#1104) 2024-06-13 01:16:50 +02:00
Sergiu Deitsch
0c10a02229
Merge branch '0.7.x' 2024-06-13 00:01:17 +02:00
Sergiu Deitsch
9ca8073cb2
docs: use annotations 2024-06-12 23:58:10 +02:00
Sergiu Deitsch
c4b63c7a4e
docs: use footnotes 2024-06-12 23:57:35 +02:00
Sergiu Deitsch
5cf7a9afd3
docs: describe failure writer 2024-06-12 23:56:44 +02:00
Sergiu Deitsch
d49e700897
docs: move flags out of logging 2024-06-12 23:54:11 +02:00
Sergiu Deitsch
44c2e9d9ad
Merge branch '0.7.x' 2024-06-12 01:20:27 +02:00
Sergiu Deitsch
df683bbc81
docs: provide custom sinks example (#1103) 2024-06-12 01:20:04 +02:00
Sergiu Deitsch
0bad9688a0
docs(bazel): update archive url 2024-06-11 20:52:53 +02:00
Sergiu Deitsch
1cd4d78817
Merge branch '0.7.x' 2024-06-11 20:13:53 +02:00
Sergiu Deitsch
30c9ed3687
docs: update version 2024-06-11 19:57:05 +02:00
Sergiu Deitsch
645acfe606
docs: move to mkdocs-material (#1101) 2024-06-11 19:53:37 +02:00
Sergiu Deitsch
cfe648e9c5
docs: move to mkdocs-material (#1101) 2024-06-11 19:48:12 +02:00
Sergiu Deitsch
cc0de6c200
Merge branch '0.7.x' 2024-06-08 17:11:26 +02:00
Sergiu Deitsch
7b134a5c82
release 0.7.1 (#1098) 2024-06-08 17:07:34 +02:00
Vertexwahn
d76999015c
feat(bazel): port to bzlmod (#1097) 2024-06-08 16:02:59 +02:00
xppt
4c50627c38
fix(symbolize): format unknown stack frames (#1092) 2024-04-22 21:17:57 +02:00
dependabot[bot]
6e6a817a44
build(deps): bump codecov/codecov-action from 3 to 4 (#1071)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3 to 4.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-22 21:17:57 +02:00
xppt
cd4ef77d58
fix(symbolize): format unknown stack frames (#1092) 2024-04-22 21:08:44 +02:00
dependabot[bot]
c0813f90bb
build(deps): bump codecov/codecov-action from 3 to 4 (#1071)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3 to 4.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-22 13:40:27 +02:00
Sergiu Deitsch
442c6fcbf1
fix: rework android detection (#1094) 2024-04-22 00:48:01 +02:00
Sergiu Deitsch
2b36dfe444
fix: rework android detection (#1094) 2024-04-22 00:47:36 +02:00
Victor Zheng PhD
eecd37e7eb
fix(bazel): add missing emscripten defines (#1082) 2024-04-22 00:39:29 +02:00
Sergiu Deitsch
f73750564e
fix: error message typo 2024-04-22 00:39:29 +02:00
Ram Subhash D
46e4721fb6
fix(readme): correct LOG_IF_EVERY_N typo (#1077) 2024-04-22 00:39:29 +02:00
Sergiu Deitsch
fd15ff9a54
fix(readme): wording 2024-04-22 00:39:29 +02:00
Victor Zheng PhD
31429d85b8
fix(bazel): add missing emscripten defines (#1082) 2024-03-11 11:20:22 +01:00
Sergiu Deitsch
ea0748d8df
feat: remove deprecations (#1078) 2024-02-21 18:56:43 +01:00
Sergiu Deitsch
5a7856ab96
fix: error message typo 2024-02-19 20:08:00 +01:00
Ram Subhash D
8a1c086d39
fix(readme): correct LOG_IF_EVERY_N typo (#1077) 2024-02-19 20:07:33 +01:00
Sergiu Deitsch
a189fc3d7d
fix(readme): wording 2024-02-18 13:24:53 +01:00
Sergiu Deitsch
34b8da6496
release 0.7 (#1076) 2024-02-17 18:49:26 +01:00
Sergiu Deitsch
7a807f3805
feat: allow to obtain the stack trace as a string (#1075) 2024-02-17 18:41:40 +01:00
Sergiu Deitsch
b24e4d9445
feat: support failure functions that throw (#1074) 2024-02-17 18:41:11 +01:00
Rishik Reddy
de77d0b97b
fix(readme): eliminate typo (#1072) 2024-02-17 18:28:52 +01:00
Sergiu Deitsch
68b6ce38eb
ci(coverage): update to gcovr 7.0 (#1070) 2024-01-27 14:03:18 +01:00
dependabot[bot]
9b34110745
build(deps): bump actions/cache from 3 to 4 (#1064)
Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-22 19:30:29 +01:00
Vertexwahn
ac12a9e794
Add MODULE.bazel file (#1059)
This is the first step of the bzlmod migration: https://bazel.build/external/migration. If/when we no longer support older Bazel versions (bzlmod became GA in 6.0), we can remove WORKSPACE.
2024-01-11 10:41:55 +01:00
Sergiu Deitsch
7e6fca90e8
cmake: rework elf detection (#1058) 2024-01-10 14:06:18 +01:00
Sergiu Deitsch
8d13b3bb0c
fix: unify LogMessage and LogMessageInfo (#1057)
Deprecate the custom prefix callback accepting LogMessageInfo in favor
of existing LogMessage data structure extended with necessary data
fields to avoid redundancies.
2024-01-10 02:03:54 +01:00
Sergiu Deitsch
2293c6fc5a
fix(symbolize): use correct format specifier (#1056) 2024-01-10 00:43:02 +01:00
Sergiu Deitsch
ec455f2cc1
fix: better encapsulate internals (#1055) 2024-01-09 23:51:43 +01:00
Sergiu Deitsch
2b5a53c880
cmake: replace check_function_exists by check_cxx_symbol_exists (#1054) 2024-01-09 20:05:22 +01:00
Sergiu Deitsch
dd77d0fd38
fix: move LogMessageVoidify into internal namespace (#1053) 2024-01-09 13:46:26 +01:00
Sergiu Deitsch
941c66fbcb
cmake: bump SOVERSION (#1052) 2024-01-09 00:39:54 +01:00
Sergiu Deitsch
9377254062
feat(dbghelp): show source line number if present (#1051) 2024-01-08 19:04:22 +01:00
Sergiu Deitsch
c469cc23a1
fix: unify additional debug output (#1050) 2024-01-08 16:26:41 +01:00
Sergiu Deitsch
7af231e6bf
feat: provide fallback for accessing process name (#1049) 2024-01-08 11:18:59 +01:00
Sergiu Deitsch
aaefca72b3
fix(symbolize): cleanup (#1048) 2024-01-08 01:40:29 +01:00
Sergiu Deitsch
734ab3463f
fix(symbolize): simplify resource management (#1047) 2024-01-08 00:18:42 +01:00
Sergiu Deitsch
42a185cd88
fix: reduce manual resource management (#1046) 2024-01-07 21:12:40 +01:00
Sergiu Deitsch
1f9ac49c7d
docs: describe default prefix format (#1045) 2024-01-07 19:12:29 +01:00
Sergiu Deitsch
489d35eb13
fix: reduce boilerplate code (#1043) 2024-01-06 21:39:49 +01:00
Sergiu Deitsch
1ef1ab37e7
fix: do not export g_logging_fail_func (#1042) 2024-01-06 16:58:51 +01:00
Sergiu Deitsch
2c735b8dfb
docs: cleanup (#1041) 2024-01-06 15:04:12 +01:00
Sergiu Deitsch
25a349f7ae
feat(time): use tm::tm_gmtoff if present (#1040)
This greatly simplifies time computations.
2024-01-06 02:56:23 +01:00
Sergiu Deitsch
eb72e4c181
feat(logger): use chrono (#1039) 2024-01-05 23:07:49 +01:00
Sergiu Deitsch
f88544adf5
feat(cleanup): use chrono (#1038)
* Deprecate type-unsafe EnableLogCleaner interface
* Increase time resolution allowing to drop timing specific
  workarounds in unit tests
2024-01-05 20:38:24 +01:00
Sergiu Deitsch
89f5977468
cmake: determine when to use port.h (#1037)
Allow building using MSYS2 (without MinGW).
2024-01-05 19:57:34 +01:00
Sergiu Deitsch
fe46778bd3
fix: threads are always enabled (#1036) 2024-01-05 15:21:43 +01:00
Sergiu Deitsch
6d23649fef
fix(debug): add missing parentheses in ternary expression (#1035) 2024-01-05 14:11:44 +01:00
Sergiu Deitsch
b172be9564
fix: allow setting stderrthreshold using GLOG_stderrthreshold (#1034) 2024-01-05 01:43:22 +01:00
Sergiu Deitsch
8fbad2cb9c
feat: make IsFailureSignalHandlerInstalled public (#1033) 2024-01-05 00:13:04 +01:00
Sergiu Deitsch
8dd7abfdec
fix: remove unused declaration (#1032) 2024-01-05 00:12:43 +01:00
Sergiu Deitsch
f3bee1b15b
fix: ensure export macro to be defined (#1031) 2024-01-04 22:06:27 +01:00
Sergiu Deitsch
c8950c6b17
ci(codecov): enable comments (#966) 2024-01-04 21:54:23 +01:00
Sergiu Deitsch
8775a454c1
feat: make headers self-contained (#1030) 2024-01-04 21:03:55 +01:00
Sergiu Deitsch
dfce35c97c
fix: cleanup exports (#1029)
Reduce unnecessary utility function exports.
2024-01-04 16:57:18 +01:00
Sergiu Deitsch
e1f424a7e2
cmake: opt-in pkg-config support 2024-01-04 15:49:29 +01:00
Sergiu Deitsch
39df0545e7
docs: cleanup 2024-01-04 15:02:54 +01:00
Sergiu Deitsch
cafba580ec
feat: use standard atomics and call_once (#1026) 2024-01-04 01:18:36 +01:00
Sergiu Deitsch
54b2c17172
fix: make log severity type safe (#1025) 2024-01-04 00:35:40 +01:00
Sergiu Deitsch
51e7a439dc
feat(demangle): use cxx abi demangler (#1023) 2024-01-03 19:24:35 +01:00
Sergiu Deitsch
bdd14b6ab1
fix(demangle): place symbols in anonymous namespace (#1022) 2024-01-03 16:49:43 +01:00
Sergiu Deitsch
70285fddc7
feat: use chrono (#1020) 2024-01-03 16:00:24 +01:00
Sergiu Deitsch
4244cec140
cmake: remove unused check (#1021) 2024-01-03 15:45:03 +01:00
Sergiu Deitsch
0032896711
feat: use standard threads (#1019) 2024-01-03 02:24:52 +01:00
Sergiu Deitsch
645d0a5d5f
fix(demangle): support decltype(nullptr) and pack expansion (#1018) 2024-01-02 22:31:00 +01:00
Sergiu Deitsch
45d7978daf
fix(tests): prevent clang from optimizing new away (#1017) 2024-01-02 13:01:42 +01:00
Sergiu Deitsch
b1bc8e75cb
feat: reduce manual deallocations (#1016) 2024-01-02 02:17:23 +01:00
Sergiu Deitsch
8ff1a7db04
feat: use standard mutexes (#1015) 2024-01-02 00:47:22 +01:00
Sergiu Deitsch
ac8f8dae2c
fix: remove unused test code (#1014) 2024-01-02 00:47:02 +01:00
Sergiu Deitsch
d29d02e8af
fix: add missing gmtime_r check (#1013)
909069ea82 introduced optional gmtime_r
support but did implement the function's availability check.
2023-12-30 22:07:29 +01:00
Sergiu Deitsch
93549f3600 chore: apply clang-format 2023-12-30 20:38:56 +01:00
Sergiu Deitsch
e3f5398aa1
rework public header structure (#1012)
Promote generated headers to regular headers. This enables direct
editing of corresponding files and running automatic source code
formatting and static analysis tools, such as clang-format and
clang-tidy on the whole project which previously was not
straightforward.
2023-12-30 19:05:26 +01:00
Sergiu Deitsch
80d7fa3863 ci: use emcmake 2023-12-30 13:06:54 +01:00
Sergiu Deitsch
aeee0ef452 fix(symbolize): use correct size_t format specifier
While compiling under Emscripten with _LP64 being 0, Clang complains
that the format specifier does not match the actual type (even though
size_t and unsigned are probably compatible.)
2023-12-30 02:14:49 +01:00
Sergiu Deitsch
546906f467 fix: remove unused include 2023-12-30 01:01:40 +01:00
Sergiu Deitsch
43792b8a13 rework (lib)unwind integration
Allow to switch between the two backends.
2023-12-30 00:50:52 +01:00
Sergiu Deitsch
3c052d90f8 fix: remove executable bit 2023-12-29 17:54:32 +01:00
Sergiu Deitsch
ab2a1a8519
fix: enable strip log tests (#1009) 2023-12-28 02:34:06 +01:00
Sergiu Deitsch
e92ab7df52
cmake: remove pre C++11 warning options (#1005) 2023-12-21 23:07:58 +01:00
Sergiu Deitsch
e26e342623
cmake: use glog specific project variables (#1004) 2023-12-21 23:07:36 +01:00
Sergiu Deitsch
dfb7703542
cmake: simplify symbol availability checks (#1003) 2023-12-21 22:25:04 +01:00
Sergiu Deitsch
b7686b6995
cmake: remove obsolete check (#1002) 2023-12-21 22:01:35 +01:00
Sergiu Deitsch
72b8a7956f
cmake: do not enable TLS without threads (#1001) 2023-12-21 20:59:30 +01:00
Sergiu Deitsch
65cc31ab16
cmake: use threads import target (#1000) 2023-12-21 20:40:43 +01:00
Sergiu Deitsch
d937c2e1b8
fix: shell quote user-provided mailer path (#999) 2023-12-21 19:54:07 +01:00
Acey
716be9edc7
feat: add missing debug logging macros (#986) 2023-12-21 19:45:06 +01:00
Mike Frysinger
6607b369d0
symbolize_unittest: make it a bit more portable (#985) 2023-12-20 21:10:26 +01:00
Sergiu Deitsch
3fcf77a691
fix: drop custom (v)snprintf definition (#992)
The functions are available since C++11.
2023-12-20 20:49:08 +01:00
Sergiu Deitsch
3731c120c0
fix: replace NULL by nullptr (#993) 2023-12-20 20:48:43 +01:00
Sergiu Deitsch
a9eecd7f9a
fix: log last error code instead of a BOOL (#994) 2023-12-20 20:47:57 +01:00
Sergiu Deitsch
7d973f9b4e
cmake: replace check_library_exists by check_cxx_symbol_exists (#991)
As per https://gitlab.kitware.com/cmake/cmake/-/issues/18121,
check_library_exists cannot not determine the availability of a symbol
in a static library. Switch to check_cxx_symbol_exists to avoid
incorrectly detecting the presence of dbghelp.
2023-12-20 18:47:10 +01:00
dependabot[bot]
36ccb159f4
build(deps): bump actions/upload-artifact from 3 to 4 (#987)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-19 21:17:14 +01:00
dependabot[bot]
58ac48fe20
build(deps): bump github/codeql-action from 2 to 3 (#988)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-19 20:02:32 +01:00
Sergiu Deitsch
b6082e5088
fix: remove redundant POSIX function aliases (#990)
The preprocessor defines interfere with method declarations, e.g., in
std::basic_filebuf, resulting in following error:

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.37.32822\include\fstream(376,26): error C2039: '_close': is not a member of 'std::basic_filebuf<char,std::char_traits<char>>' [D:\a\glog\glog\build_Debug\logging_unittest.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.37.32822\include\iosfwd(244,35): message : see declaration of 'std::basic_filebuf<char,std::char_traits<char>>' [D:\a\glog\glog\build_Debug\logging_unittest.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.37.32822\include\fstream(375,10): message : while compiling class template member function 'void std::basic_ofstream<char,std::char_traits<char>>::_close(void)' [D:\a\glog\glog\build_Debug\logging_unittest.vcxproj]
D:\a\glog\glog\src\logging_unittest.cc(788,12): message : see the first reference to 'std::basic_ofstream<char,std::char_traits<char>>::_close' in 'TestBasenameAppendWhenNoTimestamp' [D:\a\glog\glog\build_Debug\logging_unittest.vcxproj]
D:\a\glog\glog\src\logging_unittest.cc(786,12): message : see reference to class template instantiation 'std::basic_ofstream<char,std::char_traits<char>>' being compiled [D:\a\glog\glog\build_Debug\logging_unittest.vcxproj]
2023-12-19 19:08:48 +01:00
Sergiu Deitsch
931323df21
fix: add missing thread_local specifier 2023-10-15 19:10:31 +02:00
Sergiu Deitsch
b45f5b4c82
fix(build): raise minimum cmake version to 3.21 (#974)
Linking against target objects is otherwise not possible.
2023-10-12 22:28:45 +02:00
LingBin
da9753409b
fix(cleanup): ensure FLAGS_log_dir ends with '/' (#972) 2023-10-12 13:35:52 +02:00
Sergiu Deitsch
b58718f37c
fix(cmake): rework ucontext_t introspection (#954) 2023-10-09 21:35:51 +02:00
Sergiu Deitsch
aebdfd6051
fix: eliminate msvc warning 2023-10-08 19:04:29 +02:00
dependabot[bot]
e19e598302
build(deps): bump actions/checkout from 3 to 4 (#970)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-08 18:58:07 +02:00
Sergiu Deitsch
fe476db256 ci: add dependabot github action 2023-10-08 18:23:31 +02:00
Sergiu Deitsch
b8a251c091 fix(cmake): support xcode generator 2023-10-08 17:33:53 +02:00
Huy Q. Bui
4dbc26af72
feat: support log file truncation on windows (#960) 2023-10-08 14:03:10 +02:00
Sergiu Deitsch
615966eb6d
fix: prefer includes in same directory (#969)
Use quoted form instead of angle-bracket form for includes to avoid
conflicts between multiple versions of the library.
2023-10-07 20:15:29 +02:00
Sergiu Deitsch
6a7be64131
fix: remove stray spaces (#967) 2023-10-07 18:58:01 +02:00
Sergiu Deitsch
9a5e72136b
ci: drop code scanning category (#968) 2023-10-07 18:50:25 +02:00
Sergiu Deitsch
5d4fa3d774
feat: use code scanning 2023-10-07 17:08:40 +02:00
Sergiu Deitsch
4a75a9df7c
fix: eliminate type conversion warnings 2023-10-07 16:14:21 +02:00
Deev Patel
e17f932eec
fix: annotate static variable in VLOG_IS_ON (#890)
Avoid TSAN issues when multiple threads perform the check.
2023-10-07 15:35:52 +02:00
Sergiu Deitsch
f6e4d960e9
ci: replace lcov by gcovr (#965) 2023-10-07 02:29:58 +02:00
Sergiu Deitsch
1dffb4eb29
fix: enable building without threads (#964) 2023-10-06 22:30:31 +02:00
Sergiu Deitsch
747b8a0774
fix(demangle): limit ParseTemplateArg recursion depth (#963) 2023-10-06 21:32:05 +02:00
Sergiu Deitsch
857df01007
fix(demangle): limit recursion depth (#958) 2023-10-06 02:03:43 +02:00
Sergiu Deitsch
319a0dfba4
fix: stack buffer overflow (#957) 2023-10-06 01:47:56 +02:00
Sergiu Deitsch
e567cfc442
fix: address sanitizer failures (#956) 2023-10-06 00:34:38 +02:00
Sergiu Deitsch
7ba2f7bc02
fix(demangle): prevent signed integer overflow (#955) 2023-10-05 23:33:23 +02:00
Sergiu Deitsch
27bf2b2fd3
ci: update to ndk r26 2023-10-05 21:58:43 +02:00
Sergiu Deitsch
fab3b5eac4
ci: support C++23 2023-10-05 21:41:33 +02:00
Sergiu Deitsch
b90799c277
ci: drop setup-ninja action 2023-10-05 20:27:31 +02:00
Sergiu Deitsch
3411d58669 cmake: eliminate deprecation warning 2023-10-05 00:49:39 +02:00
Philipp Wollermann
64827572c0
SendEmail: Protect users against vulnerable logmailers (#939)
glog is used on a variety of systems, and we must assume that some of
them still use vulnerable mailers that have bugs or "interesting
features" such as https://nvd.nist.gov/vuln/detail/CVE-2004-2771.

Let's protect users against accidental shell injection by validating
the email addresses against a slightly stricter version of the regex
used by HTML5 to validate addresses[1].

This should prevent triggering any unexpected behavior in these tools.

Also add some basic unit tests for the SendEmail method.

[1] https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
2023-09-07 17:31:25 +02:00
Praveen Ravichandran
6fbc93a7e4
fix(readme): typo in conan install step (#946) 2023-09-06 08:58:09 +02:00
Rodrigo Queiro
3a0d4d22c5
Warn about dragons in the Bazel include path (#927)
https://github.com/google/glog/issues/837 has caused a couple of
disappointments for PR authors, so I'm hoping this comment can save them
some time, or even help them towards finding a complete solution for the
problem.
2023-06-05 11:08:12 +02:00
Eric Kilmer
22491eb123
logging: Prevent LogStream constructor from being discarded (#925)
Fixes linker error reported in #922
2023-05-25 21:26:33 +02:00
Vertexwahn
4945347d07 Fix spelling mistakes 2023-05-25 20:51:51 +02:00
Mai Hussien
888f93947b Move commandlineflags.h to shared_headers 2023-05-15 16:31:45 +02:00
Mai Hussien
4ffdf0dc78 Move shared headers to a private filegroup 2023-05-15 16:31:45 +02:00
Mai Hussien
7a62819e43 Fix targets for layering_check 2023-05-15 16:31:45 +02:00
Brad Smith
aca9a23c83
fixed OpenBSD support (#921)
- Usage of syscall() is not allowed
- Use getthrid() to retreive the thread ID
2023-05-10 13:41:38 +02:00
Sergiu Deitsch
6742834201
move to C++14 (#902) 2023-02-28 12:26:49 +01:00
Peng Xiao
35f4efbb0a bazel: Add HAVE_EXECINFO_H copts to fix empty stack trace 2023-02-28 12:10:03 +01:00
Catena cyber
9c3d6d0e71
ci: include CIFuzz GitHub workflow (#903) 2023-02-27 11:23:27 +01:00
Uilian Ries
a13d03babc
add conan usage to README (#862)
Signed-off-by: Uilian Ries <uilianries@gmail.com>
2023-02-24 22:55:35 +01:00
Catena cyber
846c3fe55b
Add fuzz testing for demangle (#878) 2023-02-24 22:45:32 +01:00
Sergiu Deitsch
1b59cb0905
drop custom prefix option (#898) 2023-02-24 20:40:09 +01:00
Sergiu Deitsch
af8344bbbe
cmake: rename glogbase to glog_internal (#901) 2023-02-24 20:39:46 +01:00
Sergiu Deitsch
88e2cd4eef
avoid anonymous struct typedefs (#900) 2023-02-24 20:15:03 +01:00
Sergiu Deitsch
4ffb2f3c40
drop lgtm badges (#899) 2023-02-24 20:13:38 +01:00
Sergiu Deitsch
4056374800
fixed emscripten detection (#897) 2023-02-24 19:25:26 +01:00
Sergiu Deitsch
f545ff5e7d
ci: update actions (#886) 2023-01-01 18:30:33 +01:00
Sergiu Deitsch
2115d9b590
ci: run linux workflow on ubuntu 22.04 (#885) 2023-01-01 18:08:53 +01:00
James Sharpe
c18db3903b Fix Windows clang CI for CC toolchain resolution
Select the correct toolchain and platform for
building with clang on windows with CC toolchain
resolution active.
2022-11-30 10:37:01 +01:00
Ivo List
05fbc65278 Disable cc toolchain resolution when using Clang on Windows
Different compilers on Window are not yet supported with CC toolchain resolution.
2022-09-21 17:00:02 +02:00
Rodrigo Queiro
9ad08ac6cc Remove symbolize Bazel test
It is broken on Windows CI (#859) in a way that I don't understand.
2022-09-15 16:42:46 +02:00
Sergiu Deitsch
b70ea80433
Revert "simplify DLOG macro definition in NDEBUG mode (#830)" (#855)
This reverts commit 278ed96891.
2022-08-18 16:14:23 +02:00
Marek Cirkos
bfee415a1d
bazel: fix broken stacktrace (#851)
Since #846, `HAVE_UNWIND_H`  is not really in use. Instead we should use `HAVE__UNWIND_BACKTRACE` and `HAVE__UNWIND_GETIP` (added in #846). To prevent that from happening again, also added Bazel tests that confirm stacktrace are still working.
2022-08-16 18:48:59 +02:00
Andrei Polushin
acc60d0c38
logsink: fix multiple issues with LogSink::ToString() (#852)
1. Initializing std::ostringstream with a string makes no sense, as the
   string becomes an initial value of an underlying buffer; seek-to-end
   is not performed, so the initial value gets completely overwritten by
   subsequent writing.

2. Flag `log_year_in_prefix` should be considered, as if formatting a
   regular logging message.

3. Writing a buffer to std::ostream is better expressed with write(s,n).
2022-08-13 12:21:25 +02:00
Andrei Polushin
6d5b384507
SetLogger should delete previously set custom logger. (#853)
As specified in the doc comment for SetLogger, "the logger becomes the
property of the logging module and should not be deleted by the caller".

Not only should the LogDestination delete a custom logger in its
destructor, but it should also delete a previous logger when another
logger is passed to SetLogger().

Co-authored-by: Sergiu Deitsch <sergiud@users.noreply.github.com>
2022-08-13 12:20:33 +02:00
Andrei Polushin
1fb4cc1958
log_file_header: add option to disable log file headers. (#850)
Log lines can be customized for parsing by an external tool.

To simplify such customization and parsing, there should be an option to
customize the file header, or at least to disable adding it.
2022-08-13 11:10:00 +02:00
Andrei Polushin
a1b6164ef1
windows: call to FormatMessage() should _IGNORE_INSERTS (#849)
Calling FormatMessage without a FORMAT_MESSAGE_IGNORE_INSERTS flag could
cause trouble, as explained in an article by Raymond Chen:

* The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag
  https://devblogs.microsoft.com/oldnewthing/20071128-00/?p=24353
2022-08-12 15:18:55 +02:00
rain
278ed96891
simplify DLOG macro definition in NDEBUG mode (#830)
Co-authored-by: joliph <joliphzjf@gmail.com>
Co-authored-by: Sergiu Deitsch <sergiud@users.noreply.github.com>
2022-08-06 20:33:23 +02:00
Sergiu Deitsch
6ed0c9e58b
added emscripten support (#846) 2022-08-04 22:52:47 +02:00
Sergiu Deitsch
a34226ca94
support ndk r25 (#844) 2022-08-01 10:46:35 +02:00
Joey Parrish
c515e1ae2f
remove unused STDC_HEADERS definition (#835) 2022-07-02 01:03:18 +02:00
Yun Peng
79d692c645 Strip only the first leading @
This change is needed for glog to work with future version of Bazel when
canonical label literals is used in Bzlmod.

Context: https://docs.google.com/document/d/1N81qfCa8oskCk5LqTW-LNthy6EBrDot7bdUsjz6JFC4/edit#heading=h.5mcn15i0e1ch
2022-06-15 18:05:23 +02:00
Xiangquan Xiao
086ce224d2 bazel: Use glog 0.6.0 in README. 2022-06-13 12:53:24 +02:00
Sergiu Deitsch
b33e3bad4c
Merge pull request #812 from google/release-0.6
release 0.6
2022-04-05 00:03:27 +02:00
Sergiu Deitsch
54b8bcbbf1 release 0.6 2022-04-02 20:33:57 +02:00
Sergiu Deitsch
864ef64920
Merge pull request #801 from skeptic-monkey/master
Fix namespace resolution issue in LOG_EVERY_T
2022-03-16 15:51:09 +01:00
Luc Bertrand
c640c2f7c1 Fix namespace resolution issue in LOG_EVERY_T 2022-03-16 15:27:38 +01:00
Rodrigo Queiro
5addeedc0a Fix "'GLOG_EXPORT' macro redefined" on clang-cl
The previous approach used
--incompatible_enable_cc_toolchain_resolution, which is recommended by
the docs, but a Bazel developer told me it's obsolete. The new, old
approach is simpler and should stop the warning from being user-visible.
2022-03-08 13:39:50 +01:00
Rodrigo Queiro
d153e294b8 Avoid "GLOG_EXPORT macro redefined" in clang-cl CI
I would prefer to fix this in glog.bzl but couldn't get that to work.
2022-03-04 11:12:21 +01:00
Rodrigo Queiro
c4ca519a86 Add CI job for clang-cl on Windows
This should catch issues like #801. This uses the new `tasks` syntax to
define multiple Windows tasks:

https://github.com/bazelbuild/continuous-integration/blob/master/buildkite/README.md#basic-syntax
2022-03-04 11:12:21 +01:00
Sergiu Deitsch
a8e0007e96
Merge pull request #790 from git-hulk/feature/logs-to-stdout
Add the logtostdout and colorlogtostdout flag to allow logging to stdout
2022-02-20 12:32:06 +01:00
Sergiu Deitsch
553ddaea85
Merge pull request #794 from Arfrever/tests-TMPDIR
Tests: Respect TEST_TMPDIR, TMPDIR, TMP environmental variables
2022-02-20 12:31:06 +01:00
Arfrever Frehtes Taifersar Arahesis
6d3f70a405 Pass EXIT_SUCCESS or EXIT_FAILURE to exit() and _exit() 2022-02-19 20:07:23 +01:00
Arfrever Frehtes Taifersar Arahesis
612a7d28c1 Tests: Respect TEST_TMPDIR, TMPDIR, TMP environmental variables
Use GetExistingTempDirectories() (which uses GetTempDirectories() which respects
TEST_TMPDIR, TMPDIR, TMP environmental variables) for FLAGS_test_tmpdir variable
used in some tests.

Fixes: #793
2022-02-19 20:07:23 +01:00
git-hulk
180b700ddc Add logtostdout and colorlogtostdout flags for logging to stdout
Currently, glog allows to use of logtostderr to send error logs to
stderr, but many log tailers would regard logs from stderr as error
logs. So we want to send non-error logs to stdout and only send error
logs to stderr according to the stderrthreshold.
2022-02-19 16:13:59 +01:00
Arfrever Frehtes Taifersar Arahesis
b38ed9d08a cmake_package_config_generate: Fix CMake warnings with CMake 3.23
Correct syntax to run CMake built-in command-line tools is `cmake -E`:
https://cmake.org/cmake/help/v3.23/manual/cmake.1.html#run-a-command-line-tool

This test was mistakenly using `cmake env ... cmake ...`, where `env` and second `cmake`
were interpreted as paths (of source directory or build directory), resulting
in "Ignoring extra path from command line" CMake warnings with CMake 3.23:
eacf1f879b
2022-02-18 14:15:15 +01:00
Sergiu Deitsch
9f0b7d3bfe renamed GOOGLE_GLOG_DLL_DECL to GLOG_EXPORT
Use a consistent naming and avoid platform specific terms. Also remove
copy and paste code.
2022-02-14 10:32:44 +01:00
Sergiu Deitsch
aa94e6b9ab simplify flags export 2022-02-13 13:04:24 +01:00
Sergiu Deitsch
17269d649d cmake: enable custom prefix by default 2022-02-13 12:54:11 +01:00
Arfrever Frehtes Taifersar Arahesis
bc1fada1cf libglog.pc: Set Libs.private for static linking 2022-01-25 19:35:57 +01:00
chien-hsing.wu
18836106d1 LogCleaner: avoid scanning logs too frequently 2022-01-25 13:45:59 +01:00
Frank Kolarek
b0174b3dda On Solaris, uname() returns non-negative value
As per https://docs.oracle.com/cd/E18752_01/html/816-5167/uname-2.html#REFMAN2uname-2
Solaris version of uname() return a non-negative value on success. Modifying this code to check
for a return value of less than zero will work on Solaris as well as Linux and AIX.
2022-01-19 21:51:06 +01:00
Vijaymahantesh Sattigeri
6969412183 Changed my Email ID 2022-01-19 21:50:30 +01:00
Sergiu Deitsch
6434410145 cmake: require at least gflags 2.2.2 2022-01-11 17:48:32 +01:00
Andrei Polushin
a8cfbe0c0c stdcxx: eliminate excessive use of std::string::c_str()
It could be more clear and slightly more efficient not to convert an
`std::string` into a C-style string whenever possible.
2021-12-30 12:55:45 +01:00
Sergiu Deitsch
b3abfaa123 use uint32 for --max-log-size 2021-12-29 23:15:17 +01:00
M Samoila
43fc3bf91c Add log_year_in_prefix flag
The flag allows suppressing the year in the log line prefix. At the same
time, the flag allows to generate log output compatible to glog releases
prior to version 0.5.
2021-12-23 21:43:23 +01:00
Sergiu Deitsch
42d509b1c3 revert to int atomics 2021-12-23 17:41:29 +01:00
Sergiu Deitsch
224f66bb63 cmake: do not search for platform specific unwind
This change removes platform specific unwind lookup allowing the use of
LLVM unwind implementation.
2021-12-22 16:15:15 +01:00
Sergiu Deitsch
4ffa98388f ensure _Unwind_Backtrace to actually be available 2021-12-21 11:38:12 +01:00
Sergiu Deitsch
087ad5bf32 eliminated clang warnings 2021-12-21 11:37:49 +01:00
Sergiu Deitsch
9dc1107f88 run clang-tidy 2021-12-15 12:04:34 +01:00
Sergiu Deitsch
dfb9ffc324 provide backward compatible send overload 2021-12-15 11:14:23 +01:00
Sergiu Deitsch
c575116051 ci: removed deprecated msvc runner 2021-12-14 22:45:41 +01:00
Marco Wang
d09b999f34 LogCleaner: make overdue_days_ unsigned int
Since the value of `LogCleaner::overdue_days_` should be >= 0,
we can simply make it an unsigned int which also avoids
unnecessary assertions.

Signed-off-by: Marco Wang <m.aesophor@gmail.com>
2021-12-13 19:00:07 +01:00
Sergiu Deitsch
baa7006e63 ci: enable warnings as errors 2021-12-10 20:10:17 +01:00
Sergiu Deitsch
660352f02b cmake: require at least version 3.16 (fixes #705) 2021-12-09 19:01:27 +01:00
Sergiu Deitsch
52354b2adc eliminate msvc warnings 2021-12-09 11:51:46 +01:00
Marco Wang
ccbda2dfd5 LogCleaner: Fix relative paths and add a new test
Signed-off-by: Marco Wang <m.aesophor@gmail.com>
2021-12-09 10:30:51 +01:00
Vijaymahantesh Sattigeri
ef36f800ed Added an API to get GMT offset from LogMessageTime
* Added API to get GMT offset
    * Made LogMessageTime as a memeber of LogMessage
    * Refactored LogSink::send() method
2021-12-09 10:26:47 +01:00
Sergiu Deitsch
ee6faf13b2 ci: use codecov token 2021-12-07 10:04:12 +01:00
Sergiu Deitsch
6e9b2f16f5 cmake: set CMP0074 policy
This enables the use of `<PackageName>_ROOT` (environment) variables.
2021-12-06 21:12:35 +01:00
Sergiu Deitsch
f4dd77ae6b ci: reworked windows builds 2021-12-06 19:00:41 +01:00
Shen Zhuoran
503e3dec8d Add Zhuoran Shen to AUTHORS and CONTRIBUTORS
I previously made a minor documentation fix in
https://github.com/google/glog/pull/747. According to README, this
commit adds myself to AUTHORS and CONTRIBUTORS.
2021-11-28 13:44:23 +01:00
Shen Zhuoran
5316599845 Fix log filename format
The log filename format does not match the example in the line below. One of them must be incorrect. This commit changes the format to match the example.
2021-11-25 12:39:38 +01:00
Sergiu Deitsch
cd8fbd5fbf ci: prefix artifact directories 2021-11-19 23:18:17 +01:00
Sergiu Deitsch
c8a7f5abee ci: added checkout action 2021-11-19 22:58:41 +01:00
Sergiu Deitsch
f47582361a ci: install lcov 2021-11-19 22:50:11 +01:00
Sergiu Deitsch
f773eb9b6f ci: unzip artifacts into separate directories 2021-11-19 22:40:33 +01:00
Sergiu Deitsch
f42fd3b154 ci: fixed unzipping multiple archives 2021-11-19 22:30:03 +01:00
Sergiu Deitsch
cb7c19d36b ci: removed non standard --zero option 2021-11-19 22:22:41 +01:00
Sergiu Deitsch
cf4c4699bc ci: unzip artifacts individually 2021-11-19 22:14:07 +01:00
Sergiu Deitsch
5a3bd74cfa ci: replaced forEach by a loop 2021-11-19 22:01:06 +01:00
Sergiu Deitsch
1da31df93c ci: name unpack step and fix indent 2021-11-19 21:31:29 +01:00
Sergiu Deitsch
6bd5acfb66 ci: download workflow artifacts 2021-11-19 21:15:37 +01:00
Sergiu Deitsch
8121c07551 ci: aggregate coverage in separate workflow 2021-11-19 20:56:53 +01:00
Sergiu Deitsch
8b872216ea ci: simplify coveralls job id 2021-11-18 11:01:35 +01:00
Sergiu Deitsch
11f08e7bb1
Merge pull request #742 from google/protect-vlog
protect VLOG by use_logging
2021-11-18 08:29:50 +01:00
Sergiu Deitsch
65199ed0b8 protect VLOG by use_logging 2021-11-18 00:01:33 +01:00
Sergiu Deitsch
b79e18b78b ci: updated coveralls job id 2021-11-13 12:37:25 +01:00
Sergiu Deitsch
4399e56647 ci: explicitly identify coveralls builds 2021-11-13 11:54:16 +01:00
Sergiu Deitsch
9206460cd3
Merge pull request #739 from google/cmake-glog-modules-install
fix `glog-modules.cmake` install
2021-11-12 12:06:47 +01:00
Sergiu Deitsch
64b4e327ff cmake: fixed glog-modules.cmake installation 2021-11-11 22:38:12 +01:00
Sergiu Deitsch
4df5ae7463 ci: added cmake package config test 2021-11-11 22:15:26 +01:00
Sergiu Deitsch
ab5e109298 Revert "cmake: fix incorrect relative path concatenation (#733)"
This reverts commit 68964b8db6.
2021-11-11 21:56:25 +01:00
Sergiu Deitsch
32522a5f65 ci: notify coveralls on finished parallel builds 2021-11-11 00:55:35 +01:00
Sergiu Deitsch
d581807e33 ci: run coveralls on completed workflow 2021-11-11 00:32:00 +01:00
Sergiu Deitsch
6c9f5b2ec4 ci: added jobs to coveralls workflow 2021-11-11 00:25:00 +01:00
Sergiu Deitsch
0798a37bb0 ci: added coveralls workflow 2021-11-11 00:14:09 +01:00
Johannes Meyer
33696664cb
restore the stream format after writing the log prefix (#731)
* Fix MungeLine() for log lines that are longer than 5 characters
* Match order of log statements in logging_unittest.cc and logging_unittest.err
* Update logging_custom_prefix_unittest.cc and logging_custom_prefix_unittest.err to match logging_unittest.cc and logging_unittest.err
* Save the stream state and set the fill character before calling into a custom_prefix_callback
2021-11-05 22:29:36 +01:00
Niklas Hambüchen
68964b8db6
cmake: fix incorrect relative path concatenation (#733)
When a `-DCMAKE_INSTALL_PREFIX` is given, this could result in paths like:

    /path/to/prefix//path/to/prefix/lib/cmake/glog/glog-modules.cmake

which was incorrect.

If a relative `DESTINATION` is given, it's assumed to be relative to the install prefix.
2021-11-05 22:19:36 +01:00
Sergiu Deitsch
17e7679fd9
Merge pull request #654 from aesophor/fix-path
Make LogCleaner support relative paths
2021-10-29 23:14:05 +02:00
Marco Wang
c27c3a803b make LogCleaner support relative paths 2021-10-29 23:04:42 +02:00
Sergiu Deitsch
e8e40f76db
Merge pull request #732 from google/log-cleaner-tests
added log cleaner tests and fixed paths
2021-10-29 22:58:38 +02:00
Sergiu Deitsch
3362cc6c79 added log cleaner tests and fixed paths 2021-10-29 22:45:55 +02:00
Sergiu Deitsch
9cf0eb7c98
Merge pull request #724 from google/mock-log
add mock log test
2021-10-12 14:43:14 +02:00
Sergiu Deitsch
1398762db8 added mock log test 2021-10-12 14:36:33 +02:00
Sergiu Deitsch
ce3533613b
Merge pull request #723 from google/coverage-use-templates
ci: replace generated headers by templates
2021-10-12 10:07:28 +02:00
Sergiu Deitsch
06e665108a ci: replace generated headers by templates 2021-10-12 09:38:04 +02:00
Sergiu Deitsch
56d3faceea
Merge pull request #722 from google/linux-github-action
add linux github workflow
2021-10-11 16:29:17 +02:00
Sergiu Deitsch
4a55b11580 ci: added linux github workflow 2021-10-11 15:54:42 +02:00
huangqinjin
3965584721
support stack unwind on Android 2021-10-08 22:14:20 +02:00
Sergiu Deitsch
acda903486
Merge pull request #720 from google/gmock-support
added gmock support
2021-10-07 20:11:58 +02:00
Sergiu Deitsch
8474b7854b added gmock support 2021-10-07 19:53:08 +02:00
Rodrigo Queiro
831a6f8232 Add -Werror to Bazel presubmits
This avoids issues like #717.
2021-10-07 19:46:34 +02:00
Artur
c34dbe9873 Fix syscall warning in Bazel Build
This commit resolves [#717](https://github.com/google/glog/issues/717) issue.
2021-10-07 19:43:48 +02:00
Sergiu Deitsch
56523194b3
Merge pull request #716 from google/export-os-defines
export `OS_*` defines (fixes #715)
2021-10-01 12:50:16 +02:00
Sergiu Deitsch
f7407d4d27 export OS_* defines (fixes #715) 2021-10-01 11:26:07 +02:00
Tongliang Liao
2412db3158 raw_logging.h depends on type definition in logging.h.
Resolve https://github.com/google/glog/issues/712
2021-09-24 12:51:15 +02:00
kinsei0916
3b6b05d70b Use __EMSCRIPTEN__ instead of __USE_POSIX2 2021-09-20 22:14:58 +02:00
kinsei0916
de81bb0aac Fix link error for Emscripten 2021-09-20 22:14:58 +02:00
Sergiu Deitsch
9733727be4
Merge pull request #706 from dfreese/tsan_annotation
Change size type in AnnotateBenignRaceSized to size_t from long
2021-09-03 19:27:28 +02:00
David Freese
ffb40018a5 Change size type in AnnotateBenignRaceSized to size_t from long
This makes this definition consistent with Abseil's declarations.  See:
https://github.com/abseil/abseil-cpp/blob/master/absl/base/dynamic_annotations.h#L213-L215

Having this unsigned seems to match what libsanitizers is expecting:
16e2427f50/libsanitizer/tsan/tsan_interface_ann.cpp (L367-L371)

This solves a "conflicting declaration of C function" when using glog
with abseil.
2021-09-03 09:51:46 -07:00
Sergiu Deitsch
6f9e32a79e
Merge pull request #700 from Starsss/master
Fix: not implement virtual class when WITH_CUSTOM_PREFIX on
2021-08-13 13:32:07 +02:00
六岁小少年
df95749e83 Fix: not implement virtual class when WITH_CUSTOM_PREFIX on 2021-08-12 16:40:52 +08:00
Sergiu Deitsch
35983c895c
Merge pull request #696 from Fettpet/signed_compare
Add a static cast to compare unsigned with unsigned
2021-08-10 13:36:31 +02:00
Sebastian Hahn
9fce37c464 Add a static cast to compare unsigned with unsigned 2021-08-09 10:15:07 +02:00
Sergiu Deitsch
a063a04ecf
Merge pull request #694 from google/more-warnings
fixed additional warnings
2021-08-01 18:15:31 +02:00
Sergiu Deitsch
92cb3c449b fixed additional warnings 2021-08-01 17:12:21 +02:00
Sergiu Deitsch
f8c8e99fdf
Merge pull request #688 from google/eliminate-warnings
eliminate warnings
2021-07-24 00:38:08 +02:00
Sergiu Deitsch
98e0e8c65d cmake: bump .so version
Account for ABI incompatibility.
2021-07-23 14:39:25 +02:00
Sergiu Deitsch
0b83bb203d eliminate warnings 2021-07-22 22:52:22 +02:00
Sergiu Deitsch
370cb741bb
Merge pull request #674 from StephLin/readme-fix-header-id
readme: fix wrong header id
2021-07-15 21:40:20 +02:00
Sergiu Deitsch
3ce6090d04 override header language 2021-07-14 22:55:23 +02:00
Sergiu Deitsch
36bcd28c61
Merge pull request #687 from google/exception-spec
fixed exception specification mismatch
2021-07-14 20:47:34 +02:00
Sergiu Deitsch
dfe573088c bump version 2021-07-14 20:02:37 +02:00
Sergiu Deitsch
717f569835 fixed exception specification mismatch 2021-07-14 19:37:05 +02:00
Sergiu Deitsch
eca3ddef81
Merge pull request #685 from z-aki/master
Fix syscall deprecation warning on macOS >= 10.12
2021-07-14 17:49:43 +02:00
z-aki
4a4331f2f2 Fix syscall deprecation warning on macOS >= 10.12
Fix #185
2021-07-14 19:51:19 +05:30
Sergiu Deitsch
a01d739ea3
Merge pull request #684 from sergiud/cmake-namespaced-gflags
cmake: prefer linking against gflags::gflags (fixes #683)
2021-07-14 10:39:54 +02:00
Sergiu Deitsch
8d3ce1c29a
Merge pull request #686 from google/ci-more-targets
ci: support more targets
2021-07-14 10:37:45 +02:00
Sergiu Deitsch
c39fcf6e8a ci: added more targets 2021-07-14 02:21:58 +02:00
Sergiu Deitsch
47ad26d5c6 readme: fixed inconsistent formatting 2021-07-13 15:30:19 +02:00
Sergiu Deitsch
5bf7fdea16 cmake: prefer linking against gflags::gflags (fixes #683) 2021-07-13 13:24:27 +02:00
Sergiu Deitsch
42ce901f28
Merge pull request #669 from darbitman/log-every-time-period
log messages periodically (time-based)
2021-07-05 20:33:12 +02:00
Dmitriy A
a1374c4200 Implement LOG_EVERY_T.
Use <chrono> and <atomic> for C++11 or greater.
For non-Windows pre-C++11 systems, use <time.h> and built-in atomic operations.
For Windows pre-C++11, use the Windows implementations for time and atomic operations.
2021-07-05 07:25:12 -07:00
luliyucoordinate
6e46c125e3 bazel: add GLOG_CUSTOM_PREFIX_SUPPORT 2021-07-01 08:04:18 +02:00
Philipp Wollermann
a415556858 Remove ubuntu1604 from presubmit.yml
Ubuntu 16.04 is end-of-life, we're going to remove it from Bazel CI.

If you like you can add testing on `ubuntu2004` platform which we also support.
2021-07-01 08:04:02 +02:00
StephLin
a1fa841f33 readme: fix wrong header id 2021-06-19 17:28:57 +08:00
Sergiu Deitsch
a4a725d547
Merge pull request #671 from sergiud/cmake-define-have-cxx11-atomic
cmake: export `<atomic>` availability (fixes #667)
2021-06-16 09:46:58 +02:00
Sergiu Deitsch
44331dc245
Merge pull request #672 from sergiud/cmake-allow-to-override-fpic
cmake: allow to override `-fPIC`
2021-06-16 00:32:16 +02:00
Sergiu Deitsch
f0bac8852a cmake: allow to override -fPIC 2021-06-15 23:56:49 +02:00
Sergiu Deitsch
764162569a
Merge pull request #670 from sergiud/cmake-msvc-snprintf
cmake: fixed msvc snprintf detection (fixes #668)
2021-06-15 20:09:07 +02:00
Sergiu Deitsch
d25a1b7bc0 cmake: export <atomic> availability (fixes #667) 2021-06-15 18:36:24 +02:00
Sergiu Deitsch
9c1a25b931 cmake: fixed msvc snprintf detection (fixes #668) 2021-06-15 18:26:10 +02:00
Fabian Meumertzheim
c1499f64a8 Export COPYING
By exporting `COPYING`, Bazel projects depending on glog can easily access its license.
2021-06-07 09:28:40 +02:00
Sergiu Deitsch
03f2b3861a
Merge pull request #650 from romange/Prod
Allow updating vmodule levels after vmodule level has been cached
2021-05-23 21:36:03 +02:00
Roman Gershman
86fea1ab25 Allow updating vmodule levels after vmodule was parsed, invalidate already cached site flags
vmodule flag is relevant for GNUC environments only.
2021-05-23 19:38:22 +03:00
Sergiu Deitsch
fef48c17e2
Merge pull request #656 from romange/cygwin
Fix cmake configuration for cygwin environment
2021-05-23 14:23:32 +02:00
Roman Gershman
d2fed749a5 Fix cmake configuration for cygwin environment
1. Use CYGWIN variable to test for WIN32 because WIN32 var has been deprecated in later versions of cmake.
2. Translate TEST_SRC_DIR to windows paths because posix open calls can not handle unix-like paths in cygwin environment.
2021-05-23 14:07:16 +03:00
Sergiu Deitsch
0b3d4cb471
Merge pull request #651 from xkszltl/initapi
Expose `IsGoogleLoggingInitialized()` in public API.
2021-05-14 13:23:01 +02:00
Tongliang Liao
81e0d616ed Expose IsGoogleLoggingInitialized() in public API.
Usually library does not have control of the process lifespan.
Without this function, it is impossible to init/shutdown reliably.
It has been one of the major pain points for years when using glog in libraries.

AFAIK 3 workarounds have been used previously:
1. Init without checking. This causes compatiblity issues with other libs using glog.
2. Also provide a init function in library's API. This makes API complicated and stateful, especially for libs that does not mean to stay for the entire life of process.
3. Steal the utility function in internal namespace. Does not work with msvc (due to missing dllexport) or `gcc -fvisibility=hidden`.

None of them are perfect, except for the last hack that usually works well on Linux.
0.5.0 changes default visibility to hidden and it does not work anymore.

Resolve https://github.com/google/glog/issues/125
2021-05-14 08:57:32 +08:00
Rodrigo Queiro
d5c04eec9e bazel: Use glog 0.5.0 in README
Also, add a sha256 for gflags to avoid a build warning.
2021-05-10 08:32:27 +02:00
Sergiu Deitsch
8f9ccfe770
Merge pull request #646 from sergiud/release-0.5
release 0.5
2021-05-08 01:05:04 +02:00
Sergiu Deitsch
36fee386f5 release 0.5 2021-05-06 21:53:03 +02:00
Sergiu Deitsch
8d40d7564d
Merge pull request #642 from husskade/patch-1
readme: update CMake source directory option
2021-04-14 19:59:37 +02:00
Kamil
a23e96f04f readme: update CMake source directory option
The `-H` command-line option has been replaced in 3.13 by `-S`.
2021-04-14 19:10:17 +02:00
Sergiu Deitsch
0efaa59a75
Merge pull request #641 from sergiud/nullptr
CHECK support for nullptr (fixes #341)
2021-04-12 10:08:28 +02:00
Sergiu Deitsch
230da316c5
Merge pull request #637 from xiaobfly/master
fix LogCleaner::IsLogFromCurrentProject for filename_extension
2021-04-11 15:20:57 +02:00
Sergiu Deitsch
bda40ec006
Merge pull request #640 from sergiud/gflags-windows-linker-warnings
fix gflags windows linker warnings
2021-04-11 15:09:03 +02:00
Sergiu Deitsch
762a2a7ee1 eliminated gflags related linker warnings (#569) 2021-04-11 14:24:41 +02:00
Sergiu Deitsch
7d4eeb14f4
Merge pull request #554 from santigl/santigl/custom-prefixer
Add support for customizing the prefix format
2021-04-09 21:02:32 +02:00
Santiago Gil
0cbc235297 Add support for setting a custom prefix format 2021-04-09 20:11:44 +02:00
Bret McKee
c7656c3ec1 CHECK support for nullptr (fixes #341)
This allows CHECK_NE(foo, nullptr) to compile and produces "nullptr" for the
string representation of nullptr.
2021-04-09 20:10:08 +02:00
Sergiu Deitsch
663bb26960
Merge pull request #620 from sergiud/cmake-allow-to-disable-symbolize
cmake: allow to disable symbolize
2021-04-09 15:06:36 +02:00
Sergiu Deitsch
7ec73b5099
Merge pull request #639 from sergiud/fix-windows-builds
fixed windows builds
2021-04-09 10:24:38 +02:00
Sergiu Deitsch
efc341d768 fixed windows builds 2021-04-08 18:16:42 +02:00
Sergiu Deitsch
a79416bab7
Merge pull request #638 from NeroBurner/github_actions
Add Windows builds using GitHub Actions
2021-04-08 01:16:17 +02:00
Reinhold Gschweicher
63ec71b58d Add windows builds with GitHub Actions
Add VS 2017, VS 2019 and MinGW-w64 builds running the test cases. All
compiler have build jobs for C++11 and C++17.

Currently only the build-type 'Debug' is used, but can easily be
extended to build both 'Debug' and 'Release'.
2021-04-07 23:19:20 +02:00
Sergiu Deitsch
39e83581de cmake: allow to disable symbolize 2021-04-07 22:59:46 +02:00
xiaobfly
635a078180 fix LogCleaner::IsLogFromCurrentProject for filename_extension 2021-04-07 17:42:52 +08:00
Sergiu Deitsch
e51790bf33
Merge pull request #625 from sergiud/remove-windows-headers
removed windows-specific headers
2021-04-06 20:22:14 +02:00
Sergiu Deitsch
36e6ed910a
Merge pull request #635 from google/win-headers
Use generated config.h for Windows.
2021-04-06 20:15:32 +02:00
Sergiu Deitsch
7d60d6e04b removed windows specific headers 2021-04-06 19:59:47 +02:00
Rodrigo Queiro
1041a221b8 Use generated config.h for Windows.
This unblocks a simplification of the Windows CMake build.
2021-04-06 14:02:21 +02:00
Sergiu Deitsch
82320a8a88
Merge pull request #631 from xiaobfly/master
fixed file extension
2021-04-04 03:17:33 +02:00
Sergiu Deitsch
bf183f44f2
Merge pull request #632 from sergiud/cmake-default-shared-libs
cmake: build shared libs by default
2021-04-02 01:45:30 +02:00
Sergiu Deitsch
9ee010d853 cmake: build shared libs by default 2021-04-02 01:23:43 +02:00
xiaobfly
4fca1b9673 fixed filename extension 2021-04-01 17:21:19 +08:00
Rodrigo Queiro
30bb9086d2 bazel: use expand_template instead of genrules
This lets us drop the dependency on the preprocessed headers in
src/windows/glog/.

For some reason, this lets Bazel realize we've failed to declare a
dependency on dirent.h, so I added that too.
2021-03-31 16:08:50 +02:00
Sergiu Deitsch
d66e593188
Merge pull request #618 from sergiud/ac_cv___attribute___printf_4_5
build: set ac_cv___attribute___printf_4_5
2021-03-31 10:32:49 +02:00
Sergiu Deitsch
d5fdcfefcd
Merge pull request #623 from sergiud/language-version
document C++ version
2021-03-31 10:32:39 +02: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
Sergiu Deitsch
5abed00e3c
Merge pull request #626 from sergiud/use-c++-headers
use C++ headers
2021-03-31 09:42:48 +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
2f7d608a92
Merge pull request #627 from sergiud/cmake-no-c-compiler
cmake: do not require a C compiler
2021-03-31 02:23:19 +02:00
Sergiu Deitsch
3f4df6aee9 cmake: do not require a C compiler 2021-03-31 01:44:15 +02:00
Sergiu Deitsch
7a6e743eb6
Merge pull request #624 from sergiud/qualify-std-string
fully qualify std::string
2021-03-31 00:45:25 +02:00
Sergiu Deitsch
e27f141194
Merge pull request #622 from sergiud/max_log_size-overflow
handle --max_log_size overflow
2021-03-30 23:59:53 +02:00
Sergiu Deitsch
0b3c27d042 fully qualify std::string 2021-03-30 23:47:48 +02:00
Sergiu Deitsch
5c57edfbc8 readme: document C++ version 2021-03-30 23:37:15 +02:00
Sergiu Deitsch
20984f9730
Merge pull request #621 from sergiud/cmake-use-gtest
cmake: optionally use gtest
2021-03-30 23:23:01 +02:00
Sergiu Deitsch
3533c22d21 handle --max_log_size overflow 2021-03-30 23:16:40 +02:00
Sergiu Deitsch
be25d94c21 cmake: optionally use gtest 2021-03-30 22:41:15 +02:00
Sergiu Deitsch
45fdc922de
Merge pull request #619 from sergiud/cmake-proper-symbol-export
cmake: export symbols selectively
2021-03-30 22:13:09 +02:00
Sergiu Deitsch
c30896d3d5 cmake: export symbols selectively 2021-03-30 21:41:52 +02:00
Sergiu Deitsch
b442ef8070 build: set ac_cv___attribute___printf_4_5 2021-03-30 21:12:09 +02:00
Rodrigo Queiro
d4e8ebab7e Add layering_check to Bazel CI.
This will avoid regressions on #596.
2021-03-02 10:32:06 +01:00
Rodrigo Queiro
0863ad797c bazel: declare headers in top-level rule
Fixes #596.
2021-03-02 10:32:06 +01:00
Rodrigo Queiro
ce50c57b9e Rename BUILD to BUILD.bazel.
This avoids conflicts with build/ on case-insensitive filesystems.

Fixes #606.
2021-03-01 13:23:27 +01:00
Sergiu Deitsch
d824eae3cd
Merge pull request #613 from sergiud/cmake-unwind-patch-match
cmake: fixed unwind patch component match check
2021-02-24 17:39:10 +01:00
Sergiu Deitsch
df3ce126d6 cmake: fixed unwind patch component match check 2021-02-23 21:26:22 +01:00
Sergiu Deitsch
246e49ac48
Merge pull request #610 from sergiud/readme-cleanup
consolidate readme
2021-02-22 22:19:49 +01:00
Marco
9881ea5969
Fix race conditions in LOG_EVERY_N (#492)
* Use CMakeLists.txt to check the availability of std::atomic<>
* Declare the static integer counters as std::atomic<int> instead of int if C++11's atomic is available
* implement fallback mechanism for pre C++11 compilers
* src/glog/logging.h.in: fix wrong atomic increment
* src/glog/logging.h.in: make modulo operations atomic
2021-02-22 22:17:25 +01:00
Sergiu Deitsch
4cef723320
Merge pull request #611 from sergiud/incorrect-cygwin64-define
replaced __CYGWIN32__ and __CYGWIN64__ by __CYGWIN__
2021-02-22 22:05:23 +01:00
Sergiu Deitsch
544b4a4f50
Merge pull request #609 from sergiud/cmake-unwind-empty-patch-component
cmake: handle empty unwind version patch component
2021-02-22 22:05:07 +01:00
Sergiu Deitsch
b9be6bb5db consolidate readme 2021-02-22 22:04:05 +01:00
Liang Zou
6d14ac3efe Fix the symlink creation bug if using bazel 2021-02-20 17:34:31 +01:00
Sergiu Deitsch
795384957d replaced __CYGWIN32__ and __CYGWIN64__ by __CYGWIN__ 2021-02-13 14:52:26 +01:00
Sergiu Deitsch
e370cd5166 bump version 2021-02-13 12:23:32 +01:00
Sergiu Deitsch
3b21da69ea cmake: handle empty unwind version patch component 2021-02-13 12:14:35 +01: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
4f09bed0b4
Merge pull request #263 from kennyyu/tsan_benign_race
Annotate LOG_EVERY_N macros as a benign race for TSAN
2021-02-13 11:55:42 +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
Sergiu Deitsch
7a8b66aa17
Merge pull request #593 from aesophor/fix-typo
src/logging.cc: Fix a typo in comment
2021-02-13 11:46:55 +01:00
Sergiu Deitsch
6d5da21549
Merge pull request #608 from mahiuchun/stl
Make stl_logging_unittest more robust.
2021-02-13 11:43:16 +01:00
Hill Ma
15d51a17cc Make stl_logging_unittest more robust. 2021-02-08 21:16:29 -08: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
Sergiu Deitsch
c8f8135a57
Merge pull request #502 from aesophor/encapsulate-log-cleaner
src/logging.cc: encapsulate log cleaner, match logfile with <base_filename_><date>-<time>.<pid>
2020-10-03 09:52:36 +02:00
Marco
d82641f709
Merge branch 'master' into encapsulate-log-cleaner 2020-10-03 09:52:23 +08:00
Sergiu Deitsch
cec37e1cf5
Merge pull request #542 from xulongwu4/master
Use NULL to indicate uninitialized VLOG_IS_ON site.
2020-10-03 01:12:22 +02:00
Yuhong Guo
b55437ac10 Fix logmailer problem for dynamic lib. 2020-10-03 01:01:05 +02:00
Sergiu Deitsch
c5dcae8306
Merge pull request #467 from sukill/master
declare FLAGS_vmodule
2020-10-03 00:58:19 +02:00
Sergiu Deitsch
b30a009faa
Merge pull request #585 from sergiud/remove-drop-autoconf-support
remove autoconf support
2020-10-03 00:49:36 +02:00
Sergiu Deitsch
b539557b36 removed autoconf support 2020-10-02 20:32:41 +02:00
Sergiu Deitsch
d516278b1c
Merge pull request #540 from pwnall/fix-uv-warn
Fix unused parameter warning on gcc.
2020-10-01 10:45:55 +02:00
Victor Costan
6c0a5fcb53 Fix unused parameter warning on gcc. 2020-09-30 00:53:10 -07: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
fcc9da24a6
Merge pull request #545 from julianaito/master
OpenBSD/powerpc: clang does not define _CALL_*, use proper ifdef instead
2020-09-29 22:19:20 +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
4c5a60c3c3
Merge pull request #551 from aesophor/replace-sprintf
Replace sprintf() with snprintf() (#536)
2020-09-29 22:12:45 +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
Sergiu Deitsch
024b095d7e
Merge pull request #552 from huangqinjin/master
Make message text null-terminated
2020-09-29 22:11:22 +02:00
Sergiu Deitsch
d442460690
Merge pull request #579 from arj-fb/safety_check_at_SymbolizeAndDemangle
Added check for if info.dli_sname is NULL
2020-09-29 22:10:08 +02:00
Sergiu Deitsch
5bc1e1177c
Merge pull request #580 from Yicong-Huang/patch-1
Make cmake build on path with spaces.
2020-09-29 22:09:21 +02:00
Sergiu Deitsch
af4df08e5b
Merge pull request #576 from santigl/santigl/streambuf-overflow-override
Remove `virtual` from `LogStreamBuf::overflow()`
2020-09-29 22:07:56 +02:00
Santiago Gil
7258189847 Add override to LogStreamBuf::overflow()
Prevents warnings such as:
```
glog/logging.h:1122:20: error: ‘virtual
std::basic_streambuf<char>::int_type
google::base_logging::LogStreamBuf::overflow(std::basic_streambuf<char>::int_type)’
can be marked override [-Werror=suggest-override]
   virtual int_type overflow(int_type ch) {
                    ^~~~~~~~
```

Signed-off-by: Santiago Gil <santiago.gil@codethink.co.uk>
2020-09-24 10:48:00 +01:00
Yicong Huang
c652590d84
Update CMakeLists.txt
wrap the path with double quotation so that it can build on path with spaces.
2020-09-15 22:22:13 -07:00
Arjun Moudgil
e5ef2728bd Added check for if info.dli_sname is NULL
Check if info.dli_sname is NULL,
If the image containing addr is found, but no nearest symbol was found, the dli_sname and dli_saddr fields are set to NULL.
2020-09-15 20:46:35 -04: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
Phillipp Schoppmann
0a2e5931bd
Fix build for Emscripten (#546)
Add back config_setting for WASM (no HAVE_SYSCALL_H)

Since there is no config_setting for Linux
(https://github.com/bazelbuild/bazel/issues/11107), Linux needs to be
the default case.
2020-05-13 09:36:55 +09: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
Marco Wang
2e87f98fe4 Replace sprintf() with snprintf() (#536)
sprintf poses two security risks:
(1) write to memory where it shouldn't
(2) read from memory where it shouldn't

This commit replaces the use of sprintf() with snprintf()
which has a size parameter to ensure the problems mentioned
above won't take place.
2020-05-08 14:50:55 +08:00
Charlène Wendling
7001ab9ecb OpenBSD/powerpc: clang does not define _CALL_* use proper ifdef
OpenBSD/macppc uses now clang by default and does not define _CALL_SYSV,
use the alternative for such platforms.
2020-04-27 15:50:32 +02:00
Longwu Ou
4a82a856d2 Use NULL to indicate uninitialized VLOG_IS_ON site. 2020-04-26 22:57:58 -04:00
Doug Rabson
3ba8976592 fix bazel build for freebsd 2020-03-25 10:17:39 +01: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
Sergiu Deitsch
7da49d48a3
Merge pull request #515 from segfaulthunter/doc
Explain log levels.
2020-03-25 09:10:52 +01:00
Lily
940335d82f
Add vcpkg installation instructions (#517)
Add vcpkg installation instructions
2020-03-25 09:08:16 +01:00
Sergiu Deitsch
dfc0e441c5
Merge pull request #523 from edbaunton/cmake-have-symbolize
Allow CMake user to disable Symbolize functionality
2020-03-25 09:05:22 +01:00
Ed Baunton
eb13e4f67c Allow CMake user to disable Symbolize functionality
Currently the user has to rely on the HAVE_SYMBOLIZE detection inside
CMakeLists.txt without having any control over whether it should be used.

Add support for disabling HAVE_SYMBOLIZE at configure time so user can specify
`cmake -DHAVE_SYMBOLIZE=0`.

Signed-off-by: Ed Baunton <ebaunton1@bloomberg.net>
2020-02-15 17:16:14 -05:00
Michael
195d416e3b Add target existence checks to Unwind find module (#518)
* Add target existence checks to Unwind find module

The build systems of projects depending on Glog may call the Unwind find
module multiple times. In these cases, the current unwind find module tries
to create a duplicate unwind::unwind target, crashing the build. This
patch adds an existence check before target creation to fix this issue.

Signed-off-by: Michael Darr <mdarr@matician.com>

* Alphabetize contributor list

* Fix inconsistent CMake style

Signed-off-by: Michael Darr <medarr@email.wm.edu>
2020-01-17 09:17:28 +01:00
Florian Mayer
74076bebc3 Explain log levels. 2020-01-10 10:50:12 +00:00
Michael Spang
130a3e10de Use file offsets in traces if object has no symbols (#513)
Fallback to using file offsets if no symbol is found, like we do if the
object could not be opened.

This makes backtraces usable even if objects in the trace are stripped,
since the trace can be symbolized by post-processing it with a tool like
asan_symbolize.py.

Note that this is not currently compatible with SymbolizeCallback as
this overwrites the filename in the buffer. The behavior is unchanged
in that case.

Closes: #514
2020-01-08 15:34:39 +09:00
Shinichiro Hamaji
445af7ef7e
Merge pull request #508 from xiaosuo/close
Don't call close(2) more than once
2019-12-24 11:38:26 +09:00
Changli Gao
a35e612c55 Don't call close(2) more than once
Don't call close(2) more then once, even though close(2) returns -1.

See the manual page for details.
2019-12-21 23:24:28 +08: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
Rodrigo Queiro
1b7d541431 Add note about namespace on Win32. 2019-11-27 18:24:27 +01:00
Rodrigo Queiro
95a3655796 Remove unnecessary defines
The only macro referenced by the public headers is GOOGLE_GLOG_DLL_DECL.
This means fewer defines are propagated to rules that depend on glog.
2019-11-27 18:24:27 +01:00
Rodrigo Queiro
c0d2ceade6 Avoid leaking config.h
This uses strip_include_prefix to avoid leaking private headers
(config.h, port.h). This needs a workaround to prevent a "missing
dependency declarations" error.
2019-11-27 18:24:27 +01:00
Luc Bertrand
925858d996 add windows target to bazel CI 2019-11-20 14:21:54 +01:00
Luc Bertrand
20919b325e add windows support for bazel bazed build 2019-11-20 14:21:54 +01:00
Luc Bertrand
7f732529da apply buildifier on glog.bzl 2019-11-20 14:21:54 +01:00
Sergiu Deitsch
1863b4228c
Merge pull request #368 from UVV-gh/cmake-sdk-fix
Use libunwind as an imported target
2019-11-10 17:02:31 +01:00
Sergiu Deitsch
c0463b17b6 added cmake package config unit test 2019-11-10 15:46:47 +01:00
Sergiu Deitsch
9a43cfb8d2 install unwind find module alongside glog 2019-11-10 11:09:18 +01:00
Sergiu Deitsch
19570c69c9 renamed and cleaned up the unwind find module 2019-11-10 11:09:14 +01: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
Sergiu Deitsch
0bf00f95aa
Merge pull request #491 from aesophor/update-doc
doc: add information about log cleaner
2019-11-05 11:34:50 +01:00
Marco Wang
0f4975a68d doc: add information about log cleaner 2019-11-05 17:33:07 +08:00
Sergiu Deitsch
5ef521d4ad
Merge pull request #487 from Telunsu/fix_wrong_assignment
src/logging.cc: fix wrong assignment
2019-11-04 09:08:57 +01:00
yww
e58e596f13 src/logging.cc: fix wrong assignment 2019-11-04 14:35:26 +08:00
Sergiu Deitsch
f811ae9ed1
Merge pull request #485 from ffontaine/master
src/symbolize.cc: do not check for HAVE_DLFCN_H for macOS
2019-11-02 13:18:29 +01:00
Fabrice Fontaine
3ee89c86d6 src/symbolize.cc: do not check for HAVE_DLFCN_H for macOS
This seems to raise a build failure, see
10498b485f (commitcomment-35770392)

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2019-11-02 10:41:05 +01:00
Sergiu Deitsch
4d6aff4184
Merge pull request #477 from ffontaine/master
src/utilities: fix build without pthread
2019-11-02 10:24:15 +01:00
Vyacheslav Yurkov
742fe94f22 Use libunwind as an imported target
When UNWIND_LIBRARY is used directly as a public dependency then
absolute path is stored in cmake config file. This is an issue when
glog is used as part of an SDK, which was built somewhere else. When
SDK is installed on developer's machine, cmake config contains a full
path to non-existent location. The solution is to find libunwind
during configure stage and store target name as a dependency, not a full path.
Cmake module looks for libunwind and libunwind-PLAT, where PLAT is one of
supported platforms.

Signed-off-by: Vyacheslav Yurkov <uvv.mail@gmail.com>
2019-11-02 02:42:25 +01:00
Fabrice Fontaine
9630e0e848 src/utilities: fix build without pthread
- Remove is_default_thread function which is an internal and not used
  function
- Remove g_main_thread_id as it was used only by is_default_thread

Fixes:
 - http://autobuild.buildroot.net/results/5320bbe1205e782e3516d9bead8d1ed825bcbaad

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2019-11-02 02:09:07 +01:00
Sergiu Deitsch
fd3dc2c633
Merge pull request #484 from sergiud/remove-executable-flag
removed executable flag from .cmake file
2019-11-02 01:53:12 +01:00
Sergiu Deitsch
eec1435d52 removed executable flag from .cmake file 2019-11-02 00:20:22 +01:00
Sergiu Deitsch
e227697b0b
Merge pull request #483 from loop0day/enhance
Support pkg-config
2019-11-01 16:33:05 +01:00
loop0day
82d0860b76 Support pkg-config 2019-11-01 22:28:58 +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
242130d305
Merge pull request #350 from TheModMaker/fixIosSim
Allow getpwuid_r to return missing entry.
2019-10-31 23:00:31 +01:00
Sergiu Deitsch
1a4c47a749
Merge pull request #88 from kekstee/master
Respect configured docdir
2019-10-31 22:56:05 +01:00
Sergiu Deitsch
f17d11aa8c
Merge pull request #161 from mpercy/thread-local-libunwind-2
Use thread local for libunwind GetStackTrace() reentrancy protection
2019-10-31 22:54:34 +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
Sergiu Deitsch
0f83e53c43
Merge pull request #443 from ammubhave/fix_musl_build
Fix symbolize_unittest for musl builds
2019-10-31 22:45:26 +01:00
Sergiu Deitsch
e558d50b0a
Merge pull request #370 from hemantbits/patch-1
Fix warnings
2019-10-31 22:44:48 +01:00
Sergiu Deitsch
30f7f3ee93
Merge pull request #479 from neheb/patch-2
logging: Fix compilation with uClibc++
2019-10-31 22:42:13 +01:00
Sergiu Deitsch
6f5699a236
Merge pull request #460 from neheb/patch-1
googletest: Switch to nanosleep
2019-10-31 22:41:36 +01:00
Rosen Penev
e24276a35e
logging: Fix compilation with uClibc++
uClibc++ has compiler support for C++11, but not the functions.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-10-31 13:04:29 -07:00
Rosen Penev
1d762fa5b0
googletest: Switch to nanosleep
usleep is deprecated and optionally not available with uClibc-ng.
2019-10-31 13:00:48 -07:00
Sergiu Deitsch
1655f4f910
Merge pull request #475 from ffontaine/master
src/symbolize.cc: fix build without dlfcn.h
2019-10-31 19:11:56 +01:00
Fabrice Fontaine
10498b485f src/symbolize.cc: fix build without dlfcn.h
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2019-10-29 22:12:39 +01:00
sukill
1e6b9f3291 declare FLAGS_vmodule 2019-09-04 18:39:21 +09:00
Shinichiro Hamaji
4cc89c9e2b
Merge pull request #465 from durswd/support_clang-cl
I supported clang-cl with BUILD_SHARED_LIBS
2019-09-02 21:16:42 -07:00
durswd
a8fad525e5 Changed the order of conditions 2019-09-02 13:28:18 +09:00
durswd
00cb9f4e6f I supported clang-cl with BUILD_SHARED_LIBS 2019-09-02 12:32:29 +09:00
Fumitoshi Ukai
ba8a9f6952
fix typo: TOOD -> TODO (#448) 2019-05-07 16:02:06 +09:00
Philipp Wollermann
0d0c254317 Don't test on Ubuntu 14.04 (#446)
Ubuntu 14.04 is about to be end-of-life and Bazel CI will stop supporting it shortly afterwards.

Context: https://groups.google.com/d/msg/bazel-dev/_D6XzfNkQQE/8TNKiNmsCAAJ
2019-04-24 10:48:51 +09:00
Shuhei Takahashi
6ca3d3cf58 Fix stacktrace on bazel build. (#347)
We need at least following defs to be set to print stacktrace in
failure signal handler.

- HAVE_UNWIND_H: on Linux and macOS. unwind.h is usually present
  by default on those OSes.
- HAVE_DLADDR: on macOS.

Windows is not cared because glog can not be built with bazel
on Windows today.
2019-04-12 10:09:41 +09:00
Amol Bhave
834dd780bf Fix symbolize_unittest for musl builds
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>
2019-04-03 12:08:35 -07:00
Andrei Sekretenko
94a54120de Extended the LogSink interface to be able to pass microseconds. 2019-03-27 18:27:31 +01:00
Shinichiro Hamaji
96a2f23dca
Merge pull request #419 from shinh/release-0-4-0
Release 0.4.0
2019-03-22 11:51:46 +09:00
Shinichiro Hamaji
5c576f78c4
Merge pull request #431 from romkatv/disallow_prefix
Protect macros from user code to the left of them
2019-02-18 11:49:24 +09:00
romkatv
29dd5da60f Add Roman Perepelitsa to AUTHORS and CONTRIBUTORS 2019-02-16 19:31:50 +01:00
romkatv
4db0631346 Protect macros from user code to the left of them 2019-02-16 19:23:36 +01:00
Shinichiro Hamaji
460ec1f564 Merge branch 'master' into release-0-4-0 2019-02-14 17:46:12 +09:00
Shinichiro Hamaji
41f4bf9cbc
Merge pull request #425 from plmuon/remove-time-from-raw-logging
remove time from raw logging
2019-02-02 11:00:29 +09:00
Shinichiro Hamaji
64041397b3 Use static to define CheckStackTrace on non-GNU (#429)
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
2019-02-02 10:13:43 +09:00
Shinichiro Hamaji
7f91846ca1 Stop using auto_ptr (#428)
Stop using auto_ptr

std::unique_ptr requires -std=c++11. just use raw pointer.
2019-02-01 17:35:02 +09:00
Peter Mutsaers
e5588de96d remove time from raw logging 2019-01-29 23:38:03 +01:00
Fumitoshi Ukai
7ffca211fe
fix appveyor link (#424)
project/google/glog -> project/google-admin/glog
2019-01-28 14:06:21 +09:00
Shinichiro Hamaji
ed1ef7c4db Apply #397 to glog/logging.h.in
windows/glog/logging.h is expected to be generated by
src/windows/preprocess.sh and should not be modified directly.
2019-01-24 09:25:43 +09:00
Sergiu Deitsch
1431a17f37
Merge pull request #420 from kwaegel/patch-1
Use push/pop macro when supressing warning
2019-01-23 08:21:27 +01:00
Shinichiro Hamaji
1d98d00c7e Update ChangeLog to record release dates at least 2019-01-23 12:24:15 +09:00
Ky Waegel
342fa2674c
Use push/pop macro when supressing warning
* Same as PR #397 , but for the `.in` file. Useful for some unusual cross-platform build environments (e.g. WSL).
2019-01-22 10:59:05 -08:00
Shinichiro Hamaji
406b0e702f glog: release 0.4.0 2019-01-22 21:00:50 +09:00
Shinichiro Hamaji
6d6d31872e Run src/windows/preprocess.sh 2019-01-22 20:58:13 +09:00
Haakan Younes
5d46e1bcfc Add demangle support for ABI tags. (#416)
Support ABI tags after <local-source-name> in demangle.cc.
Update the reference URL.

Fixes #50
2019-01-07 15:30:23 +09:00
Thomas Anderson
7fcb278d1e Fix demangling template parameter packs (#414)
* 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)
2019-01-07 15:26:08 +09:00
Sergiu Deitsch
0e4ce7c0c0
Merge pull request #410 from jackwish/fix/build/cleanup
build: cleanup temps and remove NEWS
2019-01-01 01:27:42 +01:00
Prem Nair
e0f7bfc6ca Add kwargs to glog_library 2018-12-31 14:20:45 +00:00
Prem Nair
0bc2d94cd1 Fix bazel build with gflags
The code references `@ac_cv_have_libgflags@` but not `@ac_cv_have_libgflags_h@`. This corrects that.

`int(with_gflags)` incorporates the possibility of `True/False`: https://github.com/bazelbuild/bazel/issues/4792
2018-12-31 14:20:45 +00:00
Sergiu Deitsch
e6939aa539
Merge pull request #412 from pwnall/fix_warn
Fix unused variable warning in GCC
2018-12-31 15:08:41 +01:00
Victor Costan
0989ffadb8 Fix unused variable warning in GCC. 2018-12-25 16:54:08 -08:00
王振华 (WANG Zhenhua)
293a38cc46 build: remove NEWS realated things
With automake GNU standard relaxed, these are no longer needed.
2018-12-19 12:02:35 +00:00
王振华 (WANG Zhenhua)
5a22c3cdc0 build: remove automake temporaries 2018-12-19 11:54:06 +00:00
Sergiu Deitsch
6deff5ab23
Merge pull request #408 from jackwish/fix/build/readme
automake: relax GNU standard directory style
2018-12-18 16:49:36 +01:00
王振华 (WANG Zhenhua)
da37a6c30a update all README naming
Now, we can build.
2018-12-18 07:00:06 +00:00
王振华 (WANG Zhenhua)
1231a37f0b automake: relax GNU standard directory style
GNU standard assumes `README` under root dir, while PR #403
didn't fix the building issue exactually.
https://www.gnu.org/software/automake/manual/html_node/List-of-Automake-options.html
2018-12-18 06:50:44 +00:00
Sergiu Deitsch
1d900193d8
Merge pull request #403 from NeroBurner/fix_make_for_README
update README.md filename in Makefile.am
2018-12-13 08:32:26 +01:00
Sergiu Deitsch
a2e49f75f8
Merge pull request #406 from NeroBurner/ci_enable_clang
ci: add clang-cxx17 toolchain
2018-12-13 08:29:57 +01:00
Sergiu Deitsch
d328081115
Merge pull request #405 from NeroBurner/remove_register_keyword
remove register keyword from unittest
2018-12-13 08:29:32 +01:00
NeroBurner
e0cabc5404 remove register keyword from unittest 2018-12-13 08:15:52 +01:00
NeroBurner
5ab6736b40 ci: add clang-cxx17 toolchain 2018-12-13 07:49:59 +01:00
NeroBurner
e3738a25ec update README.md filename in Makefile.am 2018-12-12 13:34:44 +01:00
Sergiu Deitsch
702c533ce0
Merge pull request #397 from kwaegel/patch-1
Use push/pop macro when supressing warning
2018-12-12 10:18:17 +01:00
Roman Gershman
6adf6d7ae5 fix debug build using gcc -fsanitize=undefined (#374) 2018-12-12 10:16:49 +01:00
Sergiu Deitsch
125d6b3df4
Merge pull request #330 from NeroBurner/ci_travis_appveyor_master
ci: add appveyor and travis config
2018-12-12 09:00:35 +01:00
Ky Waegel
615d0b9712
Use push/pop macro when supressing warning
* Previous implementation did not correctly restore the warning state if initially disabled.
2018-11-27 17:35:07 -08:00
Taiju Tsuiki
781096619d Upstream Chromium local changes to symbolize.cc (#391)
* 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.
2018-11-21 11:14:38 +09:00
Rodrigo Queiro
de82428e52 Use gflags 2.2.2 in Bazel build
The newly-released gflags 2.2.2 includes fixes to the Bazel BUILD files
that weren't in the older 2.2.1 release.
2018-11-19 09:57:51 +01:00
Fumitoshi Ukai
c44e3bbb8f
Merge pull request #388 from tzik/pread
Make symbolize.cc thread safe even on shared fds
2018-11-14 16:03:33 +09:00
tzik
1081df6e5c Make symbolize.cc thread safe even on shared fds
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.
2018-11-13 12:55:09 +09:00
Yun Peng
5c292672df Use Starlark version of http_archive
To fix https://github.com/google/glog/issues/376
2018-11-05 11:50:58 +01:00
Sergiu Deitsch
e364e754a6
Merge pull request #367 from bsilver8192/master
Don't crash on some forms of invalid ELF files
2018-10-23 21:50:06 +02:00
Sergiu Deitsch
c4bada1876
Merge pull request #371 from zaporozhets/fix_mistyping_in_comment
Fix mistype in comment
2018-10-23 21:42:15 +02:00
Taras Zaporozhets
a9393f0909 Fix mistype in comment 2018-10-17 15:54:37 +03:00
NeroBurner
b8221040d2 [skip CI] add badges to README, rename to markdown 2018-10-15 13:34:52 +02:00
NeroBurner
a29380601b set timeout for stacktrace unittest
The stacktrace unittest hangs when compiled with MSVC. The default
timeout is 1500 seconds. Change it to 30 seconds
2018-10-15 13:34:52 +02:00
NeroBurner
0cf2af6e69 ci: add appveyor and travis config
Add toolchain directory with cmake toolchain files used to find
compilers and set C++ versions

The following configurations are build on Windows using appveyor
service:
- enable MSVC 2015 SDK 8.1
- enable MSVC 2015
- enable MSVC 2017
- enable MSVC 2017 c++17
- enable mingw-cxx11
- enable mingw-gnuxx11
- enable mingw-cxx17

The following configurations are build on Linux using travis service:
- enable Ubuntu 14.04 amd64/i386, C++11
- enable Ubuntu 16.04 amd64/i386, C++11
- enable Ubuntu 18.04 amd64 C++98, C++11, GNU++11, C++17
- enable mingw-w64 on Ubuntu 18.04 amd64, C++11, GNU++11, C++17

The tests for cross compiled mingw windows binaries are run using wine64
2018-10-15 13:34:52 +02:00
Hemant
41a6a7880e
Fix warnings
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() {
             ^~~~~~~
2018-10-12 13:25:19 +01:00
Brian Silverman
91e3fdcefc Don't crash on some forms of invalid ELF files
With a few tweaks, it will fail to look up symbol names in these cases
instead.
2018-09-18 17:08:27 -07:00
Jacob Trimble
a606c3187b Allow getpwuid_r to return missing entry.
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.
2018-07-27 10:58:18 -07:00
Sergiu Deitsch
8d7a107d68
Merge pull request #344 from dzung-hoang/master
Fix errors with BUILD_SHARED_LIBS=ON for Visual Studio 2017 (fixes #343)
2018-07-16 09:18:06 +02:00
Dzung Hoang
87b82b2362 fix errors with BUILD_SHARED_LIBS=ON for Visual Studio 2017 2018-07-16 02:10:05 -05:00
levosos
367518f650 copts are passed correctly when building w/o gflags
resolves #338
2018-07-09 11:14:33 +02:00
Sergiu Deitsch
046f441a39
generate an empty NEWS file (fixes #340) 2018-07-06 12:41:50 +02:00
Sergiu Deitsch
039608d46a
Merge pull request #336 from NeroBurner/patch-1
fix glog.html link to gflags repository
2018-07-03 20:11:28 +02:00
Sergiu Deitsch
5514af001e
Merge pull request #337 from NeroBurner/remove_NEWS
Delete NEWS
2018-07-03 20:10:50 +02:00
NeroBurner
520186c233 Delete NEWS
remove unused 10 year old empty file
2018-07-02 14:21:54 +02:00
NeroBurner
aa9aaac09f
fix glog.html link to gflags repository
Fixes Issue https://github.com/google/glog/issues/325
2018-07-02 11:54:44 +02:00
Sergiu Deitsch
3267f3e1a8
Merge pull request #331 from NeroBurner/fix_windows_logging_ut
Fix windows logging ut
2018-06-29 12:31:45 +02:00
Sergiu Deitsch
c72907c4a8
Merge pull request #332 from NeroBurner/fix_cxx17_throws
tests: fix compilation with C++17
2018-06-21 15:20:24 +02:00
NeroBurner
5fa1d59065 tests: fix compilation with C++17
Remove throw() commands as they were deprecated with C++11 and are
removed with C++17
2018-06-21 14:05:09 +02:00
Artem Dinaburg
f39f78c7cc Define constants for _open and silence some warnings 2018-06-20 12:50:50 +02:00
Artem Dinaburg
b54793d232 Windows has the fc utility to compare files instead of diff 2018-06-20 12:50:50 +02:00
Artem Dinaburg
62c3e3cd56 The %p format is implementation defined. Compare it via a special token,
just like the null pointer test.
2018-06-20 12:50:50 +02:00
Sergiu Deitsch
0301bfdd39
Merge pull request #324 from NeroBurner/fix_mingw_cross_compile
Fix mingw cross compile
2018-06-19 14:36:39 +02:00
loop0day
abce78806c cmake: renamed GFLAGS_NAMESPACE to GLOG_GFLAGS_NAMESPACE (#318)
This eliminates a conflict between glog and gflags preprocessor definition of GFLAGS_NAMESPACE that can cause the gflags namespace detection to fail (fixes #317).
2018-06-01 15:00:59 +02:00
NeroBurner
364fad5649 port: remove unused includes 2018-06-01 14:50:12 +02:00
NeroBurner
800bd423e4 port: split localtime_r definition and impl 2018-06-01 14:50:12 +02:00
NeroBurner
7450a8b345 mingw-w64: check if localtime_r exists
- check in cmake if localtime_r exists
- if localtime_r is missing (MSVC, mingw-w64 on linux) redefine it using
  localtime_s
2018-06-01 14:50:11 +02:00
NeroBurner
0797f7382b mingw-w64: fix port.h pthread recreation 2018-06-01 14:50:10 +02:00
NeroBurner
d354e2e8f9 mingw-w64: fix dbghelp on case sensitive systems
- fix dbhelp.h include
- fix dbghelp check and link
2018-06-01 14:50:07 +02:00
NeroBurner
06a8ee0976 logging: fix basetsd on case sensitive sytems 2018-06-01 14:50:06 +02:00
Daiki Maekawa
2faa186e62 cmake: added BUILD_SHARED_LIBS option (#313) 2018-04-26 08:46:24 +02:00
Ruslan Baratov
d064ab8d0a Fix build for Android API < 21 2018-04-22 23:54:24 +03:00
Rodrigo Queiro
e0341da07b Add Bazel CI configuration
This was previously present in
https://github.com/bazelbuild/continuous-integration, but the Bazel team
asked us to move it to our repo. It will be helpful if we need to change
the build configuration, eg to add new platforms.
2018-04-18 11:54:56 +02:00
Akiyoshi Ochiai
dd2b93d761 Fix __attribute__((noreturn)) mismatch warning in Bazel build 2018-04-18 10:15:54 +02: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
Sergiu Deitsch
11afec2795
Merge pull request #303 from Nazg-Gul/reincluded-config
Fix redefined warnings from config.h
2018-03-21 13:44:44 +01:00
Shinichiro Hamaji
643f6d4678
Merge pull request #305 from samuela/patch-1
Make int conversion explicit and fix clang warning
2018-03-21 21:43:40 +09:00
samuela
838753987f
Make int conversion explicit and fix clang warning 2018-03-20 18:03:46 -07:00
Sergey Sharybin
418f9020e3 Fix redefined warnings from config.h
The issue was caused by config.h header being included from both
header files and implementation files.

Proposed solution is to have regular header guard in the generated
config.h. Benefit of this solution is that it's least intrusive.
Downside is that it only solves issue for CMake build system, and
autoconf one is not fixed since header template is automatically
generated by autoheader who does not add header guard.
2018-03-20 11:14:06 +01:00
Shinichiro Hamaji
1fe7e94ac6
Merge pull request #304 from Nazg-Gul/terminfo-konsole
konsole family of terminfo supports colored output
2018-03-20 18:14:33 +09: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
Sergiu Deitsch
43dafc5bf2 cmake: fixed gcc warning 2018-03-19 00:21:33 +01:00
Sergiu Deitsch
a97d6b0e1c
Symbolizer support for mingw and cygwin (#208)
* added dbghelp symbolizer support for mingw and cygwin
* fixed compiler errors in case <stdint.h> is not available
* cmake: check whether SymFromAddr actually works
2018-02-27 21:03:20 +01:00
Sergiu Deitsch
1aec14edf4 cmake: do not introduce a policy stack in the package config 2018-02-23 10:16:24 +01:00
Sergiu Deitsch
4c4631c9b3
Merge pull request #292 from Mizux/master
CMake Update
2018-02-10 14:34:47 +01:00
Corentin Le Molgat
6b6e38a7d5 Rework CMake glog VERSION management.
- Use of Project version properties instead of custom variables
- fix missmatch between VERSION (build version) and SOVERSION (API version)
src: https://cmake.org/cmake/help/latest/prop_tgt/VERSION.html#prop_tgt:VERSION
2018-02-06 10:37:26 +01:00
Corentin Le Molgat
4ef88d510e remove uneeded enable_testing()
CTest module already provides it
2018-02-06 10:37:26 +01:00
Corentin Le Molgat
cbfd86a1d8 Provide glog::glog ALIAs
Useful when using glog as subproject.
Add an explanation at top like in gflags.git CMakeLists.txt
2018-02-06 10:37:26 +01:00
Rodrigo Queiro
55cc27b6ec Bazel: make example more portable 2018-02-01 14:13:46 +01:00
Rodrigo Queiro
bc9a491033 Allow using glog/stl_logging.h with Bazel
Fixes #289.
2018-02-01 14:13:46 +01:00
Rodrigo Queiro
3106945d8d Add workaround for Bazel build on macOS
This works around https://github.com/bazelbuild/bazel/issues/3979,
and so closes #282.
2018-01-16 17:06:15 +01:00
Sergiu Deitsch
028d37889a cmake: remove config.h from public headers (closes #238) 2018-01-04 15:20:26 +01:00
Sergiu Deitsch
fb19c33b00
Merge pull request #283 from Mizux/master
Use target gflags instead of old VARIABLES
2018-01-04 14:38:21 +01:00
Mizux
63871d3e29
Use target gflags instead of old VARIABLES 2018-01-04 13:02:02 +01:00
Rodrigo Queiro
5b1aa94e4b
Merge pull request #276 from drigz/add-example
Add an example using glog from Bazel
2018-01-04 12:00:27 +01:00
Rodrigo Queiro
3efe9e4025 Add an example using glog from Bazel 2018-01-04 11:35:53 +01:00
Rodrigo Queiro
bffb4a6ee2
Merge pull request #277 from drigz/update-gflags
Update gflags to latest master
2018-01-04 11:29:54 +01:00
Sergiu Deitsch
a92e1d95c5 cmake: use gflags package config instead of a find module
This allows to avoid conflicts between third party gflags find modules floating
around. If a package provide a local version of gflags find module, clients
which locate glog will incorrectly use it. Another problem is a CMake error message
"cmake_policy PUSH without matching POP" in nested find_package calls. In summary,
we need to ensure to use the original gflags package config.
2018-01-04 02:38:42 +01:00
Sergiu Deitsch
b2c3afecaa cmake: ensure consumers do not overwrite the required policy 2018-01-02 23:36:51 +01:00
Sergiu Deitsch
ce197f26a5 removed obsolete vsprojects 2018-01-02 22:31:47 +01:00
Sergiu Deitsch
185ba48937 cmake: added a postfix for debug builds (closes #237)
This allows to deploy debug and release builds concurrently.
2018-01-02 14:38:37 +01:00
Sergiu Deitsch
f3bd836de4
Merge pull request #281 from sergiud/msvc-error-define
Fixed undeclared identifier error
2018-01-02 02:21:51 +01:00
Sergiu Deitsch
85d49f7a47 logging_unittest: fixed undeclared identifier error (fixes #267) 2018-01-02 02:18:00 +01:00
Shinichiro Hamaji
0a9f71036f
Merge pull request #278 from shinh/contrib
Update AUTHORS and CONTRIBUTORS for PR#232
2017-12-21 19:05:40 +09:00
Shinichiro Hamaji
4682134d59 Update AUTHORS and CONTRIBUTORS for PR#232 2017-12-20 17:27:27 +09:00
Rodrigo Queiro
2a593235ba Update gflags to latest master
This means that gflags no longer leaks config.h, so I had to fix a bug
in glog.bzl where config.h is generated at the wrong path.

I also switched to the best-practice for depending on git repositories,
ie using http_archive with a mirror.
2017-12-19 15:50:12 +01:00
Rodrigo Queiro
fc87161c96
Merge pull request #232 from qzmfranklin/bazel
Build with Bazel.
2017-12-18 10:20:57 +01:00
Zhongming Qu
389a7782e8 Remove the use of bind() from WORKSPACE. 2017-12-14 13:45:01 -08:00
Zhongming Qu
ea458f60b9 Remove an empty textual_hdrs field. 2017-12-14 01:03:19 -08:00
Zhongming Qu
e6e2e1372a Hide certain header files from the cc_library().
This commit addresses a few issues:

    1.  No longer leak config.h in a way similar to
            https://github.com/gflags/gflags/issues/233
        The solution of prefixing the path by 'glog_internal' is modified from
            https://github.com/gflags/gflags/issues/234

    2.  No longer expose internal headers.

    3.  Replace PACKAGE_NAME with native.package_name()

    4.  Uers can choose namespaces via the newly added 'namespace' keyword.

    5.  Replace glob with explicitly listing of files.

    6.  Make the genrules more compact using pythonic list construction.
2017-12-14 00:58:33 -08:00
Zhongming Qu
004fc8cb8e Can build with Bazel now 2017-12-14 00:58:33 -08:00
Zhongming Qu
921651e97c Build with Bazel. 2017-12-14 00:58:33 -08:00
Fumitoshi Ukai
2063b38708
Merge pull request #261 from pcc/fix3
Compute base addresses from program headers while reading /proc/self/maps.
2017-11-10 16:55:27 +09:00
Peter Collingbourne
c4d37a78cc Compute base addresses from program headers while reading /proc/self/maps.
We previously had logic to compute the base address from program
headers as part of symbolization. The problem is that we need a correct
base address earlier in order to adjust a PC into the image's address
space, as these addresses can appear in unsymbolized output.

There was previously an assumption that only the mapping that
was lowest in the address space did not need to be adjusted. This
assumption is not guaranteed (for example, the kernel may choose to
map an ET_DYN lowest) and in fact turned out to be wrong in binaries
linked with lld because the first mapping is read-only.

The solution is to move the program header reading logic into the
code that reads /proc/self/maps.

There is a change in semantics for clients that install a callback
using the InstallSymbolizeOpenObjectFileCallback function. Any such
clients will need to return a correct base address from the callback
by reading program headers using code similar to that in the function
OpenObjectFileContainingPcAndGetStartAddress.
2017-11-08 14:15:02 -08:00
Sergiu Deitsch
bac8811710
Merge pull request #106 from dimhotepus/master
Cache strlen outside of cycles (PVS-Studio)
2017-11-04 16:22:21 +01:00
Kenny Yu
4764ca65f5 Annotate LOG_EVERY_N macros as a benign race for TSAN
Summary:
Issue #80 points out several places in glog where TSAN discovers
false positives. One of these places is in the `LOG_EVERY_N` macros.
These macros are implemented by maintaining a static unprotected
integer counter, and TSAN will report data races on these counters.

Here is a minimum example to reproduce the data race:

```

void logging() {
  for (int i = 0; i < 300; ++i) {
    LOG_EVERY_N(INFO, 2) << "foo";
  }
}

int main() {
  auto t1 = std::thread(logging);
  auto t2 = std::thread(logging);
  t1.join();
  t2.join();
  return 0;
}
```

And here is the TSAN report:

```
WARNING: ThreadSanitizer: data race (pid=776850)
  Write of size 4 at 0x558de483f684 by thread T2:
    #0 logging()
    #1 void std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>)
    #2 std::_Bind_simple<void (*())()>::operator()()
    #3 std:🧵:_Impl<std::_Bind_simple<void (*())()> >::_M_run()
    #4 execute_native_thread_routine

  Previous write of size 4 at 0x558de483f684 by thread T1:
    #0 logging()
    #1 void std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>)
    #2 std::_Bind_simple<void (*())()>::operator()()
    #3 std:🧵:_Impl<std::_Bind_simple<void (*())()> >::_M_run()
    #4 execute_native_thread_routine

  Location is global '<null>' at 0x000000000000 (main+0x00000011c684)

  Thread T2 (tid=776857, running) created by main thread at:
    #0 pthread_create
    #1 __gthread_create
    #2 std:🧵:_M_start_thread(std::shared_ptr<std:🧵:_Impl_base>, void (*)())
    #3 main

  Thread T1 (tid=776856, running) created by main thread at:
    #0 pthread_create
    #1 __gthread_create
    #2 std:🧵:_M_start_thread(std::shared_ptr<std:🧵:_Impl_base>, void (*)())
    #3 main

SUMMARY: ThreadSanitizer: data race in logging()
```

To avoid noisy TSAN reports and also avoid adding a performance hit, this
change will mark these counters as benign races so that TSAN will not report
them. This change will only have an effect if we are compiling with TSAN;
there are no changes if we are not building with TSAN.

With this change, the above example no longer reports a data race when built
and run with TSAN.
2017-11-03 17:32:47 -07:00
Shinichiro Hamaji
d72e3be82c
Merge pull request #260 from ukai/shell_escape
Shell escape arguments to /bin/mail.
2017-10-31 14:30:52 +09:00
Fumitoshi Ukai
9f8a9a9a0d Shell escape arguments to /bin/mail. 2017-10-31 13:04:26 +09:00
Shinichiro Hamaji
56b81ea796 Style fixes for consistency 2017-10-20 16:11:31 +09:00
Shinichiro Hamaji
ebf81ac476 Merge pull request #245 from DariuszOstolski/issue211
Fix username lookup in case of missing USER environment variable
2017-10-20 16:09:28 +09:00
Shinichiro Hamaji
cb7b26bd71 Merge pull request #254 from DariuszOstolski/issue253
#253: Use MS preprocessor idiom to disable warning
2017-10-20 15:48:21 +09:00
Dariusz Ostolski
4912af30f9 #253: Use MS preprocessor idiom to disable warning 2017-10-18 20:56:49 +02:00
Shinichiro Hamaji
d0531421fd Merge pull request #226 from sergiud/zero-allocation-log-failure
Zero allocation fix
2017-10-12 00:25:02 +09:00
Sergiu Deitsch
2fe6508e53 fixed gcc logging failure 2017-10-11 00:45:08 +02:00
Dariusz Ostolski
9d28cac469 Added HAVE_PWD_H to cmake build 2017-09-20 18:41:07 +02:00
Dariusz Ostolski
2d3cf2681d Fix username lookup in case of missing USER environment variable 2017-09-19 22:23:53 +02:00
Shinichiro Hamaji
2a6df66252 Merge pull request #228 from sergiud/dll-export-fix
Fix for missing exports (fixes #227)
2017-08-10 00:06:08 +09:00
Sergiu Deitsch
1bfae38300 added missing exports (fixes #227) 2017-08-09 15:21:32 +02:00
Shinichiro Hamaji
246a5896f1 Merge pull request #225 from jray272/remove-log-every-n-assert
Fix LOG_EVERY_N with clang -Wunused-local-typedef
2017-08-09 16:35:05 +09:00
Jim Ray
dd19fb2466 Remove GOOGLE_GLOG_COMPILE_ASSERT
This compile time assert is no longer used anywhere in glog. Remove
it.
2017-08-09 00:09:16 -07:00
Shinichiro Hamaji
e209906823 Merge pull request #224 from jray272/run-windows-script
Run src/windows/preprocess.sh to pick up latest logging.h.in changes
2017-08-09 15:04:26 +09:00
Jim Ray
8b3023f7e4 Fix LOG_EVERY_N with clang -Wunused-local-typedef
Glog uses a pre-C++11 compile time assert to verify the validity of
the severity parameter for LOG_EVERY_N. Unfortunately, some compilers
will complain about the usage of LOG_EVERY_N with
"-Wunused-local-typedef" due to the way the compile time assert is
constructed. This makes it impossible to use LOG_EVERY_N with this
warning treated as an error.

The fix simply removes the assert entirely. This is safe to do since
you can't put anything invalid into the severity parameters without
generating a compile error elsewhere. This has been safe to do ever
since the GLOG_ prefixes were added as part of 6febec361e.

Fixes #223
2017-08-06 00:17:50 -07:00
Jim Ray
8ed1668cdb Update Windows logging.h based on 2df0ca34aa
Commit changes to src/windows/glog/logging.h that were missed in
2df0ca34aa. Because a change to src/glog/logging.h.in was made,
src/windows/preprocess.sh needed to be run.
2017-08-06 00:13:30 -07:00
Jim Ray
bb485da39a Add Jim Ray to CONTRIBUTORS 2017-08-06 00:13:30 -07:00
Shinichiro Hamaji
b3695ee325 Merge pull request #218 from andschwa/remove-sln
Update Windows docs
2017-08-01 14:41:47 +09:00
Andrew Schwartzmeyer
a2a66f611c Update Windows readme for CMake 2017-07-26 11:35:04 -07:00
Andrew Schwartzmeyer
9f121e5493 Update gitignore for CMake and Visual Studio 2017-07-26 11:34:52 -07:00
Andrew Schwartzmeyer
c7c689fbb9 Delete ancient Visual Studio Solution file. 2017-07-26 11:34:40 -07:00
Shinichiro Hamaji
3faeb50cae Merge pull request #216 from google/revert-120-master
Revert "configure.ac: Allow user to disable gflags"
2017-07-26 17:46:57 +09:00
Shinichiro Hamaji
a6ffefa7e5 Revert "configure.ac: Allow user to disable gflags" 2017-07-26 17:44:25 +09:00
Shinichiro Hamaji
dc8aa29f2c Merge pull request #120 from ribalda/master
configure.ac: Allow user to disable gflags
2017-07-19 23:51:20 +09:00
Shinichiro Hamaji
ce8799c8e2 Merge pull request #209 from sergiud/cmake-icc-fix
cmake: fixed gflags namespace detection (fixes #193)
2017-07-10 01:53:19 +09:00
Sergiu Deitsch
e50aeaa5ee cmake: fixed gflags namespace detection (fixes #193)
This commit fixes gflags namespace detection using Intel compiler and ensures
the generated try_compile command line does not produce malformed paths.
2017-07-09 15:48:13 +02:00
Shinichiro Hamaji
40fc21467a Merge pull request #153 from sergiud/cmake-gnu-install-dirs
cmake: do not hardcode relative install directories
2017-07-06 15:01:10 +09:00
Shinichiro Hamaji
a9b9ee8e8c Merge pull request #152 from sergiud/cmake-project-name
cmake: changed project name from google-glog to glog
2017-07-06 15:00:37 +09:00
Shinichiro Hamaji
a808e435b7 Merge pull request #157 from sergiud/cygwin-support
Cygwin support
2017-07-06 15:00:06 +09: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
Shinichiro Hamaji
80bec2ba45 Merge pull request #199 from v1bri/brian-fix-gflags-link
Use gflags ALIAS instead of ${gflags_XXX} vars
2017-06-29 12:36:25 +09:00
Shinichiro Hamaji
5cfa9a28f5 Merge pull request #168 from andschwa/windows-stacktrace
Port stack tracing to Windows
2017-06-28 12:31:40 +09:00
Andrew Schwartzmeyer
d1f49ba5aa Support signal handler on Windows 2017-06-27 10:50:20 -07:00
Andrew Schwartzmeyer
7f95ecfdc7 Link to DbgHelp using pre-processor directive
This method ensure that all users of glog get automatically linked to
the DbgHelp library without needing to set compiler flags.
2017-06-27 10:50:20 -07:00
Andrew Schwartzmeyer
e2caf9876e Export GetStackTrace
Necessary when building with BUILD_SHARED_LIBS=1.
2017-06-27 10:50:20 -07:00
Andrew Schwartzmeyer
f1d64f7deb Support symbolizer and demangler on Windows 2017-06-27 10:50:20 -07:00
Andrew Schwartzmeyer
e5d36443c6 Support stacktrace on Windows 2017-06-26 18:47:34 -07:00
Andrew Schwartzmeyer
9c1d0e6f6e Copy stacktrace_generic-inl.h for Windows 2017-06-26 16:21:10 -07:00
Andrew Schwartzmeyer
bcaaa5d29b Add Andrew Schwartzmeyer to authors and contributors 2017-06-26 16:21:10 -07:00
Brian Orr
baf6c8b2c5 Specify gflags version in CMakeLists.txt 2017-06-22 11:24:58 -07:00
Brian Orr
e1cae334a1 Use gflags ALIAS instead of ${gflags_XXX} vars
The gflags project updated their CMake config last year with a
`gflags` ALIAS target. This can be used instead of the legacy
`${gflags_LIBRARIES}` and `${gflags_INCLUDE_DIRS}` variables. It also
looks cleaner.

Fixes #198
2017-06-22 00:25:13 -07:00
Fumitoshi Ukai
77a0e36b7a Merge pull request #188 from shinh/remove-configure
Remove files generated by autotools

closes #165
2017-05-12 14:57:09 +09:00
Shinichiro Hamaji
4f3e18bf26 Remove files generated by autotools
for #165. I think not many projects have them in their repo.
2017-05-12 14:53:39 +09:00
Shinichiro Hamaji
d166ae3881 Update the version in CMakeLists.txt to 0.3.5 2017-05-10 20:44:01 +09:00
Fumitoshi Ukai
70f0f55813 Merge pull request #186 from shinh/backport
Backport internal changes
2017-05-10 12:51:39 +09:00
Shinichiro Hamaji
a6266db97a Add a hack for naive include scanners 2017-05-09 17:35:18 +09:00
Shinichiro Hamaji
ee9d487782 Define OS_LINUX only if it's not defined yet 2017-05-09 17:22:38 +09:00
Shinichiro Hamaji
c4814b729a symbolize: Allow 4kB stack consumption on PPC64 2017-05-09 17:21:16 +09:00
Shinichiro Hamaji
f278d734c1 x86 stacktrace: Use __builtin_frame_address if possible 2017-05-09 17:14:15 +09:00
Shinichiro Hamaji
0d78884a22 Relax test for symbolize
Don't rely on an internal-linkage extern "C" function having an
unmangled name. This isn't required by the ABI, and in fact is not
valid for a conforming compiler(!). Instead, allow symbolization to
produce either a mangled or an unmangled name here.
2017-05-09 17:14:15 +09:00
Shinichiro Hamaji
7314fa3f86 Use LOG(FATAL) instead of CHECK(false) 2017-05-09 17:14:12 +09:00
Shinichiro Hamaji
f012836db1 Run src/windows/preprocess.sh 2017-05-09 16:41:58 +09:00
Shinichiro Hamaji
ce4fab2960 glog: release 0.3.5 2017-05-09 16:27:57 +09:00
Fumitoshi Ukai
e56ed55208 Merge pull request #179 from renning22/master
CHECK_NOTNULL works with smart pointers when compiled in C++11.
2017-04-21 09:54:53 +09:00
Ning Ren
0d8c6340f8 CHECK_NOTNULL works with smart pointers when compiled in C++11. 2017-04-20 15:32:24 -07:00
Fumitoshi Ukai
da816ea706 Merge pull request #169 from mayah/windows-no-return
Add __declspec(noreturn) on Win
2017-03-07 12:44:37 +09:00
mayah
8fa778aa12 Add __declspec(noreturn) on Win
Currently cl.exe doesn't know LOG(FATAL) exits the program. Set
__declspec(noreturn).
2017-03-07 11:22:24 +09:00
Fumitoshi Ukai
ab6545470b Merge pull request #164 from yoshisatoyanagisawa/dcheck_always_on
DCHECK_ALWAYS_ON to make D* enabled under NDEBUG
2017-02-09 11:04:00 +09:00
Yoshisato Yanagisawa
027332ffac DCHECK_ALWAYS_ON to make D* enabled under NDEBUG
The macro NDEBUG could be automatically defined for release build on
some build environments (e.g. MSVC).  If we use NDEBUG as a key to
distinguish using DCHECK as CHECK (I call this DCHECK is enabled) or
not, we cannot make DCHECK enabled for release build on such
environments.

Considering people use a program with glog for presubmit testing or
dogfooding, they should need to do release build with DCHECK enabled.
2017-02-08 17:23:37 +09:00
Mike Percy
f581614a78 Use thread local for libunwind GetStackTrace()
Previously, the implementation of google::GetStackTrace() that uses
libunwind uses a global variable that enforces that only one thread may
invoke libunwind at a time. However, libunwind is thread-safe. The
comment above the variable indicates that it is to protect against
reentrancy issues.

Instead of using a global variable, it would be much better to use a
thread-local variable to protect against these reentrancy issues. That
should provide the needed reentrancy protection while allowing multiple
threads to get stack traces at the same time.

It also allows for the removal of the atomic CAS operations on the
variable.

Resolves #160.
2017-01-27 21:24:11 -08:00
Sergiu Deitsch
96a09ae01a fixed cygwin compilation errors 2017-01-17 12:47:11 +01:00
Sergiu Deitsch
b3dea50f33 cmake: do not hardcode relative install directories 2017-01-10 11:34:42 +01:00
Sergiu Deitsch
f2157a387b cmake: changed project name from google-glog to glog
This fixes the default install location on Windows. Specifically,
find_package works now out-of-the box with the default
CMAKE_INSTALL_PREFIX.
2017-01-10 11:15:18 +01: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
Ricardo Ribalda Delgado
5da5f2cac5 configure.ac: Allow user to disable gflags
Under some circumstances like cross-compilation, the user might not want
to enable support for gflags.

This patch allows support for --without-gflags

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
2016-10-20 15:59:19 +02:00
Fumitoshi Ukai
b6a5e0524c Update github.com/sergiud in AUTHORS/CONTRIBUTORS 2016-10-20 15:53:26 +09:00
Fumitoshi Ukai
9581b3fb9b Merge pull request #132 from sergiud/cmake-disable-unittests
cmake: allow to disable building unit tests
2016-10-19 16:40:55 +09:00
Sergiu Deitsch
60375e0bd4 cmake: allow to disable building unit tests
This commit introduces a CMake `BUILD_TESTING` boolean option that
allows to disable unit tests. This is especially useful in superbuilds
where typically only the main library is built. By default, this option
is enabled.
2016-10-19 09:32:21 +02:00
Fumitoshi Ukai
cf36dabd8e Merge pull request #127 from MinGW-caffe/master
try to avoid the error "conflicting declaration 'typedef DWORD pthread_t'" etc. in MinGW
2016-10-19 16:29:34 +09:00
Fumitoshi Ukai
5080258031 Add MiniLight to AUTHORS/CONTRIBUTORS 2016-10-19 16:28:53 +09:00
Fumitoshi Ukai
bf766fac4f Merge pull request #123 from yying/master
Set sinks_ to NULL after deletion in LogDestination::DeleteLogDestinations
2016-10-19 16:10:39 +09:00
Fumitoshi Ukai
ff5fa62a5f Add Andy Ying to AUTHORS/CONTRIBUTORS 2016-10-19 16:09:41 +09:00
Fumitoshi Ukai
7cff62028c Merge pull request #116 from pcc/fix2
Fix autotools build.
2016-10-19 16:06:38 +09:00
Fumitoshi Ukai
f5cc8631a4 Merge pull request #98 from willyd/relocatable
Added $<BUILD_INTERFACE> to gflags include directory
2016-10-19 16:02:49 +09:00
Fumitoshi Ukai
b3a1dc359d Add Guillaume Dumont to AUTHORS/CONTRIBUTORS 2016-10-19 15:59:24 +09:00
Fumitoshi Ukai
dee7c8c36e Merge pull request #129 from sergiud/cmake-PIC
cmake: enable position independent code (PIC)
2016-10-19 15:52:32 +09:00
Fumitoshi Ukai
fc61880361 Merge pull request #130 from sergiud/cmake-warning-fix
cmake: fixed clang warning propagation to gcc
2016-10-19 15:51:45 +09:00
Sergiu Deitsch
e6c26b2b94 cmake: fixed clang warning propagation to gcc 2016-10-07 11:03:19 +02:00
Sergiu Deitsch
e05f325668 cmake: enable position independent code (PIC) 2016-10-07 10:54:14 +02:00
MiniLight
9c584dd2ed try to avoid the error "conflicting declaration 'typedef DWORD
pthread_t'" etc.
2016-10-03 08:00:09 +08:00
Andy Ying
a00dfdfc53 NULL sinks_ after deletion to prevent dangling pointer 2016-09-11 01:16:32 -04:00
Ezequiel Lara Gomez
47af307fa6 Added fixed log name support
See https://code.google.com/p/google-glog/issues/detail?id=209 - 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.
2016-09-08 10:52:39 +01:00
Fumitoshi Ukai
0472b91c5d Add Peter Collingbourne <pcc@google.com> to CONTRIBUTORS 2016-07-14 10:47:13 +09:00
Fumitoshi Ukai
f174cba02c Merge pull request #115 from pcc/fix1
symbolize: Calculate a module's zero VA using program headers.
2016-07-14 10:44:18 +09:00
Peter Collingbourne
8e98eb2a5a Fix autotools build.
It looks like commit 3c49b93 modified the auto-generated file src/config.h.in
to add a definition of macro GOOGLE_GLOG_DLL_DECL. One of the autotools
reverts this change upon running "make", causing the build to fail when a
source file includes demangle.h.

To fix the problem, revert the change to src/config.h.in and include
glog/logging.h from demangle.h which provides a definition of that macro.
2016-06-22 18:48:32 -07:00
Peter Collingbourne
a93a4511ec symbolize: Calculate a module's zero VA using program headers.
Previously we were using a module's "start address", i.e. the
address at which the module's executable region was mapped, as the
zero virtual address, i.e. the address from which the DSO's virtual
addresses are calculated. This works fine for DSOs created by the
bfd and gold linkers, which will emit a PT_LOAD directive into the
program header which loads the executable region at virtual address
(p_vaddr) and file offset (p_offset) 0.

However, the lld linker may place a read-only region before the
executable region, meaning that both p_vaddr and p_offset for the
executable region are non-zero. This means that any symbols resolved
by the symbolizer are resolved to an incorrect virtual address. To
correctly calculate the address corresponding to virtual address zero,
we need to take into account p_vaddr and p_offset.

Specifically, the calculation starts with the "base address", i.e. the
start address minus the file offset. To get from the base address to
virtual address zero, we first add p_offset. This gives us the mapped
address of the start of the segment, or in other words the mapped
address corresponding to the virtual address of the segment. (Note
that this is distinct from the start address, as p_offset is not
guaranteed to be page aligned.) We then subtract p_vaddr, which takes
us to virtual address zero.
2016-06-22 18:41:43 -07:00
dimhotepus
4544e968ab Cache strlen outside of cycles (PVS-Studio) 2016-04-30 14:24:12 +03:00
Fumitoshi Ukai
de6149ef8e Merge pull request #101 from yasushi-saito/master
Allow permission line in /proc/self/map to be "rwx", not just "r-x".
2016-04-15 17:05:30 +09:00
Fumitoshi Ukai
202b395c04 Merge pull request #91 from abdasgupta/master
Added support for PowerPC.
2016-04-13 14:00:49 +09:00
Fumitoshi Ukai
2a7423b346 Merge pull request #82 from sergiud/cmake-imported-target
Better support and documentation for CMake projects that consume glog
2016-04-13 13:59:08 +09:00
Yaz Saito on W541
d630221933 Allow permission line in /proc/self/map to be "rwx", not just "r-x". At
least in Ubuntu14, a binary file that's writable by the process owner
has permission "rwx", not "r-x".
2016-04-11 14:35:42 -07:00
Guillaume Dumont
45901a359f Added $<BUILD_INTERFACE> to gflags include to avoid including the gflags include dir in the glog-targets.cmake 2016-04-05 14:02:42 -04:00
Fumitoshi Ukai
f176cc8454 Merge pull request #96 from mayah/update-windows
Update src/windows/glog/logging.h to ToT
2016-03-31 17:50:09 +09:00
mayah
821d3e806e Run src/windows/preprocess.sh
src/windows/glog/logging.h is not generated by the current source.
Let me run src/windows/preprocess.sh and update the source.
2016-03-31 17:29:36 +09:00
Abhishek Dasgupta
b27d0420fb Added support for PowerPC. 2016-03-21 11:28:53 +00:00
Alexander Scheuermann
d68736bc1d Respect configured docdir
Avoid overriding the configured docdir inside the Makefile.
$(datarootdir)/doc/ may differ from $(prefix)/share/doc/
2016-03-04 08:55:28 +01:00
Sergiu Dotenco
c7e35f834c added CMake usage instructions 2016-01-08 15:31:10 +01:00
Sergiu Dotenco
780efcc857 cmake: allow to refer to imported glog target as glog::glog 2016-01-08 14:55:58 +01:00
Sergey Sharybin
f94a49c571 Resolve missing prototype warning
Makes compilation process less noisy even when using string compiler flags.
2015-12-31 17:55:37 +05:00
Fumitoshi Ukai
4d391fe692 use namespace GFLAGS_NAMESPACE instead namespace gflags
only signalhandler_unittest.cc uses "using namespace gflags".
others use "using namespace GFLAGS_NAMESPACE", so
signalhandler_unittest.cc does the same way.

fixes #62
2015-12-17 16:31:55 +09:00
Fumitoshi Ukai
a63f466c48 win: use _fdopen instead of fdopen
The POSIX function fdopen is deprecated.
Use the ISO C++ conformant _fdopen instead.
https://msdn.microsoft.com/library/ms235351.aspx

fixes #73
2015-12-17 15:40:25 +09:00
Fumitoshi Ukai
1256d28554 win: FAILED macro can't be used with HANDLE.
FAILED macro is for HRESULT, not for HANDLE.
FindFirstFile returns INVALID_HANDLE_VALUE when error or not found.
https://msdn.microsoft.com/library/windows/desktop/aa364418(v=vs.85).aspx

fixes #79
2015-12-17 15:36:40 +09:00
Fumitoshi Ukai
0312301143 avoid calling new/malloc in signalhandler.
FlushLogFilesUnsafe would be called in FailureSignalHandler,
so should avoid calling new/malloc, which are not signal safe.

fixes #78
2015-12-17 15:26:15 +09:00
Fumitoshi Ukai
de75983a81 Merge pull request #74 from yoshisatoyanagisawa/fix_sigabrt_action
Reset SIGABRT action only if FailureSignalHandler is installed.
2015-11-27 13:18:55 +09:00
Yoshisato Yanagisawa
cda16b3443 Reset SIGABRT action only if FailureSignalHandler is installed.
When I set my own signal handler to SIGABRT, it did not executed
with CHECK.  That is because SIGABRT handler is reset to default
just before glog calls abort.
Let me make it reset only if the handler is what glog installed
i.e. FailureSignalHandler.
2015-11-26 16:19:22 +09:00
Fumitoshi Ukai
f46e0745a8 Merge pull request #58 from ruslo/fix.include
Fix missing public include directory
2015-11-10 17:11:29 +09:00
Fumitoshi Ukai
0ae958f933 Merge pull request #56 from rhencke/fix-test
Fix double-free in unit test on Windows.
2015-11-10 17:10:29 +09:00
Fumitoshi Ukai
013a36bddf Merge pull request #51 from flandr/pthread-cmake-build
Link libpthread when necessary in CMake builds
2015-11-10 17:05:10 +09:00
Ruslan Baratov
ccacef4362 Fix missing public include directory
Path "<prefix>/include" will not be added to the headers search of dependent
targets without specifying INSTALL_INTERFACE, i.e. compilation
will fail with error:

  "fatal error: 'glog/logging.h' file not found".
2015-09-09 00:33:31 +03:00
Nate Rosenblum
bdb6c3219a Add pthread library to linker list when needed 2015-09-06 08:09:36 -07:00
Robert Hencke
c10e6ec19c Fix double-free in unit test on Windows.
The LOG_SYSRESULT refers to result twice.  Since, in this test,
result expands to FindClose(handle), the handle was being freed twice.
2015-09-06 09:53:22 -04:00
Fumitoshi Ukai
a66751870f Merge pull request #49 from sergiud/cmake-visibility
Fixed warning caused by policy CMP0063 introduced in CMake 3.3
2015-08-12 16:10:40 +09:00
Fumitoshi Ukai
85e5c6edad Merge pull request #47 from sergiud/master
Allow to disable multithreading support using CMake
2015-08-12 16:09:02 +09:00
Fumitoshi Ukai
4dd62b0547 Add Teddy Reed to AUTHORS/CONTRIBUTORS 2015-08-12 16:06:34 +09:00
Fumitoshi Ukai
a94afc6807 Merge pull request #26 from theopolis/feature-mode-flag
[#23] Add logfile_mode to control logfile permissions
2015-08-12 16:05:28 +09:00
Sergiu Dotenco
ed6dba0bd8 cmake: fixed warning caused by policy CMP0063 2015-08-11 19:00:14 +02:00
Teddy Reed
58438d398f [#23] Add logfile_mode to control logfile permissions 2015-08-10 16:49:33 -07:00
Sergiu Dotenco
cb5487d901 cmake: allow to disable multithreading support
This commit additionally enables threading for win32 by default.
2015-08-08 21:26:17 +02:00
Fumitoshi Ukai
f7691955e8 Merge pull request #35 from bsilver8192/fix-mocklog-unused-arguments
Fix mocklog unused arguments
2015-08-06 17:17:55 +09:00
Fumitoshi Ukai
254db0ae1b Merge pull request #34 from bsilver8192/fix-macro-redefinition
Fix redefinition of _XOPEN_SOURCE.
2015-08-06 17:15:44 +09:00
Fumitoshi Ukai
4a1e5ef60c Add tomange to AUTHORS/CONTRIBUTORS 2015-08-06 17:10:21 +09:00
Fumitoshi Ukai
cd37eec302 Merge pull request #20 from UbimoLTD/patch-1
Don't call RAW_VLOG with locking vmodule_lock

SetVLOGLevel locks vmodule_lock however RAW_VLOG at the end also implicitly locks it via InitVLOG3__.
This causes deadlock/segfault.

fixes #29
2015-08-06 17:09:02 +09:00
Fumitoshi Ukai
8db3ff0b75 Merge pull request #12 from ukai/fix_leak
delete LogDestination::sinks_ at DeleteLogDestinations(). 

fixes #8
2015-08-06 16:57:51 +09:00
Fumitoshi Ukai
e91d5c4d02 Add Sergiu Dotenco to AUTHORS/CONTRIBUTORS 2015-08-06 16:55:37 +09:00
Fumitoshi Ukai
fe136448ff Merge pull request #7 from sergiud/master
Add CMake support. closes #4
2015-08-06 16:53:55 +09:00
Fumitoshi Ukai
454906f44b Add Michael Tanner and tbennun to AUTORS/CONTRIBUTORS 2015-08-06 16:45:44 +09:00
Sergiu Dotenco
8453b0856b cmake: link to libunwind 2015-07-15 22:35:01 +02:00
Sergiu Dotenco
05746ed702 cmake: support gflags in static builds 2015-07-15 22:35:01 +02:00
Sergiu Dotenco
95cde7af2f cmake: disabled 'template argument uses unnamed type' warning 2015-07-15 22:35:00 +02:00
Sergiu Dotenco
5aee7c7899 added missing include 2015-07-15 22:35:00 +02:00
Sergiu Dotenco
856ff81a82 fixed vc 14.0 ctp 6 compilation error 2015-07-15 22:34:59 +02:00
Sergiu Dotenco
b561c94b19 determine gflags namespace automatically 2015-07-15 22:34:59 +02:00
Sergiu Dotenco
f9def39a46 do not redefine snprintf if it's already available 2015-07-15 22:34:58 +02:00
Sergiu Dotenco
fa4c5b50a9 do not redefine stl logging macros 2015-07-15 22:34:58 +02:00
Sergiu Dotenco
ea628ae809 allow to define TEST_SRC_DIR as a macro 2015-07-15 22:34:58 +02:00
Sergiu Dotenco
3325258036 allow to use __declspec(noreturn) 2015-07-15 22:34:57 +02:00
Sergiu Dotenco
3d9fea9e84 export the Demangle function 2015-07-15 22:34:57 +02:00
Sergiu Dotenco
3c49b93201 added cmake support 2015-07-15 22:34:44 +02:00
Brian Silverman
beb55fa825 Fix redefinition of _XOPEN_SOURCE.
Under Debian Jessie, I get a warning about redefining _XOPEN_SOURCE
which is easy to fix.
2015-06-16 16:50:57 -07:00
Brian Silverman
180eaff781 Fix unused arguments warning in ScopedMockLog. 2015-06-16 16:50:01 -07:00
Brian Silverman
287ab79862 Add Brian Silverman to AUTHORS+CONTRIBUTORS. 2015-06-16 16:49:53 -07:00
romange
2c5038470b Update vlog_is_on.cc
SetVLOGLevel locks vmodule_lock however RAW_VLOG at the end also implicitly locks it via InitVLOG3__.

This causes deadlock/segfault.
2015-04-30 20:28:32 +03:00
Pierre Phaneuf
2a02db7aa5 Add Abhishek Parmar to the AUTHORS/CONTRIBUTORS files. 2015-04-23 11:41:53 +01:00
Fumitoshi Ukai
ed072a55b8 don't remove sinks_ elements. 2015-04-11 00:05:05 +09:00
Abhishek Parmar
701dd7120d Guard GOOGLE_PREDICT_TRUE|FALS with #ifndef to avoid collision with other google opensource projects like protobuf. 2015-04-08 10:19:06 -07:00
Fumitoshi Ukai
9c2acaaa49 delete LogDestination::sinks_ at DeleteLogDestinations().
fixes #8 AddLogSink memory leak
2015-03-27 17:23:20 +09:00
Fumitoshi Ukai
1b0b08c8dd Merge pull request #10 from jmr/std_vector
LOG_STRING: use std::vector and std::string.
2015-03-27 16:43:58 +09:00
Jesse Rosenstock
162a8ef4ea LOG_STRING: use std::vector and std::string.
Previously, plain vector and string were used.
This assumed that there were "using" directives or
declarations before the macro was used.  This will
not always be the case.
2015-03-26 14:25:14 -04:00
Fumitoshi Ukai
852970d850 Merge pull request #6 from darkwind-mt/master
Adds color output support for tmux terminals
2015-03-26 17:51:44 +09:00
Michael Tanner
66088e4787 Adds color output support for tmux terminals 2015-03-23 10:56:04 +00:00
Fumitoshi Ukai
47ab571f38 Merge pull request #2 from tbennun/master
Fix x64/Debug build on MSVS
2015-03-18 14:54:40 +09:00
Pierre Phaneuf
80942e5ea2 Add the typical Google contributors and authors files.
Also add a CONTRIBUTING.md, that GitHub will link to in the pull request
creation page.
2015-03-16 10:50:32 +00:00
tbennun
7553b4193d Fix x64/Debug build on MSVS 2015-03-13 07:56:59 +02:00
Fumitoshi Ukai
d8cb47f77d Merge pull request #1 from ukai/release_0.3.4
glog: release 0.3.4
2015-03-11 13:02:27 +09:00
Fumitoshi Ukai
5ab077bb8d Fix for "make rpm" and "make deb" 2015-03-10 12:44:30 +09:00
Fumitoshi Ukai
3b0372bd70 glog: release 0.3.4
migrate to https://github.com/google/glog
use autoconf 2.69 / automake 1.14.1
2015-03-09 11:45:07 +09:00
78da3bf8fe Fixes for the latest MSVS.
- ssize_t
Since Windows does not have ssize_t, we need to include BaseTsd.h and
use SSIZE_t instead.

- include algorithm
MSVS 2013 requests developers to include algorithm when they use
std::min.

By yyanagisawa



git-svn-id: https://google-glog.googlecode.com/svn/trunk@143 eb4d4688-79bd-11dd-afb4-1d65580434c0
2014-08-19 00:36:29 +00:00
09e8dd6289 Add libc++ support
Similar patch was provided in
    
https://code.google.com/p/google-glog/issues/detail?id=121


git-svn-id: https://google-glog.googlecode.com/svn/trunk@142 eb4d4688-79bd-11dd-afb4-1d65580434c0
2014-03-05 05:20:24 +00:00
a5ffa88413 Build issues in demangle.cc
git-svn-id: https://google-glog.googlecode.com/svn/trunk@141 eb4d4688-79bd-11dd-afb4-1d65580434c0
2014-03-02 01:37:08 +00:00
8367470aa5 Adding a callback mechanism to allow users of google.glog to provide
their own implementation of  OpenObjectFileContainingPcAndGetStartAddress.

GTTF: Make stack trace symbolization code recognize more symbols.
One example is __libc_start_main (easy to check), there may be more.

Include the correct elf header on OpenBSD and Android.

Fix Coverity NO_EFFECT defect. Comparing unsigned greater than or equal zero is always true.



git-svn-id: https://google-glog.googlecode.com/svn/trunk@140 eb4d4688-79bd-11dd-afb4-1d65580434c0
2014-03-01 00:33:41 +00:00
a0073e504b Add StrError and replace posix_strerror_r calls
For now, we do not remove the declaration of posix_strerror_r,
but we might remove it in future.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@139 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-10-31 05:39:43 +00:00
0242c8e94d Fix VC build by adding GOOGLE_GLOG_DLL_DECL
git-svn-id: https://google-glog.googlecode.com/svn/trunk@138 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-10-31 05:36:25 +00:00
a0bf19d0df A style fix for C++11
This patch is given by Nico (thanks!)



git-svn-id: https://google-glog.googlecode.com/svn/trunk@137 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-07-29 06:27:17 +00:00
1518f230c6 Reduce dynamic allocation from 3 to 1 per log message
This patch was contributed in

https://code.google.com/p/google-glog/issues/detail?id=131

by engel. Thanks!


git-svn-id: https://google-glog.googlecode.com/svn/trunk@136 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-05-29 14:10:49 +00:00
478a80caa0 Attempt to improve mingw-w64 support
- Set -Isrc/windows for mingw
- Check existence of sigaction, pread, and pwrite
- Provide alternative implementation of pread and pwrite
- Eliminate symlink code for OS_WINDOWS
- Don't check /proc/self/fd if the OS isn't linux
- Don't use MSVC specific declarations in port.h for mingw



git-svn-id: https://google-glog.googlecode.com/svn/trunk@135 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-02-18 10:56:53 +00:00
a106e61178 Support unordered_(map|set) by stl_logging
git-svn-id: https://google-glog.googlecode.com/svn/trunk@134 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-02-18 10:45:46 +00:00
cba9095278 Remove .svn directory from the release archive
packages/deb is a directory and it may contain .svn



git-svn-id: https://google-glog.googlecode.com/svn/trunk@133 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-02-01 06:31:49 +00:00
0b0b022be1 Release glog 0.3.3
git-svn-id: https://google-glog.googlecode.com/svn/trunk@132 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-02-01 06:20:46 +00:00
069ee58a09 Fix Mac test failure
We need only the first line from signalhandler.out3


git-svn-id: https://google-glog.googlecode.com/svn/trunk@131 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-02-01 05:46:37 +00:00
e6af5ea5f1 Make sure stderr is not buffered.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@130 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-01-31 04:39:54 +00:00
fdc710e355 Add dllimport and dllexport for new symbols
git-svn-id: https://google-glog.googlecode.com/svn/trunk@129 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-01-31 03:49:40 +00:00
35ba669307 Revert http://code.google.com/p/google-glog/source/detail?r=127
Casting to (void) was bad because the return value of DCHECK_NOTNULL
cannot be used.



git-svn-id: https://google-glog.googlecode.com/svn/trunk@128 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-01-31 03:48:24 +00:00
3297f04c13 Remove warning of DCHECK_NOTNULL
http://code.google.com/p/google-glog/issues/detail?id=87


git-svn-id: https://google-glog.googlecode.com/svn/trunk@127 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-01-25 07:59:25 +00:00
133b40fd55 Document update: how to modify FLAGS_* in glog
http://code.google.com/p/google-glog/issues/detail?id=70



git-svn-id: https://google-glog.googlecode.com/svn/trunk@126 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-01-25 06:03:56 +00:00
c4c25e85fd Make glog ABI compatible with gflags
The ABI incompatibility is bad when 

- Build glog without gflags (glog package in most distributions doesn't 
  depend on gflags) 
- Use both glog and gflags 


git-svn-id: https://google-glog.googlecode.com/svn/trunk@125 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-01-25 05:44:43 +00:00
3b59339f08 Follow up for the color log patch
- Rename colorstderr => colorlogtostderr
- Remove duplicated code
- Set colorlogtostderr=0 in the unittest



git-svn-id: https://google-glog.googlecode.com/svn/trunk@124 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-01-23 05:27:13 +00:00
ff96a5a827 Output logs with colors to stderr
This patch is provided by

http://code.google.com/p/google-glog/issues/detail?id=48

Thanks!



git-svn-id: https://google-glog.googlecode.com/svn/trunk@123 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-01-23 05:25:56 +00:00
5fc80272da Re-generate logging.h for windows
Thanks Kamil for your report!



git-svn-id: https://google-glog.googlecode.com/svn/trunk@122 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-01-22 09:12:56 +00:00
74ae299924 Allow users to re-initialize glog
http://code.google.com/p/google-glog/issues/detail?id=83
http://code.google.com/p/google-glog/issues/detail?id=125
http://code.google.com/p/google-glog/issues/detail?id=142



git-svn-id: https://google-glog.googlecode.com/svn/trunk@121 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-01-10 07:46:20 +00:00
e8327746ef Move LogMessageData from .h to .cc
git-svn-id: https://google-glog.googlecode.com/svn/trunk@120 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-01-10 07:19:05 +00:00
3aa45ed56e Eliminate use of strstream based on internal changes
http://code.google.com/p/google-glog/issues/detail?id=110


git-svn-id: https://google-glog.googlecode.com/svn/trunk@119 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-01-09 16:06:21 +00:00
44c4b29de4 Fix glog/stl_logging for clang
git-svn-id: https://google-glog.googlecode.com/svn/trunk@118 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-01-09 13:59:45 +00:00
047426cf97 Run autoreconf on ubuntu precise
git-svn-id: https://google-glog.googlecode.com/svn/trunk@117 eb4d4688-79bd-11dd-afb4-1d65580434c0
2013-01-09 13:26:44 +00:00
96dac4fd02 Fixed files to support FreeBSD amd64 based on patches at:
http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/glog/files/

Since FreeBSD do not have gettid system call unlikely to MacOSX, I
modified utilities.h not to use that on FreeBSD:
* FreeBSD lacks gettid syscall.
http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/kern/syscalls.master?rev=1.276;content-type=text%2Fplain
* MacOSX gettid == 286.
http://www.opensource.apple.com/source/xnu/xnu-1504.3.12/bsd/kern/syscalls.master
   
As for the fix of stacktrace, we use a different approach.
Even in FreeBSD, package gcc44/gcc46 has unwind.h.
As a result, checking unwind.h should be natural solution.

This patch was given by yyanagisawa



git-svn-id: https://google-glog.googlecode.com/svn/trunk@116 eb4d4688-79bd-11dd-afb4-1d65580434c0
2012-11-22 12:09:13 +00:00
711fcd27de Don't #undef GLOG_MSVC_*
They are necessary because GLOG_MSVC_* will be expanded at DCHECK



git-svn-id: https://google-glog.googlecode.com/svn/trunk@115 eb4d4688-79bd-11dd-afb4-1d65580434c0
2012-07-17 10:51:15 +00:00
4f6088bc72 Reduce compiler warnings on Windows and MacOSX
DCHECK* causes "warning C4127: conditional expression is constant".

If compiled with -DWIN32_LEAN_AND_MEAN,
port.h: warning C4005: 'WIN32_LEAN_AND_MEAN': macro redefinition.

On MacOSX,
warning: "_END_GOOGLE_NAMESPACE_" redefined
warning: "_START_GOOGLE_NAMESPACE_" redefined
because config.h is included
 from base/commandlineflags.h:51
 from logging.cc:60
and
 from utilities.h:81
 from logging.cc:32
or so.

Contributed by ukai@



git-svn-id: https://google-glog.googlecode.com/svn/trunk@114 eb4d4688-79bd-11dd-afb4-1d65580434c0
2012-07-12 06:37:47 +00:00
7c613d6190 Fix LOG_SYSRESULT
result is expected to be GetLastError() or WSAGetLastError(), so
we have to convert it to HRESULT by HRESULT_FROM_WIN32 for FAILED()
macro.
Use FormatMesssageA (ANSI version). since glog may not work with
Unicode string.

Contributed by ukai@



git-svn-id: https://google-glog.googlecode.com/svn/trunk@113 eb4d4688-79bd-11dd-afb4-1d65580434c0
2012-07-03 05:25:54 +00:00
6d42536769 Reduce the number of warnings by VS2010
git-svn-id: https://google-glog.googlecode.com/svn/trunk@112 eb4d4688-79bd-11dd-afb4-1d65580434c0
2012-06-13 07:25:19 +00:00
e7712bf068 Compile error fix for QNX
This patch is given in

http://code.google.com/p/google-glog/issues/detail?id=114



git-svn-id: https://google-glog.googlecode.com/svn/trunk@111 eb4d4688-79bd-11dd-afb4-1d65580434c0
2012-05-14 07:46:20 +00:00
ad13dc67dd VC11 build fix
http://code.google.com/p/google-glog/issues/detail?id=119



git-svn-id: https://google-glog.googlecode.com/svn/trunk@110 eb4d4688-79bd-11dd-afb4-1d65580434c0
2012-05-14 07:43:51 +00:00
475ec9b9c4 Add --disable-rtti
git-svn-id: https://google-glog.googlecode.com/svn/trunk@109 eb4d4688-79bd-11dd-afb4-1d65580434c0
2012-02-24 07:28:50 +00:00
7e0a53c87f Release 0.3.2.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@108 eb4d4688-79bd-11dd-afb4-1d65580434c0
2012-01-12 08:49:31 +00:00
73b0abc989 Remove trivial warnings produced by clang
git-svn-id: https://google-glog.googlecode.com/svn/trunk@107 eb4d4688-79bd-11dd-afb4-1d65580434c0
2012-01-12 08:41:09 +00:00
cd026f9eab Add exception specification for operator new and operator delete
Unfortunately, clang produces warnings for them



git-svn-id: https://google-glog.googlecode.com/svn/trunk@106 eb4d4688-79bd-11dd-afb4-1d65580434c0
2012-01-12 07:50:28 +00:00
8b90f05746 Fix compile failures with clang in stl_logging_unittest.cc
This happens due to the reason I wrote in stl_logging.h.
We don't need utilities.h (which includes logging.h) so we can just
remove it.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@105 eb4d4688-79bd-11dd-afb4-1d65580434c0
2012-01-12 07:49:25 +00:00
fe0967b999 Fix the wrong use of sizeof
git-svn-id: https://google-glog.googlecode.com/svn/trunk@104 eb4d4688-79bd-11dd-afb4-1d65580434c0
2012-01-12 07:46:39 +00:00
11e78e4c66 Put __attribute__((noreturn)) for declartions of function pointers
Clang needs this change.



git-svn-id: https://google-glog.googlecode.com/svn/trunk@103 eb4d4688-79bd-11dd-afb4-1d65580434c0
2012-01-12 07:45:39 +00:00
6232847ecb Fix __sync_val_compare_and_swap detection
We should use the second argument of AC_TRY_LINK.
Otherwise, the main function defined twice and this test does never succeed.



git-svn-id: https://google-glog.googlecode.com/svn/trunk@102 eb4d4688-79bd-11dd-afb4-1d65580434c0
2012-01-12 06:15:52 +00:00
6febec361e Define GLOG_ prefixed log severities
Users can control if usual log severity values will be defined by
GLOG_NO_ABBREVIATED_SEVERITIES.

For http://code.google.com/p/google-glog/issues/detail?id=105



git-svn-id: https://google-glog.googlecode.com/svn/trunk@101 eb4d4688-79bd-11dd-afb4-1d65580434c0
2012-01-11 09:17:04 +00:00
8a4c1663e3 Make public headers "warnings clean" in the sense of -Wall -Wextra -Wshadow
-Werror.  Fixes issue 98.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@100 eb4d4688-79bd-11dd-afb4-1d65580434c0
2011-12-29 12:40:48 +00:00
d8944b1743 Fix logging_striplog_test.sh in debug mode. Fixes issue 108.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@99 eb4d4688-79bd-11dd-afb4-1d65580434c0
2011-12-29 12:36:09 +00:00
5a05c30365 Remove assumptions about function size in stacktrace_unittest.cc, which do not
hold when using certain compiler settings (for example, -O3 -g2 with GCC).
Fixes issue 107.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@98 eb4d4688-79bd-11dd-afb4-1d65580434c0
2011-12-28 15:45:05 +00:00
ac3e918969 Suppress warnings around return value of write and symlink.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@97 eb4d4688-79bd-11dd-afb4-1d65580434c0
2011-09-05 08:00:43 +00:00
c2cbc763ed Destruct global objects in ShutdownGoogleLogging
http://code.google.com/p/google-glog/issues/detail?id=69



git-svn-id: https://google-glog.googlecode.com/svn/trunk@96 eb4d4688-79bd-11dd-afb4-1d65580434c0
2011-09-05 08:00:01 +00:00
b1afbe7b3c Add google:: prefixes for COUNTER in glog's document
http://code.google.com/p/google-glog/issues/detail?id=92


git-svn-id: https://google-glog.googlecode.com/svn/trunk@95 eb4d4688-79bd-11dd-afb4-1d65580434c0
2011-09-05 07:58:38 +00:00
54421697f4 Create a new log files after pid has changed
http://code.google.com/p/google-glog/issues/detail?id=51
http://code.google.com/p/google-glog/issues/detail?id=74
http://code.google.com/p/google-glog/issues/detail?id=82



git-svn-id: https://google-glog.googlecode.com/svn/trunk@94 eb4d4688-79bd-11dd-afb4-1d65580434c0
2011-09-05 07:56:21 +00:00
204ef03af8 Add files left behind by certain tests to CLEANFILES.
Remove autogen.sh, since you can just use autoreconf instead.

Ran autoreconf and fixed a couple of issues that popped up in
configure.ac and m4/ac_rwlock.m4.  This updates the configuration
files to automake/aclocal 1.11.1 (from 1.10.1) and to autoconf 2.65
(from 2.61).


git-svn-id: https://google-glog.googlecode.com/svn/trunk@93 eb4d4688-79bd-11dd-afb4-1d65580434c0
2011-05-11 02:47:46 +00:00
3ae5baa10b Reduce stack consumption for Demangle(). Fixes issue 81.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@92 eb4d4688-79bd-11dd-afb4-1d65580434c0
2011-02-25 14:33:28 +00:00
0b4dcd23ac Add partial C++0x support and recognition of GCC function clone suffixes to
demangle.cc.  Fixes issue 80.

Make svn ignore autom4te.cache.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@91 eb4d4688-79bd-11dd-afb4-1d65580434c0
2011-02-07 14:43:05 +00:00
1e86eecaf6 Minor message update.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@90 eb4d4688-79bd-11dd-afb4-1d65580434c0
2010-06-15 07:04:56 +00:00
6aa35189f5 Release 0.3.1.
This line, and those below, will be ignored--

M    configure
M    ChangeLog
M    configure.ac
M    packages/deb/changelog


git-svn-id: https://google-glog.googlecode.com/svn/trunk@89 eb4d4688-79bd-11dd-afb4-1d65580434c0
2010-06-15 06:30:24 +00:00
858a11d4e3 Add ShutdownGoogleLogging to close syslog.
This patch was contributed by DGunchev (thanks!)

http://code.google.com/p/google-glog/issues/detail?id=28


git-svn-id: https://google-glog.googlecode.com/svn/trunk@88 eb4d4688-79bd-11dd-afb4-1d65580434c0
2010-06-15 06:28:38 +00:00
b52f3fe2e4 s/ASSERT_EQ/CHECK_EQ/ .
We are not using gtests' ASSERT_* in our unittests.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@87 eb4d4688-79bd-11dd-afb4-1d65580434c0
2010-06-15 04:45:46 +00:00
c83adaa87d Use sys/ucontext.h when it is found. Snow leopard needs this.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@86 eb4d4688-79bd-11dd-afb4-1d65580434c0
2010-06-15 04:12:19 +00:00
1f8dac87fc Move TEST_SRC_DIR from googletest.h to config.h.
Now test passes out side tree.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@85 eb4d4688-79bd-11dd-afb4-1d65580434c0
2010-05-28 03:56:29 +00:00
f31f51085c Improve libunwind detection.
http://code.google.com/p/google-glog/issues/detail?id=42


git-svn-id: https://google-glog.googlecode.com/svn/trunk@84 eb4d4688-79bd-11dd-afb4-1d65580434c0
2010-05-28 03:45:27 +00:00
9e15c473b7 Add DCHECK_NOTNULL macro to logging.h (points to CHECK_NOTNULL in debug mode)
http://code.google.com/p/google-glog/issues/detail?id=25


git-svn-id: https://google-glog.googlecode.com/svn/trunk@83 eb4d4688-79bd-11dd-afb4-1d65580434c0
2010-05-28 03:43:29 +00:00
b2704e9f07 Add __extension__ for GCC's statement expression.
http://code.google.com/p/google-glog/issues/detail?id=31


git-svn-id: https://google-glog.googlecode.com/svn/trunk@82 eb4d4688-79bd-11dd-afb4-1d65580434c0
2010-05-28 03:32:50 +00:00
85f35499a7 Add some more google:: namespaces.
http://code.google.com/p/google-glog/issues/detail?id=40


git-svn-id: https://google-glog.googlecode.com/svn/trunk@81 eb4d4688-79bd-11dd-afb4-1d65580434c0
2010-05-28 03:31:14 +00:00
e912f200f0 Fix --enable-frame-pointers.
http://code.google.com/p/google-glog/issues/detail?id=44


git-svn-id: https://google-glog.googlecode.com/svn/trunk@80 eb4d4688-79bd-11dd-afb4-1d65580434c0
2010-05-28 03:28:41 +00:00
eb80cb0af5 Add information about the conflict with windows.h into our document.
http://code.google.com/p/google-glog/issues/detail?id=33


git-svn-id: https://google-glog.googlecode.com/svn/trunk@79 eb4d4688-79bd-11dd-afb4-1d65580434c0
2010-05-28 03:21:44 +00:00
65e631e038 The test for gflags works correctly on OpenBSD.
http://code.google.com/p/google-glog/issues/detail?id=49


git-svn-id: https://google-glog.googlecode.com/svn/trunk@78 eb4d4688-79bd-11dd-afb4-1d65580434c0
2010-05-28 03:12:15 +00:00
98b018f44b test binaries are in the builddir, not the top_srcdir
http://codereview.appspot.com/989043/show



git-svn-id: https://google-glog.googlecode.com/svn/trunk@77 eb4d4688-79bd-11dd-afb4-1d65580434c0
2010-05-14 21:45:05 +00:00
cb35010215 Use GLOG_* environment variables even when gflags is installed.
Define GLOG_DEFINE_*, which checks if the GLOG_* environment variable
is defined. If defined, GLOG_DEFINE_* passes the value and otherwise,
it passes the original default value. In this way, GLOG_DEFINE_* macro
uses the value specified by gflags first, then GLOG_* environment
variables, and finally it uses the default value if neither of them are
specified.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@76 eb4d4688-79bd-11dd-afb4-1d65580434c0
2010-01-20 07:39:18 +00:00
327359662c Handle ucontext.h properly in Snow leopard.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@75 eb4d4688-79bd-11dd-afb4-1d65580434c0
2010-01-18 06:15:33 +00:00
b71aa94381 Fix compilation error with -DNDEBUG.
This bug is reported in
http://code.google.com/p/google-glog/issues/detail?id=19



git-svn-id: https://google-glog.googlecode.com/svn/trunk@74 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-11-11 09:07:47 +00:00
effef71e00 Use numeric_limits instead of SSIZE_MAX.
It seems a version of arm-linux-gcc doesn't have this symbol.
http://code.google.com/p/google-glog/issues/detail?id=18



git-svn-id: https://google-glog.googlecode.com/svn/trunk@73 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-11-11 09:06:51 +00:00
90e7825e55 Use intptr_t instead of int to cast from char* for Snow Leopard.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@72 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-10-07 08:52:14 +00:00
7e610f65f5 Release 0.3.0.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@71 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-31 05:27:23 +00:00
7e54f5ab11 Make the order of check for OS_WINDOWS|OS_CYGWIN and HAVE_PTHREAD consistent.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@70 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-31 05:25:27 +00:00
1b5a90b691 Cast from pthread_t to pid_t via uintptr_t.
On 64bit NetBSD, pthread_t is a pointer and pid_t is an integer so
we cannot cast from pthread_t to pid_t directoly due to difference of
their size.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@69 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-30 10:45:13 +00:00
9495564423 Call glog_internal_namespace_::ProgramInvocationShortName() explicitly.
Otherwise, we may call google::ProgramInvocationShortName() in gflags.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@68 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-30 10:43:50 +00:00
5bf76bb4d5 Avoid warning for type punning like
src/logging_unittest.cc:591: warning: dereferencing type-punned pointer will break strict-aliasing rules

As we'll never dereference the casted pointers, it's OK to silence this warning.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@67 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-30 10:42:59 +00:00
fcbeeb9f35 Fix posix_strerror_r for OpenBSD.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@66 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-30 05:51:28 +00:00
f028227fa3 Define DumpPCAndSymbol() only when HAVE_SYMBOLIZE is defined.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@65 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-29 09:11:48 +00:00
d712e2084a Fix user name detection for Windows.
This patch was given by ademin (thanks!).

http://code.google.com/p/google-glog/issues/detail?id=12


git-svn-id: https://google-glog.googlecode.com/svn/trunk@64 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-29 08:38:20 +00:00
fc88a722eb Suppress warnings.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@63 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-29 08:37:32 +00:00
b35305f1ab Initializes the length of machine name properly.
This fix was suggested at (thanks!)

http://code.google.com/p/google-glog/issues/detail?id=9


git-svn-id: https://google-glog.googlecode.com/svn/trunk@62 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-29 07:34:28 +00:00
2c28a49394 Regression: Add NOGDI and NOMINMAX macros before including windows.h.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@61 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-27 08:13:30 +00:00
c24b607748 Use internal namespace instead of anonymous namespace for Mutex.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@60 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-27 05:42:23 +00:00
70cb94e244 Add cast for pthread_self() to avoid warning.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@59 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-27 05:31:23 +00:00
d96287aa28 Add virtual ~Thread() to avoid warnings.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@58 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-27 05:30:39 +00:00
ac63dd1f58 Add OS_NETBSD macro.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@57 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-27 05:29:58 +00:00
8c4e3a9238 Suppress warnings. Most of this patch was given by keir (thanks!).
Corresponding glog bug: http://code.google.com/p/google-glog/issues/detail?id=10

The differences from keir's patch are:
- For raw_logging.h.in, I just included time.h for struct tm.
- Added a fprintf which warns that we should have died to avoid a warning for unused local variable.
- Added inline for some functions which may be unused in googletest.h.
- Removed DumpPCAndFrameSize as it was unused.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@56 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-08 17:19:09 +00:00
4cd8381429 Add m4/pc_from_ucontext.m4. It supports NetBSD and OpenBSD as well.
Also, update the version of acx_pthread.m4


git-svn-id: https://google-glog.googlecode.com/svn/trunk@55 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-08 15:41:38 +00:00
424c6fc5c2 Fix regression of r23.
http://code.google.com/p/google-glog/source/detail?r=23


git-svn-id: https://google-glog.googlecode.com/svn/trunk@54 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-08 15:38:35 +00:00
f0f26f1ee0 Utilize AM_CXXFLAGS.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@53 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-08 15:30:26 +00:00
5f9c97a33c Run benchmarks only when --run_benchmark is specified.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@52 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-07-07 03:10:39 +00:00
c1995cd469 Encapsulate the definition of Mutex into glog's internal namespace.
This will fix the issue a user in Japan reported in his blog.

http://kzk9.net/blog/2009/05/deadlock_with_gflags_and_glog_2.html

According to his description, when he use glog and gflags-1.1, gflags'
code uses glog's Mutex, the Mutex cannot lock the pthread_mutex, and
the program stops.

The bug happens with the combination of gflags-1.1 and glog. It seems
that the issue was caused by incompatibility of Mutex classes. Though I
couldn't reproduce this issue, the reporter of this bug said that
adding namespace fixes the problem and I think it is generally good
idea to use namespace for this kind of common component to avoid
incompatibilities. So, I check this change in now. This patch
will protect glog from future changes on Mutex as well.
--This line, and  those below, will be ignored--

M    src/base/mutex.h


git-svn-id: https://google-glog.googlecode.com/svn/trunk@51 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-05-20 05:55:40 +00:00
7b97abb978 Suppress warnings (re-definition of _XOPEN_SOURCE) by including utilities.h first.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@50 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-05-19 09:12:00 +00:00
94a3b0ed4f Add -lgflags into LD_FLAGS when gflags is detected and --with-gflags isn't specified. Thanks kzk for this patch!
git-svn-id: https://google-glog.googlecode.com/svn/trunk@49 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-04-22 04:28:59 +00:00
ca448a53a0 Release 0.2.1.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@48 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-04-10 16:27:12 +00:00
a86eb1ac62 Check if InitGoogleLogging is not called twice.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@47 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-04-10 16:15:53 +00:00
e334c48314 Generation of pkg-config metadata file.
Thanks Tomasz for this contribution!


git-svn-id: https://google-glog.googlecode.com/svn/trunk@46 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-04-10 05:49:58 +00:00
ddfd1884b6 A bug fix for Windows: Use GetSystemTimeAsFileTime instead of GetSystemTime. SYSTEMTIME's mSecond is not a unix time but like tm.tm_sec.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@45 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-04-09 07:49:44 +00:00
8cf64cc167 Use struct instead of class for forward declaration of CrashReason as we define it as struct.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@44 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-04-07 09:03:16 +00:00
e8531d6b71 Fix a silly bug. I submitted wrong version of auto generated script.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@43 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-04-07 08:01:03 +00:00
315d590cdc Apply patch given by maw (thanks!). The patch was modified a bit using AC_ARG_WITH.
- Fix build problems when building with gtest.
- --with-gflags support.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@42 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-04-07 06:33:09 +00:00
b86afef3f7 Fixes for GCC 4.4. Thanks John for this patch!
git-svn-id: https://google-glog.googlecode.com/svn/trunk@41 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-03-10 02:15:40 +00:00
4a3f102ce0 Introduce RecordCrashReason().
git-svn-id: https://google-glog.googlecode.com/svn/trunk@40 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-03-04 10:16:33 +00:00
f365379532 Add license information for all source code.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@39 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-01-28 17:04:50 +00:00
e70803833d Bug fix: ifdef guard for InitGoogleMock must be HAVE_LIB_GMOCK rather than HAVE_LIB_GTEST.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@38 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-01-24 19:25:56 +00:00
0b79295aa9 Add mock-log.h into distribution.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@37 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-01-23 22:50:55 +00:00
c545928d5c Release 0.2.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@36 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-01-23 19:18:59 +00:00
f97a7c7332 Add README.windows, based on google-perftools'.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@35 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-01-23 19:01:22 +00:00
8ef5cd3398 Regenerate header files for VC++.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@34 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-01-23 19:00:09 +00:00
a82b66f208 Add static library project and its unittest.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@33 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-01-23 18:56:19 +00:00
0c6fdbd87f Remove the name of unused parameter.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@32 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-01-23 18:49:53 +00:00
630e77bac0 Remove unnecessary #include.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@31 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-01-23 18:48:11 +00:00
c3441fb6ba Better Cygwin support.
- configure.ac: Add -lpthread only if acx_pthread_ok is yes. In cygwin, we use Windows' thread so that we don't need -lpthread.
- base/mutex.h: Define NOMINMAX before we include windows.h.
- glog/*.h: Make sure that dllimport doesn't appear in cygwin. Note that windows.h may define _WIN32 macro.
- utilities.h: Define OS_CYGWIN.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@30 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-01-22 18:22:48 +00:00
e31a91b650 * Add LOG_TO_STRING.
* Add LOG_AT_LEVEL.
* Add DVLOG.
* Add LOG_TO_SINK_ONLY.
* Log microseconds.
* Add --log_backtrace_at option.
* Introduce CrashReason class.
* Fix some bugs.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@29 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-01-15 10:34:35 +00:00
eecffc5aa5 Introduce mock-log.h for unittests.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@28 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-01-13 11:49:10 +00:00
9de1077eed Define ARRAYSIZE in utilities.h and use it.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@27 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-01-09 06:07:55 +00:00
cc27d6aa59 Use gtest and gmock if installed.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@26 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-01-05 06:05:01 +00:00
68e9555c91 Initialize gflags in signalhandler_unittest.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@25 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-01-05 05:56:05 +00:00
6dfafc4571 Fix a typo in commandlineflags.h.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@24 eb4d4688-79bd-11dd-afb4-1d65580434c0
2009-01-05 05:54:57 +00:00
afd586a5d5 Initial windows support. Now we don't have the stacktrace and several unittests.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@23 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-12-19 15:20:40 +00:00
c54c735616 Flush logs unsafely before program fails in the signal handler.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@22 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-12-19 06:49:33 +00:00
4f81d0f209 Add -lpthread in addition to -pthread on Linux.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@21 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-11-21 11:22:51 +00:00
5cecb10919 Release 0.1.2.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@20 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-11-19 05:34:01 +00:00
c9c8d24b26 Add an instruction about stacktrace on x86-64 in INSTALL file. Basically, this
note was copied from google-perftools's notice (google-perftools/INSTALL).  I
modified the notice because the situation around stacktracer is a bit different
between glog and perftools.  Perftool's tcmalloc hooks malloc and its
stacktracer must not call malloc.  In glog, stacktracer with malloc can be an
issue only when users use InstallFailureSignalHandler() and a signal is raised
inside malloc.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@19 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-11-18 11:28:39 +00:00
a00ca9b038 Fix a typo: s/gnore/ignore/
git-svn-id: https://google-glog.googlecode.com/svn/trunk@18 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-11-17 10:38:58 +00:00
32b7e7c1a4 Remove stacktrace.cc.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@17 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-11-17 08:32:28 +00:00
f9b58c5198 Re-organize the way to produce stacktrace.
Since we introduced the API to set signal handler and print a
stacktrace, we should avoid glibc's backtrace, which may call malloc.
Basically, we choose the way to produce a stacktrace as same as
perftools.

Also, I removed GetStackFrames, which is not used and not implemented
with glibc.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@16 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-11-17 07:58:10 +00:00
62a67b2516 Utilize the second parameter (version number) for deb.sh.
The original way (ls && tail -n 1) could not handle version numbers which have patch level proprely (e.g., 0.1.1.tar.gz is considered less than 0.1.tar.gz since ls command orders files lexicographically).


git-svn-id: https://google-glog.googlecode.com/svn/trunk@15 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-11-04 07:09:16 +00:00
1ea4ad6ba1 Use uintptr_t instead of int as the integer format of pthread_t.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@14 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-11-04 07:08:11 +00:00
d15fcf784c Stop to define DISALLOW_EVIL_CONSTRUCTORS to avoid name conflict.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@13 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-11-03 05:00:04 +00:00
198a6d51b2 Forgot to add file for the previous change...
Add InstallFailureSignalHandler().  The function installs a signal handler that will dump useful information when the program crashes on certain signals such as SIGSEGV.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@12 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-10-30 10:38:57 +00:00
91d9fd8814 Add InstallFailureSignalHandler(). The function installs a signal handler that
will dump useful information when the program crashes on certain signals such
as SIGSEGV.
Also, changed the version of autoconf (2.59 => 2.61).


git-svn-id: https://google-glog.googlecode.com/svn/trunk@11 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-10-30 10:33:45 +00:00
b8dbc14c51 ChangeLogs for glog 0.1.1.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@10 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-10-30 10:02:59 +00:00
c481ede8ce Use abort instead of exit.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@9 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-10-17 11:54:23 +00:00
2ed196e07a Fix a bug: vmodule didn't work with gflags. Since
gflags isn't initialized when REGISTER_MODULE_INITIALIZER is invoked,
we couldn't initialize vmodule_list properly. Modified to call
VLOG2Initializer in the first call of InitVLOG3__.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@8 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-10-17 11:53:23 +00:00
364832195d Use dladdr to get symbols for environments which doesn't use ELF and
has execinfo.h (e.g., MacOSX 10.5). Though dladdr may not be async
signal safe, it's OK since glog's stacktrace doesn't depend on signals.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@7 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-10-17 11:52:32 +00:00
e1fb8f60e9 Add __attribute__((noinline)) for StackGrowsDown. This is necessary for recent GCC (4.3).
git-svn-id: https://google-glog.googlecode.com/svn/trunk@6 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-10-14 00:32:16 +00:00
bf6108bb8c Fix the include paths in the document: s/google/glog/.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@5 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-10-10 15:19:23 +00:00
fc7c28797e Fix some syntax/HTML issues.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@4 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-10-08 12:18:45 +00:00
13b587131b Modify the content type for the document files.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@3 eb4d4688-79bd-11dd-afb4-1d65580434c0
2008-10-08 11:20:32 +00:00
173 changed files with 17247 additions and 50863 deletions

62
.bazelci/presubmit.yml Normal file
View File

@ -0,0 +1,62 @@
---
tasks:
ubuntu1804:
name: "Ubuntu 22.04"
platform: ubuntu2204
build_flags:
- "--features=layering_check"
- "--copt=-Werror"
build_targets:
- "//..."
test_flags:
- "--features=layering_check"
- "--copt=-Werror"
test_targets:
- "//..."
macos:
name: "macOS: latest Xcode"
platform: macos
build_flags:
- "--features=layering_check"
- "--copt=-Werror"
build_targets:
- "//..."
test_flags:
- "--features=layering_check"
- "--copt=-Werror"
test_targets:
- "//..."
windows-msvc:
name: "Windows: MSVC 2017"
platform: windows
environment:
BAZEL_VC: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC"
build_flags:
- "--features=layering_check"
- "--copt=/WX"
build_targets:
- "//..."
test_flags:
- "--features=layering_check"
- "--copt=/WX"
test_targets:
- "//..."
windows-clang-cl:
name: "Windows: Clang"
platform: windows
environment:
BAZEL_VC: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC"
build_flags:
- "--extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl"
- "--extra_execution_platforms=//:x64_windows-clang-cl"
- "--compiler=clang-cl"
- "--features=layering_check"
build_targets:
- "//..."
test_flags:
- "--extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl"
- "--extra_execution_platforms=//:x64_windows-clang-cl"
- "--compiler=clang-cl"
- "--features=layering_check"
test_targets:
- "//..."

168
.clang-format Normal file
View File

@ -0,0 +1,168 @@
---
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
SortPriority: 0
- Regex: '^<.*\.h>'
Priority: 1
SortPriority: 0
- Regex: '^<.*'
Priority: 2
SortPriority: 0
- Regex: '.*'
Priority: 3
SortPriority: 0
IncludeIsMainRegex: '([-_](test|unittest))?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: true
IndentGotoLabels: true
IndentPPDirectives: AfterHash
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: ''
BasedOnStyle: google
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: c++14
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
...

58
.clang-tidy Normal file
View File

@ -0,0 +1,58 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,google-*,modernize-*,-modernize-use-trailing-return-type,readability-*,portability-*,performance-*,bugprone-*,android-*,darwin-*,clang-analyzer-*'
WarningsAsErrors: ''
HeaderFilterRegex: ''
FormatStyle: file
CheckOptions:
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: '0'
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: '1'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
- key: google-build-namespaces.HeaderFileExtensions
value: ',h,hh,hpp,hxx'
- key: google-global-names-in-headers.HeaderFileExtensions
value: ',h,hh,hpp,hxx'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.BranchThreshold
value: '4294967295'
- key: google-readability-function-size.LineThreshold
value: '4294967295'
- key: google-readability-function-size.NestingThreshold
value: '4294967295'
- key: google-readability-function-size.ParameterThreshold
value: '4294967295'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-function-size.VariableThreshold
value: '4294967295'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: google-runtime-int.SignedTypePrefix
value: int
- key: google-runtime-int.TypeSuffix
value: ''
- key: google-runtime-int.UnsignedTypePrefix
value: uint
- key: google-runtime-references.WhiteListTypes
value: ''
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
...

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
*.h linguist-language=C++

10
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,10 @@
# Set update schedule for GitHub Actions
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"

69
.github/workflows/android.yml vendored Normal file
View File

@ -0,0 +1,69 @@
name: Android
on: [push, pull_request]
jobs:
build-android:
name: NDK-C++${{matrix.std}}-${{matrix.abi}}-${{matrix.build_type}}
runs-on: ubuntu-22.04
permissions:
actions: read
contents: read
security-events: write
defaults:
run:
shell: bash
env:
NDK_VERSION: 26.0.10792818
strategy:
fail-fast: true
matrix:
std: [14, 17, 20]
abi: [arm64-v8a, armeabi-v7a, x86_64, x86]
build_type: [Debug, Release]
steps:
- uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: cpp
- name: Setup Dependencies
run: |
sudo apt-get update
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \
cmake \
ninja-build
- name: Setup NDK
env:
ANDROID_SDK_ROOT: /usr/local/lib/android/sdk
run: |
echo 'y' | ${{env.ANDROID_SDK_ROOT}}/cmdline-tools/latest/bin/sdkmanager --install 'ndk;${{env.NDK_VERSION}}'
- name: Configure
env:
CXXFLAGS: -Wall -Wextra -Wpedantic -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror ${{env.CXXFLAGS}}
run: |
cmake -S . -B build_${{matrix.abi}} \
-DCMAKE_ANDROID_API=28 \
-DCMAKE_ANDROID_ARCH_ABI=${{matrix.abi}} \
-DCMAKE_ANDROID_NDK=/usr/local/lib/android/sdk/ndk/${{env.NDK_VERSION}} \
-DCMAKE_ANDROID_STL_TYPE=c++_shared \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_CXX_EXTENSIONS=OFF \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_SYSTEM_NAME=Android \
-G Ninja \
-Werror
- name: Build
run: |
cmake --build build_${{matrix.abi}} \
--config ${{matrix.build_type}}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3

26
.github/workflows/cifuzz.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: CIFuzz
on: [pull_request]
jobs:
Fuzzing:
runs-on: ubuntu-latest
steps:
- name: Build Fuzzers
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'glog'
dry-run: false
language: c++
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'glog'
fuzz-seconds: 60
dry-run: false
language: c++
- name: Upload Crash
uses: actions/upload-artifact@v4
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
path: ./out/artifacts

57
.github/workflows/emscripten.yml vendored Normal file
View File

@ -0,0 +1,57 @@
name: Emscripten
on: [push, pull_request]
jobs:
build-linux:
defaults:
run:
shell: bash
name: Emscripten-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}
runs-on: ubuntu-22.04
permissions:
actions: read
contents: read
security-events: write
container: emscripten/emsdk
strategy:
fail-fast: true
matrix:
build_type: [Release, Debug]
lib: [static]
std: [14, 17, 20, 23]
steps:
- uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: cpp
- name: Setup Dependencies
run: |
sudo apt-get update
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \
cmake \
ninja-build
- name: Configure
env:
CXXFLAGS: -Wall -Wextra -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror -Wno-error=wasm-exception-spec ${{env.CXXFLAGS}}
run: |
emcmake cmake -S . -B build_${{matrix.build_type}} \
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install \
-G Ninja \
-Werror
- name: Build
run: |
cmake --build build_${{matrix.build_type}} \
--config ${{matrix.build_type}}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3

120
.github/workflows/linux.yml vendored Normal file
View File

@ -0,0 +1,120 @@
name: Linux
on: [push, pull_request]
jobs:
build-linux:
defaults:
run:
shell: bash
name: GCC-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}
runs-on: ubuntu-22.04
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: true
matrix:
build_type: [Release, Debug]
lib: [shared, static]
std: [14, 17, 20, 23]
steps:
- uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: cpp
- name: Setup Dependencies
run: |
sudo apt-get update
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y --no-install-suggests --no-install-recommends \
g++ \
cmake \
gcovr \
libgflags-dev \
libgmock-dev \
libgtest-dev \
libunwind-dev \
ninja-build
- name: Setup Environment
if: matrix.build_type == 'Debug'
run: |
echo 'CXXFLAGS=--coverage' >> $GITHUB_ENV
- name: Configure
env:
CXXFLAGS: -Wall -Wextra -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror ${{env.CXXFLAGS}}
run: |
cmake -S . -B build_${{matrix.build_type}} \
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install \
-G Ninja \
-Werror
- name: Build
run: |
cmake --build build_${{matrix.build_type}} \
--config ${{matrix.build_type}}
- name: Install
run: |
cmake --build build_${{matrix.build_type}} \
--config ${{matrix.build_type}} \
--target install
cmake build_${{matrix.build_type}} \
-DCMAKE_INSTALL_INCLUDEDIR=${{runner.workspace}}/foo/include \
-DCMAKE_INSTALL_LIBDIR=${{runner.workspace}}/foo/lib \
-DCMAKE_INSTALL_DATAROOTDIR=${{runner.workspace}}/foo/share
cmake --build build_${{matrix.build_type}} \
--config ${{matrix.build_type}} \
--target install
- name: Test CMake Package (relative GNUInstallDirs)
run: |
cmake -S src/package_config_unittest/working_config \
-B build_${{matrix.build_type}}_package \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_PREFIX_PATH=${{github.workspace}}/install \
-G Ninja
cmake --build build_${{matrix.build_type}}_package \
--config ${{matrix.build_type}}
- name: Test CMake Package (absolute GNUInstallDirs)
run: |
cmake -S src/package_config_unittest/working_config \
-B build_${{matrix.build_type}}_package_foo \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_PREFIX_PATH=${{runner.workspace}}/foo \
-G Ninja
cmake --build build_${{matrix.build_type}}_package_foo \
--config ${{matrix.build_type}}
- name: Test
run: |
ctest --test-dir build_${{matrix.build_type}} -j$(nproc) --output-on-failure
- name: Generate Coverage
if: matrix.build_type == 'Debug'
run: |
cd build_${{matrix.build_type}}
gcovr -r .. . -s --xml coverage.xml
- name: Upload Coverage to Codecov
if: matrix.build_type == 'Debug'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: build_${{matrix.build_type}}/coverage.xml
fail_ci_if_error: true
verbose: true
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3

76
.github/workflows/macos.yml vendored Normal file
View File

@ -0,0 +1,76 @@
name: macOS
on: [push, pull_request]
jobs:
build-macos:
name: AppleClang-C++${{matrix.std}}-${{matrix.build_type}}
runs-on: macos-12
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: true
matrix:
std: [14, 17, 20, 23]
include:
- generator: Xcode
- build_type: Debug
steps:
- uses: actions/checkout@v4
- name: Setup Dependencies
run: |
brew install ninja
- name: Setup Coverage Dependencies
if: matrix.build_type == 'Debug'
run: |
brew install gcovr
- name: Setup Environment
if: matrix.build_type == 'Debug'
run: |
echo 'CXXFLAGS=--coverage' >> $GITHUB_ENV
echo 'LDFLAGS=--coverage' >> $GITHUB_ENV
- name: Configure
shell: bash
env:
CXXFLAGS: -Wall -Wextra -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror -pedantic-errors ${{env.CXXFLAGS}}
run: |
cmake -S . -B build_${{matrix.build_type}} \
-DCMAKE_CXX_EXTENSIONS=OFF \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-G "${{matrix.generator}}" \
-Werror
- name: Build
run: |
cmake --build build_${{matrix.build_type}} \
--config ${{matrix.build_type}}
- name: Test
run: |
ctest --test-dir build_${{matrix.build_type}} \
--build-config ${{matrix.build_type}} \
--output-on-failure
- name: Generate Coverage
if: matrix.build_type == 'Debug'
run: |
cd build_${{matrix.build_type}}
rm -r Tests/
gcovr -r .. . -s --cobertura coverage.xml
- name: Upload Coverage to Codecov
if: matrix.build_type == 'Debug'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: build_${{matrix.build_type}}/coverage.xml
fail_ci_if_error: true
verbose: true

245
.github/workflows/windows.yml vendored Normal file
View File

@ -0,0 +1,245 @@
name: Windows
on: [push, pull_request]
jobs:
build-msvc:
name: ${{matrix.msvc}}-${{matrix.arch}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}
runs-on: ${{matrix.os}}
permissions:
actions: read
contents: read
security-events: write
defaults:
run:
shell: powershell
env:
CL: /MP
CXXFLAGS: /WX /permissive-
strategy:
fail-fast: true
matrix:
arch: [Win32, x64]
build_type: [Debug, Release]
lib: [shared, static]
msvc: [VS-16-2019, VS-17-2022]
std: [14, 17, 20, 23]
include:
- msvc: VS-16-2019
os: windows-2019
generator: 'Visual Studio 16 2019'
- msvc: VS-17-2022
os: windows-2022
generator: 'Visual Studio 17 2022'
steps:
- uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: cpp
- name: Cache GTest
id: cache-gtest
uses: actions/cache@v4
with:
path: gtest/
key: ${{runner.os}}-gtest-1.14-${{matrix.lib}}-${{matrix.arch}}-${{matrix.build_type}}
- name: Download GTest
if: steps.cache-gtest.outputs.cache-hit != 'true'
run: |
(New-Object System.Net.WebClient).DownloadFile("https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip", "v1.14.0.zip")
Expand-Archive v1.14.0.zip .
- name: Build GTest
if: steps.cache-gtest.outputs.cache-hit != 'true'
run: |
cmake -S googletest-1.14.0 -B build-googletest `
-A ${{matrix.arch}} `
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} `
-Dgtest_force_shared_crt=ON `
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/gtest
cmake --build build-googletest `
--config ${{matrix.build_type}} `
--target install
- name: Cache gflags
id: cache-gflags
uses: actions/cache@v4
with:
path: gflags/
key: ${{runner.os}}-gflags-2.2.2-${{matrix.lib}}-${{matrix.arch}}-${{matrix.build_type}}
- name: Download gflags
if: steps.cache-gflags.outputs.cache-hit != 'true'
run: |
(New-Object System.Net.WebClient).DownloadFile("https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.zip", "v2.2.2.zip")
Expand-Archive v2.2.2.zip .
- name: Build gflags
if: steps.cache-gflags.outputs.cache-hit != 'true'
run: |
cmake -S gflags-2.2.2 -B build-gflags `
-A ${{matrix.arch}} `
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} `
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/gflags
cmake --build build-gflags `
--config ${{matrix.build_type}} `
--target install
- name: Setup Environment
run: |
echo "GTest_ROOT=$((Get-Item .).FullName)/gtest" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "gflags_ROOT=$((Get-Item .).FullName)/gflags" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "${{github.workspace}}/gtest/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "${{github.workspace}}/gflags/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Setup Release Environment
if: matrix.build_type != 'Debug'
run: |
echo "CXXFLAGS=/Zi ${{env.CXXFLAGS}}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Configure
run: |
cmake -S . -B build_${{matrix.build_type}} `
-A ${{matrix.arch}} `
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} `
-DCMAKE_CXX_EXTENSIONS=OFF `
-DCMAKE_CXX_STANDARD=${{matrix.std}} `
-DCMAKE_CXX_STANDARD_REQUIRED=ON `
-DCMAKE_EXE_LINKER_FLAGS='/NOIMPLIB' `
-DCMAKE_EXE_LINKER_FLAGS_RELEASE='/INCREMENTAL:NO /DEBUG' `
-DCMAKE_INSTALL_PREFIX:PATH=./install `
-DCMAKE_MSVC_RUNTIME_LIBRARY='MultiThreaded$<$<CONFIG:Debug>:Debug>DLL' `
-G "${{matrix.generator}}" `
-Werror
- name: Build
run: cmake --build build_${{matrix.build_type}} `
--config ${{matrix.build_type}}
- name: Test
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: |
cmake --build build_${{matrix.build_type}}/ `
--config ${{matrix.build_type}} `
--target RUN_TESTS
- name: Install
run: |
cmake --build build_${{matrix.build_type}}/ `
--config ${{matrix.build_type}} `
--target install
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: language:cpp
build-mingw:
name: ${{matrix.sys}}-${{matrix.env}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}
runs-on: windows-2022
permissions:
actions: read
contents: read
security-events: write
env:
BUILDDIR: 'build_${{matrix.sys}}-${{matrix.env}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}'
defaults:
run:
shell: msys2 {0}
strategy:
fail-fast: true
matrix:
build_type: [Debug]
lib: [shared, static]
std: [14, 17, 20, 23]
sys: [mingw32, mingw64]
include:
- sys: mingw32
env: i686
- sys: mingw64
env: x86_64
steps:
- uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: cpp
- uses: msys2/setup-msys2@v2
with:
msystem: ${{matrix.sys}}
install: >-
mingw-w64-${{matrix.env}}-cmake
mingw-w64-${{matrix.env}}-gcc
mingw-w64-${{matrix.env}}-gflags
mingw-w64-${{matrix.env}}-ninja
mingw-w64-${{matrix.env}}-python-jinja
mingw-w64-${{matrix.env}}-python-lxml
mingw-w64-${{matrix.env}}-python-pip
mingw-w64-${{matrix.env}}-python-pygments
- name: Setup Coverage Dependencies
if: matrix.build_type == 'Debug'
run: |
pip install 'gcovr==7.0'
- name: Setup Environment
if: matrix.build_type == 'Debug'
run: |
echo 'CXXFLAGS=--coverage ${{env.CXXFLAGS}}' >> $GITHUB_ENV
- name: Configure
env:
CXXFLAGS: -Wall -Wextra -Wpedantic -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror ${{env.CXXFLAGS}}
run: |
cmake -S . -B build_${{matrix.build_type}}/ \
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_CXX_EXTENSIONS=OFF \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_INSTALL_PREFIX:PATH=./install \
-G Ninja \
-Werror
- name: Build
run: |
cmake --build build_${{matrix.build_type}}/ --config ${{matrix.build_type}}
- name: Test
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: |
cmake --build build_${{matrix.build_type}}/ --config ${{matrix.build_type}} \
--target test
- name: Install
run: |
cmake --build build_${{matrix.build_type}}/ \
--config ${{matrix.build_type}} \
--target install
- name: Generate Coverage
if: matrix.build_type == 'Debug'
run: |
cd build_${{matrix.build_type}}
gcovr -r .. . -s --cobertura coverage.xml
- name: Upload Coverage to Codecov
if: matrix.build_type == 'Debug'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: build_${{matrix.build_type}}/coverage.xml
fail_ci_if_error: true
verbose: true
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
*.orig
/build*/
/site/
bazel-*
# Bzlmod lockfile
/MODULE.bazel.lock

30
AUTHORS
View File

@ -1,2 +1,30 @@
opensource@google.com
# This is the official list of glog authors for copyright purposes.
# This file is distinct from the CONTRIBUTORS files.
# See the latter for an explanation.
#
# Names should be added to this file as:
# Name or Organization <email address>
# The email address is not required for organizations.
#
# Please keep the list sorted.
Abhishek Dasgupta <abhi2743@gmail.com>
Abhishek Parmar <abhishek@orng.net>
Andrew Schwartzmeyer <andrew@schwartzmeyer.com>
Andy Ying <andy@trailofbits.com>
Brian Silverman <bsilver16384@gmail.com>
Dmitriy Arbitman <d.arbitman@gmail.com>
Google Inc.
Guillaume Dumont <dumont.guillaume@gmail.com>
LingBin <lingbinlb@gmail.com>
Marco Wang <m.aesophor@gmail.com>
Michael Tanner <michael@tannertaxpro.com>
MiniLight <MiniLightAR@Gmail.com>
romange <romange@users.noreply.github.com>
Roman Perepelitsa <roman.perepelitsa@gmail.com>
Sergiu Deitsch <sergiu.deitsch@gmail.com>
tbennun <tbennun@gmail.com>
Teddy Reed <teddy@prosauce.org>
Vijaymahantesh Sattigeri <vijaymahantesh016@gmail.com>
Zhongming Qu <qzmfranklin@gmail.com>
Zhuoran Shen <cmsflash99@gmail.com>

22
BUILD.bazel Normal file
View File

@ -0,0 +1,22 @@
licenses(["notice"])
exports_files(["COPYING"])
load(":bazel/glog.bzl", "glog_library")
glog_library()
# platform() to build with clang-cl on Bazel CI. This is enabled with
# the flags in .bazelci/presubmit.yml:
#
# --incompatible_enable_cc_toolchain_resolution
# --extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl
# --extra_execution_platforms=//:x64_windows-clang-cl
platform(
name = "x64_windows-clang-cl",
constraint_values = [
"@platforms//cpu:x86_64",
"@platforms//os:windows",
"@rules_cc//cc/private/toolchain:clang-cl",
],
)

1059
CMakeLists.txt Normal file

File diff suppressed because it is too large Load Diff

54
CONTRIBUTORS Normal file
View File

@ -0,0 +1,54 @@
# People who have agreed to one of the CLAs and can contribute patches.
# The AUTHORS file lists the copyright holders; this file
# lists people. For example, Google employees are listed here
# but not in AUTHORS, because Google holds the copyright.
#
# Names should be added to this file only after verifying that
# the individual or the individual's organization has agreed to
# the appropriate Contributor License Agreement, found here:
#
# https://developers.google.com/open-source/cla/individual
# https://developers.google.com/open-source/cla/corporate
#
# The agreement for individuals can be filled out on the web.
#
# When adding J Random Contributor's name to this file,
# either J's name or J's organization's name should be
# added to the AUTHORS file, depending on whether the
# individual or corporate CLA was used.
#
# Names should be added to this file as:
# Name <email address>
#
# Please keep the list sorted.
Abhishek Dasgupta <abhi2743@gmail.com>
Abhishek Parmar <abhishek@orng.net>
Andrew Schwartzmeyer <andrew@schwartzmeyer.com>
Andy Ying <andy@trailofbits.com>
Bret McKee <bretmckee@google.com>
Brian Silverman <bsilver16384@gmail.com>
Dmitriy Arbitman <d.arbitman@gmail.com>
Eric Kilmer <eric.d.kilmer@gmail.com>
Fumitoshi Ukai <ukai@google.com>
Guillaume Dumont <dumont.guillaume@gmail.com>
Håkan L. S. Younes <hyounes@google.com>
Ivan Penkov <ivanpe@google.com>
Jacob Trimble <modmaker@google.com>
Jim Ray <jimray@google.com>
LingBin <lingbinlb@gmail.com>
Marco Wang <m.aesophor@gmail.com>
Michael Darr <mdarr@matician.com>
Michael Tanner <michael@tannertaxpro.com>
MiniLight <MiniLightAR@Gmail.com>
Peter Collingbourne <pcc@google.com>
Rodrigo Queiro <rodrigoq@google.com>
romange <romange@users.noreply.github.com>
Roman Perepelitsa <roman.perepelitsa@gmail.com>
Sergiu Deitsch <sergiu.deitsch@gmail.com>
Shinichiro Hamaji <hamaji@google.com>
tbennun <tbennun@gmail.com>
Teddy Reed <teddy@prosauce.org>
Vijaymahantesh Sattigeri <vijaymahantesh016@gmail.com>
Zhongming Qu <qzmfranklin@gmail.com>
Zhuoran Shen <cmsflash99@gmail.com>

113
ChangeLog
View File

@ -1,3 +1,116 @@
2024-06-08 Google Inc. <opensource@google.com>
* google-glog: version 0.7.1.
* See git log for the details.
2024-02-17 Google Inc. <opensource@google.com>
* google-glog: version 0.7.0.
* See git log for the details.
2022-04-05 Google Inc. <opensource@google.com>
* google-glog: version 0.6.0.
* See git log for the details.
2021-05-08 Google Inc. <opensource@google.com>
* google-glog: version 0.5.0.
* See git log for the details.
2019-01-22 Google Inc. <opensource@google.com>
* google-glog: version 0.4.0.
* See git log for the details.
2017-05-09 Google Inc. <opensource@google.com>
* google-glog: version 0.3.5
* See git log for the details.
2015-03-09 Google Inc. <opensource@google.com>
* google-glog: version 0.3.4
* See git log for the details.
2013-02-01 Google Inc. <opensource@google.com>
* google-glog: version 0.3.3
* Add --disable-rtti option for configure.
* Visual Studio build and test fix.
* QNX build fix (thanks vanuan).
* Reduce warnings.
* Fixed LOG_SYSRESULT (thanks ukai).
* FreeBSD build fix (thanks yyanagisawa).
* Clang build fix.
* Now users can re-initialize glog after ShutdownGoogleLogging.
* Color output support by GLOG_colorlogtostderr (thanks alexs).
* Now glog's ABI around flags are compatible with gflags.
* Document mentions how to modify flags from user programs.
2012-01-12 Google Inc. <opensource@google.com>
* google-glog: version 0.3.2
* Clang support.
* Demangler and stacktrace improvement for newer GCCs.
* Now fork(2) doesn't mess up log files.
* Make valgrind happier.
* Reduce warnings for more -W options.
* Provide a workaround for ERROR defined by windows.h.
2010-06-15 Google Inc. <opensource@google.com>
* google-glog: version 0.3.1
* GLOG_* environment variables now work even when gflags is installed.
* Snow leopard support.
* Now we can build and test from out side tree.
* Add DCHECK_NOTNULL.
* Add ShutdownGoogleLogging to close syslog (thanks DGunchev)
* Fix --enable-frame-pointers option (thanks kazuki.ohta)
* Fix libunwind detection (thanks giantchen)
2009-07-30 Google Inc. <opensource@google.com>
* google-glog: version 0.3.0
* Fix a deadlock happened when user uses glog with recent gflags.
* Suppress several unnecessary warnings (thanks keir).
* NetBSD and OpenBSD support.
* Use Win32API GetComputeNameA properly (thanks magila).
* Fix user name detection for Windows (thanks ademin).
* Fix several minor bugs.
2009-04-10 Google Inc. <opensource@google.com>
* google-glog: version 0.2.1
* Fix timestamps of VC++ version.
* Add pkg-config support (thanks Tomasz)
* Fix build problem when building with gtest (thanks Michael)
* Add --with-gflags option for configure (thanks Michael)
* Fixes for GCC 4.4 (thanks John)
2009-01-23 Google Inc. <opensource@google.com>
* google-glog: version 0.2
* Add initial Windows VC++ support.
* Google testing/mocking frameworks integration.
* Link pthread library automatically.
* Flush logs in signal handlers.
* Add macros LOG_TO_STRING, LOG_AT_LEVEL, DVLOG, and LOG_TO_SINK_ONLY.
* Log microseconds.
* Add --log_backtrace_at option.
* Fix some minor bugs.
2008-11-18 Google Inc. <opensource@google.com>
* google-glog: version 0.1.2
* Add InstallFailureSignalHandler(). (satorux)
* Re-organize the way to produce stacktraces.
* Don't define unnecessary macro DISALLOW_EVIL_CONSTRUCTORS.
2008-10-15 Google Inc. <opensource@google.com>
* google-glog: version 0.1.1
* Support symbolize for MacOSX 10.5.
* BUG FIX: --vmodule didn't work with gflags.
* BUG FIX: symbolize_unittest failed with GCC 4.3.
* Several fixes on the document.
2008-10-07 Google Inc. <opensource@google.com>
* google-glog: initial release:

230
INSTALL
View File

@ -1,230 +0,0 @@
Copyright 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. (Caching is
disabled by default to prevent problems with accidental use of stale
cache files.)
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You only need
`configure.ac' if you want to change it or regenerate `configure' using
a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. Run `./configure --help'
for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not support the `VPATH'
variable, you have to compile the package for one architecture at a
time in the source code directory. After you have installed the
package for one architecture, use `make distclean' before reconfiguring
for another architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the `--target=TYPE' option to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
will cause the specified gcc to be used as the C compiler (unless it is
overridden in the site shell script).
`configure' Invocation
======================
`configure' recognizes the following options to control how it
operates.
`--help'
`-h'
Print a summary of the options to `configure', and exit.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

View File

@ -1,19 +1,18 @@
Copyright (c) 2008, Google Inc.
Copyright © 2024, Google Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name of Google Inc. nor the names of its contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT

13
MODULE.bazel Normal file
View File

@ -0,0 +1,13 @@
module(
name = "glog",
compatibility_level = 1,
)
bazel_dep(name = "gflags", version = "2.2.2")
bazel_dep(name = "googletest", version = "1.14.0", dev_dependency = True)
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "rules_cc", version = "0.0.12")
# Required for Windows clang-cl build: --extra_toolchains=@local_config_cc//:cc-toolchain-arm64_windows
cc_configure = use_extension("@rules_cc//cc:extensions.bzl", "cc_configure_extension")
use_repo(cc_configure, "local_config_cc")

View File

@ -1,172 +0,0 @@
## Process this file with automake to produce Makefile.in
# Make sure that when we re-make ./configure, we get the macros we need
ACLOCAL_AMFLAGS = -I m4
# This is so we can #include <glog/foo>
AM_CPPFLAGS = -I$(top_srcdir)/src
# This is mostly based on configure options
AM_CXXFLAGS =
# These are good warnings to turn on by default
if GCC
AM_CXXFLAGS += -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare
endif
# These are x86-specific, having to do with frame-pointers
if X86_64
if ENABLE_FRAME_POINTERS
AM_CXXFLAGS += -fno-omit-frame-pointer
else
# TODO(csilvers): check if -fomit-frame-pointer might be in $(CXXFLAGS),
# before setting this.
AM_CXXFLAGS += -DNO_FRAME_POINTER
endif
endif
glogincludedir = $(includedir)/glog
## The .h files you want to install (that is, .h files that people
## who install this package can include in their own applications.)
gloginclude_HEADERS = src/glog/log_severity.h src/glog/logging.h src/glog/raw_logging.h src/glog/vlog_is_on.h src/glog/stl_logging.h
docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION)
## This is for HTML and other documentation you want to install.
## Add your documentation files (in doc/) in addition to these
## top-level boilerplate files. Also add a TODO file if you have one.
dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README \
doc/designstyle.css doc/glog.html
## The libraries (.so's) you want to install
lib_LTLIBRARIES =
## unittests you want to run when people type 'make check'.
## TESTS is for binary unittests, check_SCRIPTS for script-based unittests.
## TESTS_ENVIRONMENT sets environment variables for when you run unittest,
## but it only seems to take effect for *binary* unittests (argh!)
TESTS =
TESTS_ENVIRONMENT =
check_SCRIPTS =
# Every time you add a unittest to check_SCRIPTS, add it here too
noinst_SCRIPTS =
# Binaries used for script-based unittests.
TEST_BINARIES =
TESTS += logging_unittest
logging_unittest_SOURCES = $(gloginclude_HEADERS) src/config.h \
src/logging_unittest.cc
logging_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
logging_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
logging_unittest_LDADD = libglog.la $(PTHREAD_LIBS) $(GFLAGS_LIBS)
check_SCRIPTS += logging_striplog_test_sh
noinst_SCRIPTS += src/logging_striplog_test.sh
logging_striplog_test_sh: logging_striptest0 logging_striptest2 logging_striptest10
$(top_srcdir)/src/logging_striplog_test.sh
check_SCRIPTS += demangle_unittest_sh
noinst_SCRIPTS += src/demangle_unittest.sh
demangle_unittest_sh: demangle_unittest
$(top_srcdir)/demangle_unittest # force to create lt-demangle_unittest
$(top_srcdir)/src/demangle_unittest.sh
TEST_BINARIES += logging_striptest0
logging_striptest0_SOURCES = $(gloginclude_HEADERS) src/config.h \
src/logging_striptest_main.cc
logging_striptest0_CXXFLAGS = $(PTHREAD_CFLAGS)
logging_striptest0_LDFLAGS = $(PTHREAD_CFLAGS)
logging_striptest0_LDADD = libglog.la $(PTHREAD_LIBS) $(GFLAGS_LIBS)
TEST_BINARIES += logging_striptest2
logging_striptest2_SOURCES = $(gloginclude_HEADERS) src/config.h \
src/logging_striptest2.cc
logging_striptest2_CXXFLAGS = $(PTHREAD_CFLAGS)
logging_striptest2_LDFLAGS = $(PTHREAD_CFLAGS)
logging_striptest2_LDADD = libglog.la $(PTHREAD_LIBS) $(GFLAGS_LIBS)
TEST_BINARIES += logging_striptest10
logging_striptest10_SOURCES = $(gloginclude_HEADERS) src/config.h \
src/logging_striptest10.cc
logging_striptest10_CXXFLAGS = $(PTHREAD_CFLAGS)
logging_striptest10_LDFLAGS = $(PTHREAD_CFLAGS)
logging_striptest10_LDADD = libglog.la $(PTHREAD_LIBS) $(GFLAGS_LIBS)
TESTS += demangle_unittest
demangle_unittest_SOURCES = $(gloginclude_HEADERS) src/config.h \
src/demangle_unittest.cc
demangle_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
demangle_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
demangle_unittest_LDADD = libglog.la $(PTHREAD_LIBS) $(GFLAGS_LIBS)
TESTS += stacktrace_unittest
stacktrace_unittest_SOURCES = $(gloginclude_HEADERS) src/config.h \
src/stacktrace_unittest.cc
stacktrace_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
stacktrace_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
stacktrace_unittest_LDADD = libglog.la $(PTHREAD_LIBS) $(GFLAGS_LIBS)
TESTS += symbolize_unittest
symbolize_unittest_SOURCES = $(gloginclude_HEADERS) src/config.h \
src/symbolize_unittest.cc
symbolize_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
symbolize_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
symbolize_unittest_LDADD = libglog.la $(PTHREAD_LIBS) $(GFLAGS_LIBS)
TESTS += stacktrace_framesizes_unittest
stacktrace_framesizes_unittest_SOURCES = $(gloginclude_HEADERS) src/config.h \
src/stacktrace_framesizes_unittest.cc
stacktrace_framesizes_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
stacktrace_framesizes_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
stacktrace_framesizes_unittest_LDADD = libglog.la $(PTHREAD_LIBS) $(GFLAGS_LIBS)
TESTS += stl_logging_unittest
stl_logging_unittest_SOURCES = $(gloginclude_HEADERS) src/config.h \
src/stl_logging_unittest.cc
stl_logging_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
stl_logging_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
stl_logging_unittest_LDADD = libglog.la $(PTHREAD_LIBS) $(GFLAGS_LIBS)
## vvvv RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS
lib_LTLIBRARIES += libglog.la
libglog_la_SOURCES = $(gloginclude_HEADERS) src/config.h \
src/logging.cc src/raw_logging.cc src/vlog_is_on.cc \
src/utilities.cc src/utilities.h \
src/demangle.cc src/demangle.h \
src/stacktrace.cc src/stacktrace.h \
src/stacktrace_generic-inl.h \
src/stacktrace_libunwind-inl.h \
src/stacktrace_powerpc-inl.h \
src/stacktrace_x86-inl.h \
src/stacktrace_x86_64-inl.h \
src/symbolize.cc src/symbolize.h \
src/base/mutex.h src/base/googleinit.h \
src/base/commandlineflags.h src/googletest.h
libglog_la_CXXFLAGS = $(PTRHEAD_CFLAGS) -DNDEBUG
libglog_la_LDFLAGS = $(PTRHEAD_CFLAGS)
libglog_la_LIBADD = $(PTHREAD_LIBS)
## ^^^^ END OF RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS
## This should always include $(TESTS), but may also include other
## binaries that you compile but don't want automatically installed.
noinst_PROGRAMS = $(TESTS) $(TEST_BINARIES)
rpm: dist-gzip packages/rpm.sh packages/rpm/rpm.spec
@cd packages && ./rpm.sh ${PACKAGE} ${VERSION}
deb: dist-gzip packages/deb.sh packages/deb/*
@cd packages && ./deb.sh ${PACKAGE} ${VERSION}
# TODO(hamaji): We don't support Visual Studio for now.
## Windows wants write permission to .vcproj files and maybe even sln files.
#dist-hook:
# test -e "$(distdir)/vsprojects" \
# && chmod -R u+w $(distdir)/*.sln $(distdir)/vsprojects/
libtool: $(LIBTOOL_DEPS)
$(SHELL) ./config.status --recheck
EXTRA_DIST = packages/rpm.sh packages/rpm/rpm.spec packages/deb.sh packages/deb \
$(SCRIPTS) src/logging_unittest.err src/demangle_unittest.txt

File diff suppressed because it is too large Load Diff

0
NEWS
View File

5
README
View File

@ -1,5 +0,0 @@
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
./configure && make && make install

23
README.rst Normal file
View File

@ -0,0 +1,23 @@
Google Logging Library
======================
|Linux Github actions| |Windows Github actions| |macOS Github actions| |Codecov|
Google Logging (glog) is a C++14 library that implements application-level
logging. The library provides logging APIs based on C++-style streams and
various helper macros.
Getting Started
---------------
Please refer to project's `documentation <https://google.github.io/glog/>`_.
.. |Linux Github actions| image:: https://github.com/google/glog/actions/workflows/linux.yml/badge.svg
:target: https://github.com/google/glog/actions
.. |Windows Github actions| image:: https://github.com/google/glog/actions/workflows/windows.yml/badge.svg
:target: https://github.com/google/glog/actions
.. |macOS Github actions| image:: https://github.com/google/glog/actions/workflows/macos.yml/badge.svg
:target: https://github.com/google/glog/actions
.. |Codecov| image:: https://codecov.io/gh/google/glog/branch/master/graph/badge.svg?token=8an420vNju
:target: https://codecov.io/gh/google/glog

1
WORKSPACE.bazel Normal file
View File

@ -0,0 +1 @@
# WORKSPACE marker file needed by Bazel

7274
aclocal.m4 vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +0,0 @@
#!/bin/sh
# Before using, you should figure out all the .m4 macros that your
# configure.m4 script needs and make sure they exist in the autoconf/
# directory.
#
# These are the files that this script might edit:
# aclocal.m4 configure Makefile.in src/config.h.in \
# depcomp config.guess config.sub install-sh missing mkinstalldirs \
# ltmain.sh
#
# Here's a command you can run to see what files aclocal will import:
# aclocal -I ../autoconf --output=- | sed -n 's/^m4_include..\([^]]*\).*/\1/p'
set -ex
rm -rf autom4te.cache
aclocal --force -I m4
grep -q LIBTOOL configure.ac && libtoolize -c -f
autoconf -f -W all,no-obsolete
autoheader -f -W all
automake -a -c -f -W all
rm -rf autom4te.cache
exit 0

View File

@ -0,0 +1,9 @@
cc_test(
name = "main",
size = "small",
srcs = ["main.cc"],
deps = [
"//:glog",
"@gflags//:gflags",
],
)

22
bazel/example/main.cc Normal file
View File

@ -0,0 +1,22 @@
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <glog/stl_logging.h>
int main(int argc, char* argv[]) {
// Initialize Google's logging library.
google::InitGoogleLogging(argv[0]);
// Optional: parse command line flags
gflags::ParseCommandLineFlags(&argc, &argv, true);
LOG(INFO) << "Hello, world!";
// glog/stl_logging.h allows logging STL containers.
std::vector<int> x;
x.push_back(1);
x.push_back(2);
x.push_back(3);
LOG(INFO) << "ABC, it's easy as " << x;
return 0;
}

290
bazel/glog.bzl Normal file
View File

@ -0,0 +1,290 @@
# Implement a macro glog_library() that the BUILD.bazel file can load.
# By default, glog is built with gflags support. You can change this behavior
# by using glog_library(with_gflags=0)
#
# This file is inspired by the following sample BUILD files:
# https://github.com/google/glog/issues/61
# https://github.com/google/glog/files/393474/BUILD.txt
#
# Known issue: the namespace parameter is not supported on Win32.
def expand_template_impl(ctx):
ctx.actions.expand_template(
template = ctx.file.template,
output = ctx.outputs.out,
substitutions = ctx.attr.substitutions,
)
expand_template = rule(
implementation = expand_template_impl,
attrs = {
"template": attr.label(mandatory = True, allow_single_file = True),
"substitutions": attr.string_dict(mandatory = True),
"out": attr.output(mandatory = True),
},
)
def glog_library(with_gflags = 1, **kwargs):
if native.repository_name() != "@":
repo_name = native.repository_name()[1:] # Strip the first leading @
gendir = "$(GENDIR)/external/" + repo_name
src_windows = "external/%s/src/windows" % repo_name
else:
gendir = "$(GENDIR)"
src_windows = "src/windows"
# Config setting for WebAssembly target.
native.config_setting(
name = "wasm",
values = {"cpu": "wasm"},
)
# Detect when building with clang-cl on Windows.
native.config_setting(
name = "clang-cl",
values = {"compiler": "clang-cl"},
)
common_copts = [
"-std=c++14",
"-I%s/glog_internal" % gendir,
] + (["-DGLOG_USE_GFLAGS"] if with_gflags else [])
wasm_copts = [
# Disable warnings that exists in glog.
"-Wno-sign-compare",
"-Wno-unused-function",
"-Wno-unused-local-typedefs",
"-Wno-unused-variable",
# Allows src/logging.cc to determine the host name.
"-DHAVE_SYS_UTSNAME_H",
# For src/utilities.cc.
"-DHAVE_SYS_TIME_H",
# NOTE: users could optionally patch -DHAVE_UNWIND off if
# stacktrace dumping is not needed
"-DHAVE_UNWIND",
# Enable dumping stacktrace upon sigaction.
"-DHAVE_SIGACTION",
# For logging.cc.
"-DHAVE_PREAD",
# -DHAVE_MODE_T prevent repeated typedef mode_t leading
# to emcc compilation failure
"-DHAVE_MODE_T",
"-DHAVE_UNISTD_H",
]
linux_or_darwin_copts = wasm_copts + [
"-DGLOG_EXPORT=__attribute__((visibility(\\\"default\\\")))",
"-DGLOG_NO_EXPORT=__attribute__((visibility(\\\"default\\\")))",
"-DHAVE_POSIX_FADVISE",
"-DHAVE_SSIZE_T",
"-DHAVE_SYS_TYPES_H",
# For src/utilities.cc.
"-DHAVE_SYS_SYSCALL_H",
# For src/logging.cc to create symlinks.
"-fvisibility-inlines-hidden",
"-fvisibility=hidden",
]
freebsd_only_copts = [
# Enable declaration of _Unwind_Backtrace
"-D_GNU_SOURCE",
"-DHAVE_LINK_H",
"-DHAVE_SYMBOLIZE", # Supported by <link.h>
]
linux_only_copts = [
# For utilities.h.
"-DHAVE_EXECINFO_H",
"-DHAVE_LINK_H",
"-DHAVE_SYMBOLIZE", # Supported by <link.h>
]
darwin_only_copts = [
# For stacktrace.
"-DHAVE_DLADDR",
]
windows_only_copts = [
# Override -DGLOG_EXPORT= from the cc_library's defines.
"-DGLOG_EXPORT=__declspec(dllexport)",
"-DGLOG_NO_ABBREVIATED_SEVERITIES",
"-DGLOG_NO_EXPORT=",
"-DGLOG_USE_WINDOWS_PORT",
"-DHAVE__CHSIZE_S",
"-DHAVE_DBGHELP",
"-I" + src_windows,
]
clang_cl_only_copts = [
# Allow the override of -DGLOG_EXPORT.
"-Wno-macro-redefined",
]
windows_only_srcs = [
"src/windows/dirent.h",
"src/windows/port.cc",
"src/windows/port.h",
]
gflags_deps = ["@gflags//:gflags"] if with_gflags else []
final_lib_defines = select({
# GLOG_EXPORT is normally set by export.h, but that's not
# generated for Bazel.
"@bazel_tools//src/conditions:windows": [
"GLOG_DEPRECATED=__declspec(deprecated)",
"GLOG_EXPORT=",
"GLOG_NO_ABBREVIATED_SEVERITIES",
"GLOG_NO_EXPORT=",
],
"//conditions:default": [
"GLOG_DEPRECATED=__attribute__((deprecated))",
"GLOG_EXPORT=__attribute__((visibility(\\\"default\\\")))",
"GLOG_NO_EXPORT=__attribute__((visibility(\\\"default\\\")))",
],
})
final_lib_copts = select({
"@bazel_tools//src/conditions:windows": common_copts + windows_only_copts,
"@bazel_tools//src/conditions:darwin": common_copts + linux_or_darwin_copts + darwin_only_copts,
"@bazel_tools//src/conditions:freebsd": common_copts + linux_or_darwin_copts + freebsd_only_copts,
":wasm": common_copts + wasm_copts,
"//conditions:default": common_copts + linux_or_darwin_copts + linux_only_copts,
}) + select({
":clang-cl": clang_cl_only_copts,
"//conditions:default": [],
})
# Needed to use these headers in `glog` and the test targets without exposing them as public targets in `glog`
native.filegroup(
name = "shared_headers",
srcs = [
"src/base/commandlineflags.h",
"src/stacktrace.h",
"src/utilities.h",
]
)
native.cc_library(
name = "glog",
visibility = ["//visibility:public"],
srcs = [
":config_h",
":shared_headers",
"src/base/googleinit.h",
"src/demangle.cc",
"src/demangle.h",
"src/flags.cc",
"src/logging.cc",
"src/raw_logging.cc",
"src/signalhandler.cc",
"src/stacktrace.cc",
"src/stacktrace.h",
"src/stacktrace_generic-inl.h",
"src/stacktrace_libunwind-inl.h",
"src/stacktrace_powerpc-inl.h",
"src/stacktrace_unwind-inl.h",
"src/stacktrace_windows-inl.h",
"src/stacktrace_x86-inl.h",
"src/symbolize.cc",
"src/symbolize.h",
"src/utilities.cc",
"src/utilities.h",
"src/vlog_is_on.cc",
] + select({
"@bazel_tools//src/conditions:windows": windows_only_srcs,
"//conditions:default": [],
}),
hdrs = [
"src/glog/flags.h",
"src/glog/log_severity.h",
"src/glog/logging.h",
"src/glog/platform.h",
"src/glog/raw_logging.h",
"src/glog/stl_logging.h",
"src/glog/types.h",
"src/glog/vlog_is_on.h",
],
# https://github.com/google/glog/issues/837: Replacing
# `strip_include_prefix` with `includes` would avoid spamming
# downstream projects with compiler warnings, but would also leak
# private headers like stacktrace.h, because strip_include_prefix's
# implementation only creates symlinks for the public hdrs. I suspect
# the only way to avoid this is to refactor the project including the
# CMake build, so that the private headers are in a glog_internal
# subdirectory.
strip_include_prefix = "src",
defines = final_lib_defines,
copts = final_lib_copts,
deps = gflags_deps + select({
"@bazel_tools//src/conditions:windows": [":strip_include_prefix_hack"],
"//conditions:default": [],
}),
linkopts = select({
"@bazel_tools//src/conditions:windows": ["dbghelp.lib"],
"//conditions:default": [],
}),
**kwargs
)
test_list = [
"cleanup_immediately",
"cleanup_with_absolute_prefix",
"cleanup_with_relative_prefix",
# "demangle", # Broken
# "logging", # Broken
# "mock-log", # Broken
# "signalhandler", # Pointless
"stacktrace",
"stl_logging",
# "symbolize", # Broken
"utilities",
]
test_only_copts = [
"-DTEST_SRC_DIR=\\\"%s/tests\\\"" % gendir,
]
for test_name in test_list:
native.cc_test(
name = test_name + "_test",
visibility = ["//visibility:public"],
srcs = [
":config_h",
":shared_headers",
"src/googletest.h",
"src/" + test_name + "_unittest.cc",
],
defines = final_lib_defines,
copts = final_lib_copts + test_only_copts,
deps = gflags_deps + [
":glog",
"@googletest//:gtest",
],
**kwargs
)
# Workaround https://github.com/bazelbuild/bazel/issues/6337 by declaring
# the dependencies without strip_include_prefix.
native.cc_library(
name = "strip_include_prefix_hack",
hdrs = [
"src/glog/flags.h",
"src/glog/log_severity.h",
"src/glog/logging.h",
"src/glog/platform.h",
"src/glog/raw_logging.h",
"src/glog/stl_logging.h",
"src/glog/types.h",
"src/glog/vlog_is_on.h",
],
)
expand_template(
name = "config_h",
template = "src/config.h.cmake.in",
out = "glog_internal/config.h",
substitutions = {"#cmakedefine": "//cmakedefine"},
)

View File

@ -0,0 +1,69 @@
macro(determine_gflags_namespace VARIABLE)
if (NOT DEFINED "${VARIABLE}")
if (CMAKE_REQUIRED_INCLUDES)
set (CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}")
else ()
set (CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS)
endif ()
set(MACRO_CHECK_INCLUDE_FILE_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(_NAMESPACES gflags google)
set(_check_code
"
#include <gflags/gflags.h>
int main(int argc, char**argv)
{
GLOG_GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
}
")
if (NOT CMAKE_REQUIRED_QUIET)
message (STATUS "Looking for gflags namespace")
endif ()
if (${ARGC} EQUAL 3)
set (CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS})
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARGV2}")
endif ()
set (_check_file
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/DetermineGflagsNamespace.cxx)
foreach (_namespace ${_NAMESPACES})
file (WRITE "${_check_file}" "${_check_code}")
try_compile (${VARIABLE}
"${CMAKE_BINARY_DIR}" "${_check_file}"
COMPILE_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}" -DGLOG_GFLAGS_NAMESPACE=${_namespace}
LINK_LIBRARIES gflags
CMAKE_FLAGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
OUTPUT_VARIABLE OUTPUT)
if (${VARIABLE})
set (${VARIABLE} ${_namespace} CACHE INTERNAL "gflags namespace" FORCE)
break ()
else ()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining the gflags namespace ${_namespace} failed with the following output:\n"
"${OUTPUT}\n\n")
endif ()
endforeach (_namespace)
if (${ARGC} EQUAL 3)
set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_SAVE})
endif ()
if (${VARIABLE})
if (NOT CMAKE_REQUIRED_QUIET)
message (STATUS "Looking for gflags namespace - ${${VARIABLE}}")
endif ()
file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining the gflags namespace passed with the following output:\n"
"${OUTPUT}\n\n")
else ()
if (NOT CMAKE_REQUIRED_QUIET)
message (STATUS "Looking for gflags namespace - failed")
endif ()
set (${VARIABLE} ${_namespace} CACHE INTERNAL "gflags namespace")
endif ()
endif ()
endmacro ()

61
cmake/FindUnwind.cmake Normal file
View File

@ -0,0 +1,61 @@
# - Try to find libunwind
# Once done this will define
#
# Unwind_FOUND - system has libunwind
# unwind::unwind - cmake target for libunwind
include (FindPackageHandleStandardArgs)
find_path (Unwind_INCLUDE_DIR NAMES unwind.h libunwind.h DOC "unwind include directory")
find_library (Unwind_LIBRARY NAMES unwind DOC "unwind library")
mark_as_advanced (Unwind_INCLUDE_DIR Unwind_LIBRARY)
# Extract version information
if (Unwind_LIBRARY)
set (_Unwind_VERSION_HEADER ${Unwind_INCLUDE_DIR}/libunwind-common.h)
if (EXISTS ${_Unwind_VERSION_HEADER})
file (READ ${_Unwind_VERSION_HEADER} _Unwind_VERSION_CONTENTS)
string (REGEX REPLACE ".*#define UNW_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1"
Unwind_VERSION_MAJOR "${_Unwind_VERSION_CONTENTS}")
string (REGEX REPLACE ".*#define UNW_VERSION_MINOR[ \t]+([0-9]+).*" "\\1"
Unwind_VERSION_MINOR "${_Unwind_VERSION_CONTENTS}")
string (REGEX REPLACE ".*#define UNW_VERSION_EXTRA[ \t]+([0-9]+).*" "\\1"
Unwind_VERSION_PATCH "${_Unwind_VERSION_CONTENTS}")
set (Unwind_VERSION ${Unwind_VERSION_MAJOR}.${Unwind_VERSION_MINOR})
if (CMAKE_MATCH_0)
# Third version component may be empty
set (Unwind_VERSION ${Unwind_VERSION}.${Unwind_VERSION_PATCH})
set (Unwind_VERSION_COMPONENTS 3)
else (CMAKE_MATCH_0)
set (Unwind_VERSION_COMPONENTS 2)
endif (CMAKE_MATCH_0)
endif (EXISTS ${_Unwind_VERSION_HEADER})
endif (Unwind_LIBRARY)
# handle the QUIETLY and REQUIRED arguments and set Unwind_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args (Unwind
REQUIRED_VARS Unwind_INCLUDE_DIR Unwind_LIBRARY
VERSION_VAR Unwind_VERSION
)
if (Unwind_FOUND)
if (NOT TARGET unwind::unwind)
add_library (unwind::unwind INTERFACE IMPORTED)
set_property (TARGET unwind::unwind PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${Unwind_INCLUDE_DIR}
)
set_property (TARGET unwind::unwind PROPERTY
INTERFACE_LINK_LIBRARIES ${Unwind_LIBRARY}
)
set_property (TARGET unwind::unwind PROPERTY
IMPORTED_CONFIGURATIONS RELEASE
)
endif (NOT TARGET unwind::unwind)
endif (Unwind_FOUND)

View File

@ -0,0 +1,70 @@
cmake_policy (PUSH)
cmake_policy (VERSION 3.16...3.27)
include (CMakeParseArguments)
function (get_cache_variables _CACHEVARS)
set (_SINGLE)
set (_MULTI EXCLUDE)
set (_OPTIONS)
cmake_parse_arguments (_ARGS "${_OPTIONS}" "${_SINGLE}" "${_MULTI}" ${ARGS} ${ARGN})
get_cmake_property (_VARIABLES VARIABLES)
set (CACHEVARS)
foreach (_VAR ${_VARIABLES})
if (DEFINED _ARGS_EXCLUDE)
if ("${_VAR}" IN_LIST _ARGS_EXCLUDE)
continue ()
endif ("${_VAR}" IN_LIST _ARGS_EXCLUDE)
endif (DEFINED _ARGS_EXCLUDE)
get_property (_CACHEVARTYPE CACHE ${_VAR} PROPERTY TYPE)
if ("${_CACHEVARTYPE}" STREQUAL INTERNAL OR
"${_CACHEVARTYPE}" STREQUAL STATIC OR
"${_CACHEVARTYPE}" STREQUAL UNINITIALIZED)
continue ()
endif ("${_CACHEVARTYPE}" STREQUAL INTERNAL OR
"${_CACHEVARTYPE}" STREQUAL STATIC OR
"${_CACHEVARTYPE}" STREQUAL UNINITIALIZED)
get_property (_CACHEVARVAL CACHE ${_VAR} PROPERTY VALUE)
if ("${_CACHEVARVAL}" STREQUAL "")
continue ()
endif ("${_CACHEVARVAL}" STREQUAL "")
get_property (_CACHEVARDOC CACHE ${_VAR} PROPERTY HELPSTRING)
# Escape " in values
string (REPLACE "\"" "\\\"" _CACHEVARVAL "${_CACHEVARVAL}")
# Escape " in help strings
string (REPLACE "\"" "\\\"" _CACHEVARDOC "${_CACHEVARDOC}")
# Escape ; in values
string (REPLACE ";" "\\\;" _CACHEVARVAL "${_CACHEVARVAL}")
# Escape ; in help strings
string (REPLACE ";" "\\\;" _CACHEVARDOC "${_CACHEVARDOC}")
# Escape backslashes in values except those that are followed by a
# quote.
string (REGEX REPLACE "\\\\([^\"])" "\\\\\\1" _CACHEVARVAL "${_CACHEVARVAL}")
# Escape backslashes in values that are followed by a letter to avoid
# invalid escape sequence errors.
string (REGEX REPLACE "\\\\([a-zA-Z])" "\\\\\\\\1" _CACHEVARVAL "${_CACHEVARVAL}")
string (REPLACE "\\\\" "\\\\\\\\" _CACHEVARDOC "${_CACHEVARDOC}")
if (NOT "${_CACHEVARTYPE}" STREQUAL BOOL)
set (_CACHEVARVAL "\"${_CACHEVARVAL}\"")
endif (NOT "${_CACHEVARTYPE}" STREQUAL BOOL)
if (NOT "${_CACHEVARTYPE}" STREQUAL "" AND NOT "${_CACHEVARVAL}" STREQUAL "")
set (CACHEVARS "${CACHEVARS}set (${_VAR} ${_CACHEVARVAL} CACHE ${_CACHEVARTYPE} \"${_CACHEVARDOC}\")\n")
endif (NOT "${_CACHEVARTYPE}" STREQUAL "" AND NOT "${_CACHEVARVAL}" STREQUAL "")
endforeach (_VAR)
set (${_CACHEVARS} ${CACHEVARS} PARENT_SCOPE)
endfunction (get_cache_variables)
cmake_policy (POP)

View File

@ -0,0 +1,26 @@
set (RUNS 3)
foreach (iter RANGE 1 ${RUNS})
set (ENV{GOOGLE_LOG_DIR} ${TEST_DIR})
execute_process (COMMAND ${LOGCLEANUP} RESULT_VARIABLE _RESULT)
if (NOT _RESULT EQUAL 0)
message (FATAL_ERROR "Failed to run logcleanup_unittest (error: ${_RESULT})")
endif (NOT _RESULT EQUAL 0)
endforeach (iter)
file (GLOB LOG_FILES ${TEST_DIR}/*.foobar)
list (LENGTH LOG_FILES NUM_FILES)
if (WIN32)
# On Windows open files cannot be removed and will result in a permission
# denied error while unlinking such file. Therefore, the last file will be
# retained.
set (_expected 1)
else (WIN32)
set (_expected 0)
endif (WIN32)
if (NOT NUM_FILES EQUAL _expected)
message (SEND_ERROR "Expected ${_expected} log file in log directory but found ${NUM_FILES}")
endif (NOT NUM_FILES EQUAL _expected)

View File

@ -0,0 +1,26 @@
set (RUNS 3)
foreach (iter RANGE 1 ${RUNS})
execute_process (COMMAND ${LOGCLEANUP} -log_dir=${TEST_DIR}
RESULT_VARIABLE _RESULT)
if (NOT _RESULT EQUAL 0)
message (FATAL_ERROR "Failed to run logcleanup_unittest (error: ${_RESULT})")
endif (NOT _RESULT EQUAL 0)
endforeach (iter)
file (GLOB LOG_FILES ${TEST_DIR}/test_cleanup_*.barfoo)
list (LENGTH LOG_FILES NUM_FILES)
if (WIN32)
# On Windows open files cannot be removed and will result in a permission
# denied error while unlinking such file. Therefore, the last file will be
# retained.
set (_expected 1)
else (WIN32)
set (_expected 0)
endif (WIN32)
if (NOT NUM_FILES EQUAL _expected)
message (SEND_ERROR "Expected ${_expected} log file in log directory but found ${NUM_FILES}")
endif (NOT NUM_FILES EQUAL _expected)

View File

@ -0,0 +1,32 @@
set (RUNS 3)
# Create the subdirectory required by this unit test.
file (MAKE_DIRECTORY ${TEST_DIR}/${TEST_SUBDIR})
foreach (iter RANGE 1 ${RUNS})
execute_process (COMMAND ${LOGCLEANUP} -log_dir=${TEST_DIR}
RESULT_VARIABLE _RESULT)
if (NOT _RESULT EQUAL 0)
message (FATAL_ERROR "Failed to run logcleanup_unittest (error: ${_RESULT})")
endif (NOT _RESULT EQUAL 0)
endforeach (iter)
file (GLOB LOG_FILES ${TEST_DIR}/${TEST_SUBDIR}/test_cleanup_*.relativefoo)
list (LENGTH LOG_FILES NUM_FILES)
if (WIN32)
# On Windows open files cannot be removed and will result in a permission
# denied error while unlinking such file. Therefore, the last file will be
# retained.
set (_expected 1)
else (WIN32)
set (_expected 0)
endif (WIN32)
if (NOT NUM_FILES EQUAL _expected)
message (SEND_ERROR "Expected ${_expected} log file in build directory ${TEST_DIR}${TEST_SUBDIR} but found ${NUM_FILES}")
endif (NOT NUM_FILES EQUAL _expected)
# Remove the subdirectory required by this unit test.
file (REMOVE_RECURSE ${TEST_DIR}/${TEST_SUBDIR})

View File

@ -0,0 +1,11 @@
# Create the build directory
execute_process (
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_BINARY_DIR}
RESULT_VARIABLE _DIRECTORY_CREATED_SUCCEEDED
)
if (NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0)
message (FATAL_ERROR "Failed to create build directory")
endif (NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0)
file (WRITE ${INITIAL_CACHE} "${CACHEVARS}")

View File

@ -0,0 +1,30 @@
if (GENERATOR_TOOLSET)
list (APPEND _ADDITIONAL_ARGS -T ${GENERATOR_TOOLSET})
endif (GENERATOR_TOOLSET)
if (GENERATOR_PLATFORM)
list (APPEND _ADDITIONAL_ARGS -A ${GENERATOR_PLATFORM})
endif (GENERATOR_PLATFORM)
# Run CMake
execute_process (
# Capture the PATH environment variable content set during project generation
# stage. This is required because later during the build stage the PATH is
# modified again (e.g., for MinGW AppVeyor CI builds) by adding back the
# directory containing git.exe. Incidentally, the Git installation directory
# also contains sh.exe which causes MinGW Makefile generation to fail.
COMMAND ${CMAKE_COMMAND} -E env PATH=${PATH}
${CMAKE_COMMAND} -C ${INITIAL_CACHE}
-G ${GENERATOR}
${_ADDITIONAL_ARGS}
-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON
-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON
-Dglog_ROOT=${PACKAGE_DIR}
-S ${SOURCE_DIR}
-B ${TEST_BINARY_DIR}
RESULT_VARIABLE _GENERATE_SUCCEEDED
)
if (NOT _GENERATE_SUCCEEDED EQUAL 0)
message (FATAL_ERROR "Failed to generate project files using CMake")
endif (NOT _GENERATE_SUCCEEDED EQUAL 0)

11
codecov.yml Normal file
View File

@ -0,0 +1,11 @@
comment:
layout: "diff, flags, files"
behavior: default
require_changes: false
require_base: false
require_head: true
ignore:
- "**/*_unittest.cc"
- "src/*_unittest/**"
- "src/googletest.h"
- "src/mock-log.h"

99
compile
View File

@ -1,99 +0,0 @@
#! /bin/sh
# Wrapper for compilers which do not understand `-c -o'.
# Copyright 1999, 2000 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Usage:
# compile PROGRAM [ARGS]...
# `-o FOO.o' is removed from the args passed to the actual compile.
prog=$1
shift
ofile=
cfile=
args=
while test $# -gt 0; do
case "$1" in
-o)
# configure might choose to run compile as `compile cc -o foo foo.c'.
# So we do something ugly here.
ofile=$2
shift
case "$ofile" in
*.o | *.obj)
;;
*)
args="$args -o $ofile"
ofile=
;;
esac
;;
*.c)
cfile=$1
args="$args $1"
;;
*)
args="$args $1"
;;
esac
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no `-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# `.c' file was seen then we are probably linking. That is also
# ok.
exec "$prog" $args
fi
# Name of file we expect compiler to create.
cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
# Create the lock directory.
# Note: use `[/.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo $cofile | sed -e 's|[/.-]|_|g'`.d
while true; do
if mkdir $lockdir > /dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir $lockdir; exit 1" 1 2 15
# Run the compile.
"$prog" $args
status=$?
if test -f "$cofile"; then
mv "$cofile" "$ofile"
fi
rmdir $lockdir
exit $status

1466
config.guess vendored

File diff suppressed because it is too large Load Diff

1579
config.sub vendored

File diff suppressed because it is too large Load Diff

23182
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,120 +0,0 @@
## Process this file with autoconf to produce configure.
## In general, the safest way to proceed is to run the following:
## % aclocal -I . -I `pwd`/../autoconf && autoheader && autoconf && automake
# make sure we're interpreted by some minimal autoconf
AC_PREREQ(2.57)
AC_INIT(glog, 0.1, opensource@google.com)
# The argument here is just something that should be in the current directory
# (for sanity checking)
AC_CONFIG_SRCDIR(README)
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(src/config.h)
# Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX
AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
AC_PROG_LIBTOOL
AC_SUBST(LIBTOOL_DEPS)
# Check whether some low-level functions/files are available
AC_HEADER_STDC
# These are tested for by AC_HEADER_STDC, but I check again to set the var
AC_CHECK_HEADER(stdint.h, ac_cv_have_stdint_h=1, ac_cv_have_stdint_h=0)
AC_CHECK_HEADER(sys/types.h, ac_cv_have_systypes_h=1, ac_cv_have_systypes_h=0)
AC_CHECK_HEADER(inttypes.h, ac_cv_have_inttypes_h=1, ac_cv_have_inttypes_h=0)
AC_CHECK_HEADERS(syscall.h)
AC_CHECK_HEADERS(sys/syscall.h)
# For backtrace with glibc.
# TODO(hamaji): Support other platforms using libgcc.
AC_CHECK_HEADERS(execinfo.h)
AC_CHECK_SIZEOF(void *)
# These are the types I need. We look for them in either stdint.h,
# sys/types.h, or inttypes.h, all of which are part of the default-includes.
AC_CHECK_TYPE(uint16_t, ac_cv_have_uint16_t=1, ac_cv_have_uint16_t=0)
AC_CHECK_TYPE(u_int16_t, ac_cv_have_u_int16_t=1, ac_cv_have_u_int16_t=0)
AC_CHECK_TYPE(__uint16, ac_cv_have___uint16=1, ac_cv_have___uint16=0)
AC_CHECK_FUNC(sigaltstack,
AC_DEFINE(HAVE_SIGALTSTACK, 1,
[Define if you have the `sigaltstack' function]))
AX_C___ATTRIBUTE__
# We only care about these two attributes.
if test x"$ac_cv___attribute__" = x"yes"; then
ac_cv___attribute___noreturn="__attribute__ ((noreturn))"
ac_cv___attribute___printf_4_5="__attribute__((__format__ (__printf__, 4, 5)))"
else
ac_cv___attribute___noreturn=
ac_cv___attribute___printf_4_5=
fi
AX_C___BUILTIN_EXPECT
if test x"$ac_cv___builtin_expect" = x"yes"; then
ac_cv_have___builtin_expect=1
else
ac_cv_have___builtin_expect=0
fi
# On x86_64, instead of libunwind, we can choose to compile with frame-pointers
# (This isn't needed on i386, where -fno-omit-frame-pointer is the default).
AC_ARG_ENABLE(frame_pointers,
AS_HELP_STRING([--enable-frame-pointers],
[On x86_64 systems, compile with -fno-omit-frame-pointer (see INSTALL)]),
enable_frame_pointers=no)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __x86_64__ == 1 ? 0 : 1])],
[is_x86_64=yes], [is_x86_64=no])
AM_CONDITIONAL(ENABLE_FRAME_POINTERS, test "$enable_frame_pointers" = yes)
AM_CONDITIONAL(X86_64, test "$is_x86_64" = yes)
# Some of the code in this directory depends on pthreads
ACX_PTHREAD
# Check if there is google-gflags library installed.
AC_CHECK_LIB(gflags, main, ac_cv_have_libgflags=1, ac_cv_have_libgflags=0)
if test x"$ac_cv_have_libgflags" = x"1"; then
GFLAGS_LIBS=-lgflags
AC_DEFINE(HAVE_LIB_GFLAGS, 1, [define if you have google gflags library])
else
GFLAGS_LIBS=
fi
# We'd like to use read/write locks in several places in the code.
# See if our pthreads support extends to that. Note: for linux, it
# does as long as you define _XOPEN_SOURCE appropriately.
AC_RWLOCK
# Find out what namespace 'normal' STL code lives in, and also what namespace
# the user wants our classes to be defined in
AC_CXX_STL_NAMESPACE
AC_DEFINE_GOOGLE_NAMESPACE(google)
AC_CXX_USING_OPERATOR
# These are what's needed by logging.h.in and raw_logging.h.in
AC_SUBST(ac_google_start_namespace)
AC_SUBST(ac_google_end_namespace)
AC_SUBST(ac_google_namespace)
AC_SUBST(ac_cv_cxx_using_operator)
AC_SUBST(ac_cv___attribute___noreturn)
AC_SUBST(ac_cv___attribute___printf_4_5)
AC_SUBST(ac_cv_have___builtin_expect)
AC_SUBST(ac_cv_have_stdint_h)
AC_SUBST(ac_cv_have_systypes_h)
AC_SUBST(ac_cv_have_inttypes_h)
AC_SUBST(ac_cv_have_uint16_t)
AC_SUBST(ac_cv_have_u_int16_t)
AC_SUBST(ac_cv_have___uint16)
AC_SUBST(ac_cv_have_libgflags)
AC_SUBST(GFLAGS_LIBS)
# Write generated configuration file
AC_CONFIG_FILES([Makefile src/glog/logging.h src/glog/raw_logging.h src/glog/vlog_is_on.h src/glog/stl_logging.h])
AC_OUTPUT

530
depcomp
View File

@ -1,530 +0,0 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2005-07-09.11
# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by `PROGRAMS ARGS'.
object Object file output by `PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputing dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say).
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the `deleted header file' problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' '
' < "$tmpdepfile" |
## Some versions of gcc put a space before the `:'. On the theory
## that the space means something, we add a space to the output as
## well.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like `#:fec' to the end of the
# dependency line.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr '
' ' ' >> $depfile
echo >> $depfile
# The second pass generates a dummy entry for each header file.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> $depfile
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts `$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
tmpdepfile="$stripped.u"
if test "$libtool" = yes; then
"$@" -Wc,-M
else
"$@" -M
fi
stat=$?
if test -f "$tmpdepfile"; then :
else
stripped=`echo "$stripped" | sed 's,^.*/,,'`
tmpdepfile="$stripped.u"
fi
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
if test -f "$tmpdepfile"; then
outname="$stripped.o"
# Each line is of the form `foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
icc)
# Intel's C compiler understands `-MD -MF file'. However on
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want:
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using \ :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
# With Tru64 cc, shared objects can also be used to make a
# static library. This mecanism is used in libtool 1.4 series to
# handle both shared and static libraries in a single compilation.
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
#
# With libtool 1.5 this exception was removed, and libtool now
# generates 2 separate objects for the 2 libraries. These two
# compilations output dependencies in in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
tmpdepfile2=$dir$base.o.d # libtool 1.5
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.o.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
tmpdepfile4=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for `:'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
"$@" $dashmflag |
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no
for arg in "$@"; do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix="`echo $object | sed 's/^.*\././'`"
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E |
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
"$@" || exit $?
IFS=" "
for arg
do
case "$arg" in
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
echo " " >> "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

View File

@ -1,115 +0,0 @@
body {
background-color: #ffffff;
color: black;
margin-right: 1in;
margin-left: 1in;
}
h1, h2, h3, h4, h5, h6 {
color: #3366ff;
font-family: sans-serif;
}
@media print {
/* Darker version for printing */
h1, h2, h3, h4, h5, h6 {
color: #000080;
font-family: helvetica, sans-serif;
}
}
h1 {
text-align: center;
font-size: 18pt;
}
h2 {
margin-left: -0.5in;
}
h3 {
margin-left: -0.25in;
}
h4 {
margin-left: -0.125in;
}
hr {
margin-left: -1in;
}
/* Definition lists: definition term bold */
dt {
font-weight: bold;
}
address {
text-align: right;
}
/* Use the <code> tag for bits of code and <var> for variables and objects. */
code,pre,samp,var {
color: #006000;
}
/* Use the <file> tag for file and directory paths and names. */
file {
color: #905050;
font-family: monospace;
}
/* Use the <kbd> tag for stuff the user should type. */
kbd {
color: #600000;
}
div.note p {
float: right;
width: 3in;
margin-right: 0%;
padding: 1px;
border: 2px solid #6060a0;
background-color: #fffff0;
}
UL.nobullets {
list-style-type: none;
list-style-image: none;
margin-left: -1em;
}
/*
body:after {
content: "Google Confidential";
}
*/
/* pretty printing styles. See prettify.js */
.str { color: #080; }
.kwd { color: #008; }
.com { color: #800; }
.typ { color: #606; }
.lit { color: #066; }
.pun { color: #660; }
.pln { color: #000; }
.tag { color: #008; }
.atn { color: #606; }
.atv { color: #080; }
pre.prettyprint { padding: 2px; border: 1px solid #888; }
.embsrc { background: #eee; }
@media print {
.str { color: #060; }
.kwd { color: #006; font-weight: bold; }
.com { color: #600; font-style: italic; }
.typ { color: #404; font-weight: bold; }
.lit { color: #044; }
.pun { color: #440; }
.pln { color: #000; }
.tag { color: #006; font-weight: bold; }
.atn { color: #404; }
.atv { color: #060; }
}
/* Table Column Headers */
.hdr {
color: #006;
font-weight: bold;
background-color: #dddddd; }
.hdr2 {
color: #006;
background-color: #eeeeee; }

View File

@ -1,506 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>How To Use Google Logging Library (glog)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="http://www.google.com/favicon.ico" type="image/x-icon"
rel="shortcut icon">
<link href="designstyle.css" type="text/css" rel="stylesheet">
<style type="text/css">
<!--
ol.bluelist li {
color: #3366ff;
font-family: sans-serif;
}
ol.bluelist li p {
color: #000;
font-family: "Times Roman", times, serif;
}
ul.blacklist li {
color: #000;
font-family: "Times Roman", times, serif;
}
//-->
</style>
</head>
<body>
<h1>How To Use Google Logging Library (glog)</h1>
<small>(as of
<script type=text/javascript>
var lm = new Date(document.lastModified);
document.write(lm.toDateString());
</script>)
</small>
<br>
<h2> <A NAME=intro>Introduction</A> </h2>
<p><b>Google glog</b> is a library that implements application-level
logging. This library provides logging APIs based on C++-style
streams and various helper macros.
You can log a message by simply streaming things to LOG(&lt;a
particular <a href="#severity">severity level</a>&gt;), e.g.
<pre>
#include &lt;google/logging.h&gt;
int main(int argc, char* argv[]) {
// Initialize Google's logging library.
google::InitGoogleLogging(argv[0]);
// ...
LOG(INFO) &lt;&lt; "Found " &lt;&lt; num_cookies &lt;&lt; " cookies";
}
</pre>
<p>Google glog defines a series of macros that simplify many common logging
tasks. You can log messages by severity level, control logging
behavior from the command line, log based on conditionals, abort the
program when expected conditions are not met, introduce your own
verbose logging levels, and more. This document describes the
functionality supported by glog. Please note that this document
doesn't describe all features in this library, but the most useful
ones. If you want to find less common features, please check
header files under <code>src/google</code> directory.
<h2> <A NAME=severity>Severity Level</A> </h2>
<p>
You can specify one of the following severity levels (in
increasing order of severity): <code>INFO</code>, <code>WARNING</code>,
<code>ERROR</code>, and <code>FATAL</code>.
Logging a <code>FATAL</code> message terminates the program (after the
message is logged).
Note that messages of a given severity are logged not only in the
logfile for that severity, but also in all logfiles of lower severity.
E.g., a message of severity <code>FATAL</code> will be logged to the
logfiles of severity <code>FATAL</code>, <code>ERROR</code>,
<code>WARNING</code>, and <code>INFO</code>.
<p>
The <code>DFATAL</code> severity logs a <code>FATAL</code> error in
debug mode (i.e., there is no <code>NDEBUG</code> macro defined), but
avoids halting the program in production by automatically reducing the
severity to <code>ERROR</code>.
<p>Unless otherwise specified, glog writes to the filename
"/tmp/&lt;program name&gt;.&lt;hostname&gt;.&lt;user name&gt;.log.&lt;severity level&gt;.&lt;date&gt;.&lt;time&gt;.&lt;pid&gt;"
(e.g., "/tmp/hello_world.example.com.hamaji.log.INFO.20080709-222411.10474").
By default, glog copies the log messages of severity level
<code>ERROR</code> or <code>FATAL</code> to standard error (stderr)
in addition to log files.
<h2><A NAME=flags>Setting Flags</A></h2>
<p>Several flags influences glog's output behavior.
If the <a href="http://code.google.com/p/google-gflags/">Google
gflags library</a> is installed on your machine, the
<code>configure</code> script (see the INSTALL file in the package for
detail of this script) will automatically detect and use it,
allowing you to pass flags on the command line. For example, if you
want to turn the flag <code>--logtostderr</code> on, you can start
your application with the following command line:
<pre>
./your_application --logtostderr=1
</pre>
If the Google gflags library isn't installed, you set flags via
environment variables, prefixing the flag name with "GLOG_", e.g.
<pre>
GLOG_logtostderr=1 ./your_application
</pre>
<p>The following flags are most commonly used:
<dl>
<dt><code>logtostderr</code> (<code>bool</code>, default=<code>false</code>)
<dd>Log messages to stderr instead of logfiles.<br>
Note: you can set binary flags to <code>true</code> by specifying
<code>1</code>, <code>true</code> , or <code>yes</code> (case
insensitive).
Also, you can set binary flags to <code>false</code> by specifying
<code>0</code>, <code>false</code>, or <code>no</code> (again, case
insensitive).
<dt><code>stderrthreshold</code> (<code>int</code>, default=2, which
is <code>ERROR</code>)
<dd>Copy log messages at or above this level to stderr in
addition to logfiles. The numbers of severity levels
<code>INFO</code>, <code>WARNING</code>, <code>ERROR</code>, and
<code>FATAL</code> are 0, 1, 2, and 3, respectively.
<dt><code>minloglevel</code> (<code>int</code>, default=0, which
is <code>INFO</code>)
<dd>Log messages at or above this level. Again, the numbers of
severity levels <code>INFO</code>, <code>WARNING</code>,
<code>ERROR</code>, and <code>FATAL</code> are 0, 1, 2, and 3,
respectively.
<dt><code>log_dir</code> (<code>string</code>, default="")
<dd>If specified, logfiles are written into this directory instead
of the default logging directory.
<dt><code>v</code> (<code>int</code>, default=0)
<dd>Show all <code>VLOG(m)</code> messages for <code>m</code> less or
equal the value of this flag. Overridable by --vmodule.
See <a href="#verbose">the section about verbose logging</a> for more
detail.
<dt><code>vmodule</code> (<code>string</code>, default="")
<dd>Per-module verbose level. The argument has to contain a
comma-separated list of &lt;module name&gt;=&lt;log level&gt;.
&lt;module name&gt;
is a glob pattern (e.g., <code>gfs*</code> for all modules whose name
starts with "gfs"), matched against the filename base
(that is, name ignoring .cc/.h./-inl.h).
&lt;log level&gt; overrides any value given by --v.
See also <a href="#verbose">the section about verbose logging</a>.
</dl>
<p>There are some other flags defined in logging.cc. Please grep the
source code for "DEFINE_" to see a complete list of all flags.
<h2><A NAME=conditional>Conditional / Occasional Logging</A></h2>
<p>Sometimes, you may only want to log a message under certain
conditions. You can use the following macros to perform conditional
logging:
<pre>
LOG_IF(INFO, num_cookies > 10) &lt;&lt; "Got lots of cookies";
</pre>
The "Got lots of cookies" message is logged only when the variable
<code>num_cookies</code> exceeds 10.
If a line of code is executed many times, it may be useful to only log
a message at certain intervals. This kind of logging is most useful
for informational messages.
<pre>
LOG_EVERY_N(INFO, 10) &lt;&lt; "Got the " &lt;&lt; COUNTER &lt;&lt; "th cookie";
</pre>
<p>The above line outputs a log messages on the 1st, 11th,
21st, ... times it is executed. Note that the special
<code>COUNTER</code> value is used to identify which repetition is
happening.
<p>You can combine conditional and occasional logging with the
following macro.
<pre>
LOG_IF_EVERY_N(INFO, (size > 1024), 10) &lt;&lt; "Got the " &lt;&lt; COUNTER
&lt;&lt; "th big cookie";
</pre>
<p>Instead of outputting a message every nth time, you can also limit
the output to the first n occurrences:
<pre>
LOG_FIRST_N(INFO, 20) &lt;&lt; "Got the " &lt;&lt; COUNTER &lt;&lt; "th cookie";
</pre>
<p>Outputs log messages for the first 20 times it is executed. Again,
the <code>COUNTER</code> identifier indicates which repetition is
happening.
<h2><A NAME=debug>Debug Mode Support</A></h2>
<p>Special "debug mode" logging macros only have an effect in debug
mode and are compiled away to nothing for non-debug mode
compiles. Use these macros to avoid slowing down your production
application due to excessive logging.
<pre>
DLOG(INFO) &lt;&lt; "Found cookies";
DLOG_IF(INFO, num_cookies > 10) &lt;&lt; "Got lots of cookies";
DLOG_EVERY_N(INFO, 10) &lt;&lt; "Got the " &lt;&lt; COUNTER &lt;&lt; "th cookie";
</pre>
<p>All "debug mode" logging is compiled away to nothing for non-debug mode
compiles.
<h2><A NAME=check>CHECK Macros</A></h2>
<p>It is a good practice to check expected conditions in your program
frequently to detect errors as early as possible. The
<code>CHECK</code> macro provides the ability to abort the application
when a condition is not met, similar to the <code>assert</code> macro
defined in the standard C library.
<p><code>CHECK</code> aborts the application if a condition is not
true. Unlike <code>assert</code>, it is *not* controlled by
<code>NDEBUG</code>, so the check will be executed regardless of
compilation mode. Therefore, <code>fp->Write(x)</code> in the
following example is always executed:
<pre>
CHECK(fp->Write(x) == 4) &lt;&lt; "Write failed!";
</pre>
<p>There are various helper macros for
equality/inequality checks - <code>CHECK_EQ</code>,
<code>CHECK_NE</code>, <code>CHECK_LE</code>, <code>CHECK_LT</code>,
<code>CHECK_GE</code>, and <code>CHECK_GT</code>.
They compare two values, and log a
<code>FATAL</code> message including the two values when the result is
not as expected. The values must have <code>operator&lt;&lt;(ostream,
...)</code> defined.
<p>You may append to the error message like so:
<pre>
CHECK_NE(1, 2) &lt;&lt; ": The world must be ending!";
</pre>
<p>We are very careful to ensure that each argument is evaluated exactly
once, and that anything which is legal to pass as a function argument is
legal here. In particular, the arguments may be temporary expressions
which will end up being destroyed at the end of the apparent statement,
for example:
<pre>
CHECK_EQ(string("abc")[1], 'b');
</pre>
<p>The compiler reports an error if one of the arguments is a
pointer and the other is NULL. To work around this, simply static_cast
NULL to the type of the desired pointer.
<pre>
CHECK_EQ(some_ptr, static_cast<SomeType*>(NULL));
</pre>
<p>Better yet, use the CHECK_NOTNULL macro:
<pre>
CHECK_NOTNULL(some_ptr);
some_ptr->DoSomething();
</pre>
<p>Since this macro returns the given pointer, this is very useful in
constructor initializer lists.
<pre>
struct S {
S(Something* ptr) : ptr_(CHECK_NOTNULL(ptr)) {}
Something* ptr_;
};
</pre>
<p>Note that you cannot use this macro as a C++ stream due to this
feature. Please use <code>CHECK_EQ</code> described above to log a
custom message before aborting the application.
<p>If you are comparing C strings (char *), a handy set of macros
performs case sensitive as well as case insensitive comparisons -
<code>CHECK_STREQ</code>, <code>CHECK_STRNE</code>,
<code>CHECK_STRCASEEQ</code>, and <code>CHECK_STRCASENE</code>. The
CASE versions are case-insensitive. You can safely pass <code>NULL</code>
pointers for this macro. They treat <code>NULL</code> and any
non-<code>NULL</code> string as not equal. Two <code>NULL</code>s are
equal.
<p>Note that both arguments may be temporary strings which are
destructed at the end of the current "full expression"
(e.g., <code>CHECK_STREQ(Foo().c_str(), Bar().c_str())</code> where
<code>Foo</code> and <code>Bar</code> returns C++'s
<code>std::string</code>).
<p>The <code>CHECK_DOUBLE_EQ</code> macro checks the equality of two
floating point values, accepting a small error margin.
<code>CHECK_NEAR</code> accepts a third floating point argument, which
specifies the acceptable error margin.
<h2><A NAME=verbose>Verbose Logging</A></h2>
<p>When you are chasing difficult bugs, thorough log messages are very
useful. However, you may want to ignore too verbose messages in usual
development. For such verbose logging, glog provides the
<code>VLOG</code> macro, which allows you to define your own numeric
logging levels. The <code>--v</code> command line option controls
which verbose messages are logged:
<pre>
VLOG(1) &lt;&lt; "I'm printed when you run the program with --v=1 or higher";
VLOG(2) &lt;&lt; "I'm printed when you run the program with --v=2 or higher";
</pre>
<p>With <code>VLOG</code>, the lower the verbose level, the more
likely messages are to be logged. For example, if
<code>--v==1</code>, <code>VLOG(1)</code> will log, but
<code>VLOG(2)</code> will not log. This is opposite of the severity
level, where <code>INFO</code> is 0, and <code>ERROR</code> is 2.
<code>--minloglevel</code> of 1 will log <code>WARNING</code> and
above. Though you can specify any integers for both <code>VLOG</code>
macro and <code>--v</code> flag, the common values for them are small
positive integers. For example, if you write <code>VLOG(0)</code>,
you should specify <code>--v=-1</code> or lower to silence it. This
is less useful since we may not want verbose logs by default in most
cases. The <code>VLOG</code> macros always log at the
<code>INFO</code> log level (when they log at all).
<p>Verbose logging can be controlled from the command line on a
per-module basis:
<pre>
--vmodule=mapreduce=2,file=1,gfs*=3 --v=0
</pre>
<p>will:
<ul>
<li>a. Print VLOG(2) and lower messages from mapreduce.{h,cc}
<li>b. Print VLOG(1) and lower messages from file.{h,cc}
<li>c. Print VLOG(3) and lower messages from files prefixed with "gfs"
<li>d. Print VLOG(0) and lower messages from elsewhere
</ul>
<p>The wildcarding functionality shown by (c) supports both '*'
(matches 0 or more characters) and '?' (matches any single character)
wildcards. Please also check the section about <a
href="#flags">command line flags</a>.
<p>There's also <code>VLOG_IS_ON(n)</code> "verbose level" condition
macro. This macro returns true when the <code>--v</code> is equal or
greater than <code>n</code>. To be used as
<pre>
if (VLOG_IS_ON(2)) {
// do some logging preparation and logging
// that can't be accomplished with just VLOG(2) &lt;&lt; ...;
}
</pre>
<p>Verbose level condition macros <code>VLOG_IF</code>,
<code>VLOG_EVERY_N</code> and <code>VLOG_IF_EVERY_N</code> behave
analogous to <code>LOG_IF</code>, <code>LOG_EVERY_N</code>,
<code>LOF_IF_EVERY</code>, but accept a numeric verbosity level as
opposed to a severity level.
<pre>
VLOG_IF(1, (size > 1024))
&lt;&lt; "I'm printed when size is more than 1024 and when you run the "
"program with --v=1 or more";
VLOG_EVERY_N(1, 10)
&lt;&lt; "I'm printed every 10th occurrence, and when you run the program "
"with --v=1 or more. Present occurence is " &lt;&lt; COUNTER;
VLOG_IF_EVERY_N(1, (size > 1024), 10)
&lt;&lt; "I'm printed on every 10th occurence of case when size is more "
" than 1024, when you run the program with --v=1 or more. ";
"Present occurence is " &lt;&lt; COUNTER;
</pre>
<h2> <A name="misc">Miscellaneous Notes</A> </h2>
<h3><A NAME=message>Performance of Messages</A></h3>
<p>The conditional logging macros provided by glog (e.g.,
<code>CHECK</code>, <code>LOG_IF</code>, <code>VLOG</code>, ...) are
carefully implemented and don't execute the right hand side
expressions when the conditions are false. So, the following check
may not sacrifice the performance of your application.
<pre>
CHECK(obj.ok) << obj.CreatePrettyFormattedStringButVerySlow();
</pre>
<h3><A NAME=failure>User-defined Failure Function</A></h3>
<p><code>FATAL</code> severity level messages or unsatisfied
<code>CHECK</code> condition terminate your program. You can change
the behavior of the termination by
<code>InstallFailureFunction</code>.
<pre>
void YourFailureFunction() {
// Reports something...
exit(1);
}
int main(int argc, char* argv[]) {
google::InstallFailureFunction(&amp;YourFailureFunction);
}
</pre>
<p>By default, glog tries to dump stacktrace and makes the program
exit with status 1. The stacktrace is produced only when you run the
program on an architecture for which glog supports stack tracing (as
of September 2008, glog supports stack tracing for x86 and x86_64).
<h3><A NAME=raw>Raw Logging</A></h3>
<p>The header file <code>&lt;google/raw_logging.h&gt;</code> can be
used for thread-safe logging, which does not allocate any memory or
acquire any locks. Therefore, the macros defined in this
header file can be used by low-level memory allocation and
synchronization code.
Please check <code>src/google/raw_logging.h.in</code> for detail.
</p>
<h3><A NAME=plog>Google Style perror()</A></h3>
<p><code>PLOG()</code> and <code>PLOG_IF()</code> and
<code>PCHECK()</code> behave exactly like their <code>LOG*</code> and
<code>CHECK</code> equivalents with the addition that they append a
description of the current state of errno to their output lines.
E.g.
<pre>
PCHECK(write(1, NULL, 2) >= 0) << "Write NULL failed";
</pre>
<p>This check fails with the following error message.
<pre>
F0825 185142 test.cc:22] Check failed: write(1, NULL, 2) >= 0 Write NULL failed: Bad address [14]
</pre>
<h3><A NAME=syslog>Syslog</A></h3>
<p><code>SYSLOG</code>, <code>SYSLOG_IF</code>, and
<code>SYSLOG_EVERY_N</code> macros are available.
These log to syslog in addition to the normal logs. Be aware that
logging to syslog can drastically impact performance, especially if
syslog is configured for remote logging! Make sure you understand the
implications of outputting to syslog before you use these macros. In
general, it's wise to use these macros sparingly.
<h3><A NAME=strip>Strip Logging Messages</A></h3>
<p>Strings used in log messages can increase the size of your binary
and present a privacy concern. You can therefore instruct glog to
remove all strings which fall below a certain severity level by using
the GOOGLE_STRIP_LOG macro:
<p>If your application has code like this:
<pre>
#define GOOGLE_STRIP_LOG 1 // this must go before the #include!
#include &lt;google/logging.h&gt;
</pre>
<p>The compiler will remove the log messages whose severity are less
than the specified integer value. Since
<code>VLOG</code> logs at the severity level <code>INFO</code>
(numeric value <code>0</code>),
setting <code>GOOGLE_STRIP_LOG</code> to 1 or greater removes
all log messages associated with <code>VLOG</code>s as well as
<code>INFO</code> log statements.
<hr>
<address>
Shinichiro Hamaji<br>
Gregor Hohpe<br>
<script type=text/javascript>
var lm = new Date(document.lastModified);
document.write(lm.toDateString());
</script>
</address>
</body>
</html>

66
docs/build.md Normal file
View File

@ -0,0 +1,66 @@
# Building from Source
## Bazel
To use glog within a project which uses the [Bazel](https://bazel.build/) build
tool, add the following lines to your `MODULE.bazel` file:
``` bazel title="MODULE.bazel"
bazel_dep(name = "glog")
archive_override(
module_name = "glog",
urls = "https://github.com/google/glog/archive/cc0de6c200375b33d907ee7632eee2f173b33a09.tar.gz",
strip_prefix = "glog-cc0de6c200375b33d907ee7632eee2f173b33a09", # Latest commit as of 2024-06-08.
integrity = "sha256-rUrv4EBkdc+4Wbhfxp+KoRstlj2Iw842/OpLfDq0ivg=",
)
```
You can then add `@glog//:glog` to
the deps section of a `cc_binary` or
`cc_library` rule, and `#!cpp #include <glog/logging.h>` to
include it in your source code.
!!! example "Using glog in a Bazel project"
``` bazel
cc_binary(
name = "main",
srcs = ["main.cc"],
deps = ["@glog//:glog"],
)
```
## CMake
glog can be compiled using [CMake](http://www.cmake.org) on a wide range of
platforms. The typical workflow for building glog on a Unix-like system with GNU
Make as build tool is as follows:
1. Clone the repository and change into source directory.
``` bash
git clone https://github.com/google/glog.git
cd glog
```
2. Run CMake to configure the build tree.
``` bash
cmake -S . -B build -G "Unix Makefiles"
```
CMake provides different generators, and by default will pick the most
relevant one to your environment. If you need a specific version of Visual
Studio, use `#!bash cmake . -G <generator-name>`, and see `#!bash cmake
--help` for the available generators. Also see `-T <toolset-name>`, which can
be used to request the native x64 toolchain with `-T host=x64`.
3. Afterwards, generated files can be used to compile the project.
``` bash
cmake --build build
```
4. Test the build software (optional).
``` bash
cmake --build build --target test
```
5. Install the built files (optional).
``` bash
cmake --build build --target install
```
Once successfully built, glog can be [integrated into own projects](usage.md).

50
docs/contribute.md Normal file
View File

@ -0,0 +1,50 @@
# How to Contribute
We'd love to accept your patches and contributions to this project.
There are a just a few small guidelines you need to follow.
## Contributor License Agreement (CLA)
Contributions to any Google project must be accompanied by a Contributor
License Agreement. This is not a copyright **assignment**, it simply
gives Google permission to use and redistribute your contributions as
part of the project.
- If you are an individual writing original source code and you're
sure you own the intellectual property, then you'll need to sign an
[individual
CLA](https://developers.google.com/open-source/cla/individual).
- If you work for a company that wants to allow you to contribute your
work, then you'll need to sign a [corporate
CLA](https://developers.google.com/open-source/cla/corporate).
You generally only need to submit a CLA once, so if you've already
submitted one (even if it was for a different project), you probably
don't need to do it again.
Once your CLA is submitted (or if you already submitted one for another Google
project), make a commit adding yourself to the
[AUTHORS](https://github.com/google/glog/blob/master/AUTHORS) and
[CONTRIBUTORS](https://github.com/google/glog/blob/master/CONTRIBUTORS) files.
This commit can be part of your first [pull
request](https://help.github.com/articles/creating-a-pull-request).
## Submitting a Patch
1. It's generally best to start by opening a new issue describing the
bug or feature you're intending to fix. Even if you think it's
relatively minor, it's helpful to know what people are working on.
Mention in the initial issue that you are planning to work on that
bug or feature so that it can be assigned to you.
2. Follow the normal process of
[forking](https://help.github.com/articles/fork-a-repo) the project,
and setup a new branch to work in. It's important that each group of
changes be done in separate branches in order to ensure that a pull
request only includes the commits related to that bug or feature.
3. Do your best to have [well-formed commit
messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
for each change. This provides consistency throughout the project,
and ensures that commit messages are able to be formatted properly
by various git tools.
4. Finally, push the commits to your fork and submit a [pull
request](https://help.github.com/articles/creating-a-pull-request).

73
docs/failures.md Normal file
View File

@ -0,0 +1,73 @@
# Failure Signal Handler
## Stacktrace as Default Failure Handler
The library provides a convenient signal handler that will dump useful
information when the program crashes on certain signals such as `SIGSEGV`. The
signal handler can be installed by `#!cpp
google::InstallFailureSignalHandler()`. The following is an example of output
from the signal handler.
*** Aborted at 1225095260 (unix time) try "date -d @1225095260" if you are using GNU date ***
*** SIGSEGV (@0x0) received by PID 17711 (TID 0x7f893090a6f0) from PID 0; stack trace: ***
PC: @ 0x412eb1 TestWaitingLogSink::send()
@ 0x7f892fb417d0 (unknown)
@ 0x412eb1 TestWaitingLogSink::send()
@ 0x7f89304f7f06 google::LogMessage::SendToLog()
@ 0x7f89304f35af google::LogMessage::Flush()
@ 0x7f89304f3739 google::LogMessage::~LogMessage()
@ 0x408cf4 TestLogSinkWaitTillSent()
@ 0x4115de main
@ 0x7f892f7ef1c4 (unknown)
@ 0x4046f9 (unknown)
## Customizing Handler Output
By default, the signal handler writes the failure dump to the standard error.
However, it is possible to customize the destination by installing a callback
using the `#!cpp google::InstallFailureWriter()` function. The function expects
a pointer to a function with the following signature:
``` cpp
void YourFailureWriter(const char* message/* (1)! */, std::size_t length/* (2)! */);
```
1. The pointer references the start of the failure message.
!!! danger
The string is **not null-terminated**.
2. The message length in characters.
!!! warning "Possible overflow errors"
Users should not expect the `message` string to be null-terminated.
## User-defined Failure Function
`FATAL` severity level messages or unsatisfied `CHECK` condition
terminate your program. You can change the behavior of the termination
by `google::InstallFailureFunction`.
``` cpp
void YourFailureFunction() {
// Reports something...
exit(EXIT_FAILURE);
}
int main(int argc, char* argv[]) {
google::InstallFailureFunction(&YourFailureFunction);
}
```
By default, glog tries to dump the stacktrace and calls `#!cpp std::abort`. The
stacktrace is generated only when running the application on a system
supported[^1] by glog.
[^1]: To extract the stack trace, glog currently supports the following targets:
* x86, x86_64,
* PowerPC architectures,
* `libunwind`,
* and the Debug Help Library (`dbghelp`) on Windows.

93
docs/flags.md Normal file
View File

@ -0,0 +1,93 @@
# Adjusting Output
Several flags influence glog's output behavior.
## Using Command-line Parameters and Environment Variables
If the [Google gflags
library](https://github.com/gflags/gflags) is installed on your machine,
the build system will automatically detect and use it, allowing you to
pass flags on the command line.
!!! example "Activate `--logtostderr` in an application from the command line"
A binary `you_application` that uses glog can be started using
``` bash
./your_application --logtostderr=1
```
to log to `stderr` instead of writing the output to a log file.
!!! tip
You can set boolean flags to `true` by specifying `1`, `true`, or `yes`. To
set boolean flags to `false`, specify `0`, `false`, or `no`. In either case
the spelling is case-insensitive.
If the Google gflags library isn't installed, you set flags via
environment variables, prefixing the flag name with `GLOG_`, e.g.,
!!! example "Activate `logtostderr` without gflags"
``` bash
GLOG_logtostderr=1 ./your_application
```
The following flags are most commonly used:
`logtostderr` (`bool`, default=`false`)
: Log messages to `stderr` instead of logfiles.
`stderrthreshold` (`int`, default=2, which is `ERROR`)
: Copy log messages at or above this level to `stderr` in addition to
logfiles. The numbers of severity levels `INFO`, `WARNING`, `ERROR`,
and `FATAL` are 0, 1, 2, and 3, respectively.
`minloglevel` (`int`, default=0, which is `INFO`)
: Log messages at or above this level. Again, the numbers of severity
levels `INFO`, `WARNING`, `ERROR`, and `FATAL` are 0, 1, 2, and 3,
respectively.
`log_dir` (`string`, default="")
: If specified, logfiles are written into this directory instead of
the default logging directory.
`v` (`int`, default=0)
: Show all `#!cpp VLOG(m)` messages for `m` less or equal the value of this
flag. Overridable by `#!bash --vmodule`. Refer to [verbose
logging](logging.md#verbose-logging) for more detail.
`vmodule` (`string`, default="")
: Per-module verbose level. The argument has to contain a
comma-separated list of `<module name>=<log level>`. `<module name>` is a
glob pattern (e.g., `gfs*` for all modules whose name starts with "gfs"),
matched against the filename base (that is, name ignoring .cc/.h./-inl.h).
`<log level>` overrides any value given by `--v`. See also [verbose
logging](logging.md#verbose-logging) for more details.
Additional flags are defined in
[flags.cc](https://github.com/google/glog/blob/master/src/flags.cc). Please see
the source for their complete list.
## Modifying Flags Programmatically
You can also modify flag values in your program by modifying global variables
`FLAGS_*`. Most settings start working immediately after you update `FLAGS_*`.
The exceptions are the flags related to destination files. For instance, you
might want to set `FLAGS_log_dir` before calling `google::InitGoogleLogging`.
!!! example "Setting `log_dir` at runtime"
``` cpp
LOG(INFO) << "file";
// Most flags work immediately after updating values.
FLAGS_logtostderr = 1;
LOG(INFO) << "stderr";
FLAGS_logtostderr = 0;
// This wont change the log destination. If you want to set this
// value, you should do this before google::InitGoogleLogging .
FLAGS_log_dir = "/some/log/directory";
LOG(INFO) << "the same file";
```

30
docs/index.md Normal file
View File

@ -0,0 +1,30 @@
# Google Logging Library
Google Logging (glog) is a C++14 library that implements application-level
logging. The library provides logging APIs based on C++-style streams and
various helper macros.
# How to Use
You can log a message by simply streaming things to `LOG`(<a particular
[severity level](logging.md#severity-levels)\>), e.g.,
``` cpp title="main.cpp"
#include <glog/logging.h>
int main(int argc, char* argv[]) {
google::InitGoogleLogging(argv[0]); // (1)!
LOG(INFO) << "Found " << num_cookies << " cookies"; // (2)!
}
```
1. Initialize the Google Logging Library
2. Log a message with informational severity
The library can be installed using various [package managers](packages.md) or
compiled [from source](build.md). For a detailed overview of glog features and
their usage, please refer to the [user guide](logging.md).
!!! warning
The above example requires further [Bazel](build.md#bazel) or
[CMake](usage.md) setup for use in own projects.

3
docs/license.md Normal file
View File

@ -0,0 +1,3 @@
# The 3-Clause BSD License
--8<-- "LICENSE.md"

24
docs/log_cleaner.md Normal file
View File

@ -0,0 +1,24 @@
# Automatically Remove Old Logs
To enable the log cleaner:
``` cpp
using namespace std::chrono_literals;
google::EnableLogCleaner(24h * 3); // keep your logs for 3 days
```
In C++20 (and later) this can be shortened to:
``` cpp
using namespace std::chrono_literals;
google::EnableLogCleaner(3d); // keep your logs for 3 days
```
And then glog will check if there are overdue logs whenever a flush is
performed. In this example, any log file from your project whose last
modified time is greater than 3 days will be `unlink`()ed.
This feature can be disabled at any time (if it has been enabled) using
``` cpp
google::DisableLogCleaner();
```

20
docs/log_stripping.md Normal file
View File

@ -0,0 +1,20 @@
# Strip Logging Messages
Strings used in log messages can increase the size of your binary and
present a privacy concern. You can therefore instruct glog to remove all
strings which fall below a certain severity level by using the
`GOOGLE_STRIP_LOG` macro:
If your application has code like this:
``` cpp
#define GOOGLE_STRIP_LOG 1 // this must go before the #include!
#include <glog/logging.h>
```
The compiler will remove the log messages whose severities are less than
the specified integer value. Since `VLOG` logs at the severity level
`INFO` (numeric value `0`), setting `GOOGLE_STRIP_LOG` to 1 or greater
removes all log messages associated with `VLOG`s as well as `INFO` log
statements.

424
docs/logging.md Normal file
View File

@ -0,0 +1,424 @@
# Logging
glog defines a series of macros that simplify many common logging tasks. You can
log messages by [severity level](#severity-levels), [control logging](flags.md)
behavior from the command line, log based on
[conditionals](#conditional-occasional-logging), abort the program when
[expected conditions](#runtime-checks) are not met, introduce your [own logging
levels](#verbose-logging), [customize the prefix](#format-customization)
attached to log messages, and more.
## Severity Levels
You can specify one of the following severity levels (in increasing order of
severity):
1. `INFO`,
2. `WARNING`,
3. `ERROR`, and
4. `FATAL`.
Logging a `FATAL` message terminates the program (after the message is logged).
!!! note
Messages of a given severity are logged not only to corresponding severity
logfile but also to other logfiles of lower severity. For instance, a
message of severity `FATAL` will be logged to logfiles of severity `FATAL`,
`ERROR`, `WARNING`, and `INFO`.
The `DFATAL` severity logs a `FATAL` error in [debug mode](#debugging-support)
(i.e., there is no `NDEBUG` macro defined), but avoids halting the program in
production by automatically reducing the severity to `ERROR`.
## Log Files
Unless otherwise specified, glog uses the format
<tmp>/<program name>.<hostname>.<user name>.log.<severity level>.<date>-<time>.<pid>
for log filenames written to a directory designated as `<tmp>` and
determined according to the following rules.
**Windows**
: glog uses the
[GetTempPathA](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppatha)
API function to retrieve the directory for temporary files with a
fallback to
1. `C:\TMP\`
2. `C:\TEMP\`
(in the order given.)
**non-Windows**
: The directory is determined by referencing the environment variables
1. `TMPDIR`
2. `TMP`
if set with a fallback to `/tmp/`.
The default path to a log file on Linux, for instance, could be
/tmp/hello_world.example.com.hamaji.log.INFO.20080709-222411.10474
By default, glog echos `ERROR` and `FATAL` messages to standard error in
addition to log files.
## Log Line Prefix Format
Log lines have this form:
Lyyyymmdd hh:mm:ss.uuuuuu threadid file:line] msg...
where the fields are defined as follows:
| Placeholder | Meaning |
| ------------------- | ----------------------------------------------------------------------|
| `L` | A single character, representing the log level (e.g., `I` for `INFO`) |
| `yyyy` | The year |
| `mm` | The month (zero padded; i.e., May is `05`) |
| `dd` | The day (zero padded) |
| `hh:mm:ss.uuuuuu` | Time in hours, minutes and fractional seconds |
| `threadid` | The space-padded thread ID |
| `file` | The file name |
| `line` | The line number |
| `msg` | The user-supplied message |
!!! example "Default log line prefix format"
```
I1103 11:57:31.739339 24395 google.cc:2341] Command line: ./some_prog
I1103 11:57:31.739403 24395 google.cc:2342] Process id 24395
```
!!! note
Although microseconds are useful for comparing events on a single machine,
clocks on different machines may not be well synchronized. Hence, use with
caution when comparing the low bits of timestamps from different machines.
### Format Customization
The predefined log line prefix can be replaced using a user-provided callback
that formats the corresponding output.
For each log entry, the callback will be invoked with a reference to a
`google::LogMessage` instance containing the severity, filename, line
number, thread ID, and time of the event. It will also be given a
reference to the output stream, whose contents will be prepended to the actual
message in the final log line.
To enable the use of a prefix formatter, use the
``` cpp
google::InstallPrefixFormatter(&MyPrefixFormatter);
```
function to pass a pointer to the corresponding `MyPrefixFormatter` callback
during initialization. `InstallPrefixFormatter` takes a second optional argument
of type `#!cpp void*` that allows supplying user data to the callback.
!!! example "Custom prefix formatter"
The following function outputs a prefix that matches glog's default format.
The third parameter `data` can be used to access user-supplied data which
unless specified defaults to `#!cpp nullptr`.
``` cpp
void MyPrefixFormatter(std::ostream& s, const google::LogMessage& m, void* /*data*/) {
s << google::GetLogSeverityName(m.severity())[0]
<< setw(4) << 1900 + m.time().year()
<< setw(2) << 1 + m.time().month()
<< setw(2) << m.time().day()
<< ' '
<< setw(2) << m.time().hour() << ':'
<< setw(2) << m.time().min() << ':'
<< setw(2) << m.time().sec() << "."
<< setw(6) << m.time().usec()
<< ' '
<< setfill(' ') << setw(5)
<< m.thread_id() << setfill('0')
<< ' '
<< m.basename() << ':' << m.line() << "]";
}
```
## Conditional / Occasional Logging
Sometimes, you may only want to log a message under certain conditions.
You can use the following macros to perform conditional logging:
``` cpp
LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
```
The "Got lots of cookies" message is logged only when the variable
`num_cookies` exceeds 10. If a line of code is executed many times, it may be
useful to only log a message at certain intervals. This kind of logging is most
useful for informational messages.
``` cpp
LOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
```
The above line outputs a log messages on the 1st, 11th, 21st, ... times
it is executed.
!!! note
The placeholder `#!cpp google::COUNTER` identifies the recurring repetition.
You can combine conditional and occasional logging with the following
macro.
``` cpp
LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << google::COUNTER
<< "th big cookie";
```
Instead of outputting a message every nth time, you can also limit the
output to the first n occurrences:
``` cpp
LOG_FIRST_N(INFO, 20) << "Got the " << google::COUNTER << "th cookie";
```
Outputs log messages for the first 20 times it is executed. The `#!cpp
google::COUNTER` identifier indicates which repetition is happening.
Other times, it is desired to only log a message periodically based on a
time. For instance, to log a message every 10ms:
``` cpp
LOG_EVERY_T(INFO, 0.01) << "Got a cookie";
```
Or every 2.35s:
``` cpp
LOG_EVERY_T(INFO, 2.35) << "Got a cookie";
```
## Verbose Logging
When you are chasing difficult bugs, thorough log messages are very
useful. However, you may want to ignore too verbose messages in usual
development. For such verbose logging, glog provides the `VLOG` macro, which
allows you to define your own numeric logging levels.
The `#!bash --v` command line option controls which verbose messages are logged:
``` cpp
VLOG(1) << "Im printed when you run the program with --v=1 or higher";
VLOG(2) << "Im printed when you run the program with --v=2 or higher";
```
With `VLOG`, the lower the verbose level, the more likely messages are to be
logged. For example, if `#!bash --v==1`, `#!cpp VLOG(1)` will log, but `#!cpp
VLOG(2)` will not log.
!!! warning
The `VLOG` behavior is opposite of the severity level logging, where
`INFO`, `ERROR`, etc. are defined in increasing order and thus
`#!bash --minloglevel` of 1 will only log `WARNING` and above.
Though you can specify any integers for both `VLOG` macro and `--v` flag, the
common values for them are small positive integers. For example, if you write
`#!cpp VLOG(0)`, you should specify `--v=-1` or lower to silence it. This is less
useful since we may not want verbose logs by default in most cases. The `VLOG`
macros always log at the `INFO` log level (when they log at all).
Verbose logging can be controlled from the command line on a per-module basis:
``` bash
--vmodule=mapreduce=2,file=1,gfs*=3 --v=0
```
Specifying these options will specifically:
1. Print `#!cpp VLOG(2)` and lower messages from mapreduce.{h,cc}
2. Print `#!cpp VLOG(1)` and lower messages from file.{h,cc}
3. Print `#!cpp VLOG(3)` and lower messages from files prefixed with "gfs"
4. Print `#!cpp VLOG(0)` and lower messages from elsewhere
The wildcarding functionality 3. supports both `*` (matches 0 or more
characters) and `?` (matches any single character) wildcards. Please also refer
to [command line flags](flags.md) for more information.
There's also `#!cpp VLOG_IS_ON(n)` "verbose level" condition macro. This macro
returns `#!cpp true` when the `--v` is equal to or greater than `n`. The macro can be
used as follows:
``` cpp
if (VLOG_IS_ON(2)) {
// (1)
}
```
1. Here we can perform some logging preparation and logging that cant be
accomplished with just `#!cpp VLOG(2) << "message ...";`
Verbose level condition macros `VLOG_IF`, `VLOG_EVERY_N` and `VLOG_IF_EVERY_N`
behave analogous to `LOG_IF`, `LOG_EVERY_N`, `LOG_IF_EVERY_N`, but accept a
numeric verbosity level as opposed to a severity level.
``` cpp
VLOG_IF(1, (size > 1024))
<< "Im printed when size is more than 1024 and when you run the "
"program with --v=1 or more";
VLOG_EVERY_N(1, 10)
<< "Im printed every 10th occurrence, and when you run the program "
"with --v=1 or more. Present occurrence is " << google::COUNTER;
VLOG_IF_EVERY_N(1, (size > 1024), 10)
<< "Im printed on every 10th occurrence of case when size is more "
" than 1024, when you run the program with --v=1 or more. ";
"Present occurrence is " << google::COUNTER;
```
!!! info "Performance"
The conditional logging macros provided by glog (e.g., `CHECK`, `LOG_IF`,
`VLOG`, etc.) are carefully implemented and don't execute the right hand
side expressions when the conditions are false. So, the following check may
not sacrifice the performance of your application.
``` cpp
CHECK(obj.ok) << obj.CreatePrettyFormattedStringButVerySlow();
```
## Debugging Support
Special debug mode logging macros only have an effect in debug mode and are
compiled away to nothing for non-debug mode compiles. Use these macros to avoid
slowing down your production application due to excessive logging.
``` cpp
DLOG(INFO) << "Found cookies";
DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
DLOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
DLOG_FIRST_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
DLOG_EVERY_T(INFO, 0.01) << "Got a cookie";
```
## Runtime Checks
It is a good practice to check expected conditions in your program
frequently to detect errors as early as possible. The `CHECK` macro
provides the ability to abort the application when a condition is not met,
similar to the `assert` macro defined in the standard C library.
`CHECK` aborts the application if a condition is not true. Unlike
`assert`, it is **not** controlled by `NDEBUG`, so the check will be executed
regardless of compilation mode. Therefore, `fp->Write(x)` in the following
example is always executed:
``` cpp
CHECK(fp->Write(x) == 4) << "Write failed!";
```
There are various helper macros for equality/inequality checks
-`CHECK_EQ`, `CHECK_NE`, `CHECK_LE`, `CHECK_LT`, `CHECK_GE`, and
`CHECK_GT`. They compare two values, and log a `FATAL` message including the two
values when the result is not as expected. The values must have
`#!cpp operator<<(ostream, ...)` defined.
You may append to the error message like so:
``` cpp
CHECK_NE(1, 2) << ": The world must be ending!";
```
We are very careful to ensure that each argument is evaluated exactly
once, and that anything which is legal to pass as a function argument is legal
here. In particular, the arguments may be temporary expressions which will end
up being destroyed at the end of the apparent statement, for example:
``` cpp
CHECK_EQ(string("abc")[1], b);
```
The compiler reports an error if one of the arguments is a pointer and the other
is `#!cpp nullptr`. To work around this, simply `#!cpp static_cast` `#!cpp
nullptr` to the type of the desired pointer.
``` cpp
CHECK_EQ(some_ptr, static_cast<SomeType*>(nullptr));
```
Better yet, use the `CHECK_NOTNULL` macro:
``` cpp
CHECK_NOTNULL(some_ptr);
some_ptr->DoSomething();
```
Since this macro returns the given pointer, this is very useful in
constructor initializer lists.
``` cpp
struct S {
S(Something* ptr) : ptr_(CHECK_NOTNULL(ptr)) {}
Something* ptr_;
};
```
!!! warning
Due to the argument forwarding, `CHECK_NOTNULL` cannot be used to
simultaneously stream an additional custom message. To provide a custom
message, one can use the macro `CHECK_EQ` prior to the failing check.
If you are comparing C strings (`#!cpp char *`), a handy set of macros performs
both case sensitive and insensitive comparisons - `CHECK_STREQ`, `CHECK_STRNE`,
`CHECK_STRCASEEQ`, and `CHECK_STRCASENE`. The `CHECK_*CASE*` macro variants are
case-insensitive. You can safely pass `#!cpp nullptr` pointers to this macro.
They treat `#!cpp nullptr` and any non-`#!cpp nullptr` string as not equal. Two
`#!cpp nullptr`s are equal.
!!! note
Both arguments may be temporary objects which are destructed at the
end of the current *full expression*, such as
``` cpp
CHECK_STREQ(Foo().c_str(), Bar().c_str());
```
where `Foo` and `Bar` return `std::string`.
The `CHECK_DOUBLE_EQ` macro checks the equality of two floating point values,
accepting a small error margin. `CHECK_NEAR` accepts a third floating point
argument, which specifies the acceptable error margin.
## Raw Logging
The header file `<glog/raw_logging.h>` can be used for thread-safe logging,
which does not allocate any memory or acquire any locks. Therefore, the macros
defined in this header file can be used by low-level memory allocation and
synchronization code. Please check
[src/glog/raw_logging.h](https://github.com/google/glog/blob/master/src/glog/raw_logging.h)
for detail.
## Google Style `perror()`
`PLOG()` and `PLOG_IF()` and `PCHECK()` behave exactly like their `LOG*` and
`CHECK` equivalents with the addition that they append a description of the
current state of `errno` to their output lines. E.g.
``` cpp
PCHECK(write(1, nullptr, 2) >= 0) << "Write nullptr failed";
```
This check fails with the following error message.
F0825 185142 test.cc:22] Check failed: write(1, nullptr, 2) >= 0 Write nullptr failed: Bad address [14]
## Syslog
`SYSLOG`, `SYSLOG_IF`, and `SYSLOG_EVERY_N` macros are available. These log to
syslog in addition to the normal logs. Be aware that logging to syslog can
drastically impact performance, especially if syslog is configured for remote
logging! Make sure you understand the implications of outputting to syslog
before you use these macros. In general, it's wise to use these macros
sparingly.

8
docs/overrides/main.html Normal file
View File

@ -0,0 +1,8 @@
{% extends "base.html" %}
{% block outdated %}
You're not viewing the latest version.
<a href="{{ '../' ~ base_url }}">
<strong>Click here to go to latest.</strong>
</a>
{% endblock %}

34
docs/packages.md Normal file
View File

@ -0,0 +1,34 @@
# Installation using Package Managers
## conan
You can download and install glog using the [conan](https://conan.io)
package manager:
``` bash
pip install conan
conan install -r conancenter glog/<glog-version>@
```
The glog recipe in conan center is kept up to date by conan center index
community contributors. If the version is out of date, please create an
issue or pull request on the
[conan-center-index](https://github.com/conan-io/conan-center-index)
repository.
## vcpkg
You can download and install glog using the
[vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
``` bash
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install glog
```
The glog port in vcpkg is kept up to date by Microsoft team members and
community contributors. If the version is out of date, please create an
issue or pull request on the vcpkg repository.

6
docs/requirements.txt Normal file
View File

@ -0,0 +1,6 @@
mike>=2.1.1
mkdocs-git-committers-plugin-2>=2.3.0
mkdocs-git-revision-date-localized-plugin>=1.2.6
mkdocs-material-extensions>=1.3.1
mkdocs-material>=9.5.26
mkdocs>=1.6.0

84
docs/sinks.md Normal file
View File

@ -0,0 +1,84 @@
# Custom Sinks
Under certain circumstances, it is useful to send the log output to a
destination other than a file, `stderr` and/or `stdout`. In case, the library
provides the `#!cpp google::LogSink` interface whose implementations can be used
to write the log output to arbitrary locations.
## Basic Interface
The sink interface is defined as follows:
``` cpp
class LogSink {
public:
virtual void send(LogSeverity severity, const char* full_filename,
const char* base_filename, int line,
const LogMessageTime& time, const char* message,
size_t message_len);
};
```
The user must implement `#!cpp google::LogSink::send`, which is called by the
library every time a message is logged.
!!! warning "Possible deadlock due to nested logging"
This method can't use `LOG()` or `CHECK()` as logging system mutex(s) are
held during this call.
## Registering Log Sinks
To use the custom sink and instance of the above interface implementation must
be registered using `google::AddLogSink` which expects a pointer to the
`google::LogSink` instance. To unregister use `google::RemoveLogSink`. Both
functions are thread-safe.
!!! danger "`LogSink` ownership"
The `google::LogSink` instance must not be destroyed until the referencing
pointer is unregistered.
## Direct Logging
Instead of registering the sink, we can directly use to log messages. While `#!
LOG_TO_SINK(sink, severity)` allows to log both to the sink and to a global log
registry, e.g., a file, `#!cpp LOG_TO_SINK_BUT_NOT_TO_LOGFILE(sink, severity)`
will avoid the latter.
!!! example "Using a custom sink"
``` cpp title="custom_sink.cc"
-8<- "examples/custom_sink.cc:33:"
```
1. `MySink` implements a custom sink that sends log messages to `std::cout`.
2. The custom sink must be registered to for use with existing logging
macros.
3. Once the custom sink is no longer needed we remove it from the registry.
4. A sink does not need to be registered globally. However, then, messages
must be logged using dedicated macros.
Running the above example as `#!bash GLOG_log_dir=. ./custom_sink_example`
will produce
<div class="annotate" markdown>
``` title="Custom sink output"
INFO custom_sink.cc:63 logging to MySink
INFO custom_sink.cc:68 direct logging
INFO custom_sink.cc:69 direct logging but not to file (1)
```
</div>
1. This line is not present in the log file because we used
`LOG_TO_SINK_BUT_NOT_TO_LOGFILE` to log the message.
and the corresponding log file will contain
``` title="Log file generated with the custom sink"
Log file created at: 2024/06/11 13:24:27
Running on machine: pc
Running duration (h:mm:ss): 0:00:00
Log line format: [IWEF]yyyymmdd hh:mm:ss.uuuuuu threadid file:line] msg
I20240611 13:24:27.476620 126237946035776 custom_sink.cc:63] logging to MySink
I20240611 13:24:27.476796 126237946035776 custom_sink.cc:68] direct logging
```

57
docs/unwinder.md Normal file
View File

@ -0,0 +1,57 @@
# Installation Notes for 64-bit Linux Systems
!!! note
The description on this page is possibly not up-to-date.
The [glibc built-in stack-unwinder](#glibc-built-in-stack-unwinder) on 64-bit
systems has some problems with glog. In particular, if you are using
[`InstallFailureSignalHandler()`](failures.md), the signal may be raised in the
middle of `malloc`, holding some `malloc`-related locks when they invoke the
stack unwinder. The built-in stack unwinder may call `malloc` recursively, which
may require the thread to acquire a lock it already holds resulting in a
deadlock.
## Recommended Approach: `libunwind`
For above reason, if you use a 64-bit system and you need
`InstallFailureSignalHandler()`, we strongly recommend you install `libunwind`
before trying to configure or install google glog. libunwind can be found
[here](http://download.savannah.nongnu.org/releases/libunwind/libunwind-snap-070410.tar.gz).
Even if you already have `libunwind` installed, you will probably still need to
install from the snapshot to get the latest version.
!!! warning
If you install libunwind from the URL above, be aware that you may have
trouble if you try to statically link your binary with glog: that is, if you
link with `gcc -static -lgcc_eh ...`. This is because both `libunwind` and
`libgcc` implement the same C++ exception handling APIs, but they implement
them differently on some platforms. This is not likely to be a problem on
ia64, but may be on x86-64.
Also, if you link binaries statically, make sure that you add
`-Wl,--eh-frame-hdr` to your linker options. This is required so that
`libunwind` can find the information generated by the compiler required for
stack unwinding.
Using `-static` is rare, though, so unless you know this will affect you it
probably won't.
## Alternative Stack-unwinder
If you cannot or do not wish to install `libunwind`, you can still try to use
two kinds of stack-unwinder:
### glibc Built-in Stack-unwinder
As we already mentioned, glibc's unwinder has a deadlock issue. However, if you
don't use `InstallFailureSignalHandler()` or you don't worry about the rare
possibilities of deadlocks, you can use this stack-unwinder. If you specify no
options and `libunwind` isn't detected on your system, the configure script
chooses this unwinder by default.
### Frame Pointer based Stack-unwinder
The frame pointer based stack unwinder requires that your application, the glog
library, and system libraries like libc, all be compiled with a frame pointer.
This is *not* the default for x86-64.

24
docs/usage.md Normal file
View File

@ -0,0 +1,24 @@
# Using glog in a CMake Project
Assuming that glog was previously [built using CMake](build.md#cmake) or
installed using a package manager, you can use the CMake command `#!cmake
find_package` to build against glog in your CMake project as follows:
``` cmake title="CMakeLists.txt"
cmake_minimum_required (VERSION 3.16)
project (myproj VERSION 1.0)
find_package (glog 0.8.0 REQUIRED)
add_executable (myapp main.cpp)
target_link_libraries (myapp glog::glog)
```
Compile definitions and options will be added automatically to your target as
needed.
Alternatively, glog can be incorporated into using the CMake command `#!cmake
add_subdirectory` to include glog directly from a subdirectory of your project
by replacing the `#!cmake find_package` call from the previous snippet by
`add_subdirectory`. The `#!cmake glog::glog` target is in this case an `#!cmake
ALIAS` library target for the `glog` library target.

44
docs/windows.md Normal file
View File

@ -0,0 +1,44 @@
# Notes for Windows Users
glog defines the severity level `ERROR`, which is also defined by `windows.h`.
You can make glog not define `INFO`, `WARNING`, `ERROR`, and `FATAL` by defining
`GLOG_NO_ABBREVIATED_SEVERITIES` before including `glog/logging.h`. Even with
this macro, you can still use the iostream like logging facilities:
``` cpp
#define GLOG_NO_ABBREVIATED_SEVERITIES
#include <windows.h>
#include <glog/logging.h>
// ...
LOG(ERROR) << "This should work";
LOG_IF(ERROR, x > y) << "This should be also OK";
```
However, you cannot use `INFO`, `WARNING`, `ERROR`, and `FATAL` anymore for
functions defined in `glog/logging.h`.
``` cpp
#define GLOG_NO_ABBREVIATED_SEVERITIES
#include <windows.h>
#include <glog/logging.h>
// ...
// This wont work.
// google::FlushLogFiles(google::ERROR);
// Use this instead.
google::FlushLogFiles(google::GLOG_ERROR);
```
If you don't need `ERROR` defined by `windows.h`, there are a couple of more
workarounds which sometimes don't work[^1]:
- `#!cpp #define WIN32_LEAN_AND_MEAN` or `NOGDI` **before**
`#!cpp #include <windows.h>`.
- `#!cpp #undef ERROR` **after** `#!cpp #include <windows.h>`.
[^1]: For more information refer to [this
issue](http://code.google.com/p/google-glog/issues/detail?id=33).

71
examples/custom_sink.cc Normal file
View File

@ -0,0 +1,71 @@
// Copyright (c) 2024, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: Sergiu Deitsch
//
#include <glog/logging.h>
#include <algorithm>
#include <cstddef>
#include <iostream>
#include <iterator>
namespace {
struct MyLogSink : google::LogSink { // (1)!
void send(google::LogSeverity severity, const char* /*full_filename*/,
const char* base_filename, int line,
const google::LogMessageTime& /*time*/, const char* message,
std::size_t message_len) override {
std::cout << google::GetLogSeverityName(severity) << ' ' << base_filename
<< ':' << line << ' ';
std::copy_n(message, message_len,
std::ostreambuf_iterator<char>{std::cout});
std::cout << '\n';
}
};
} // namespace
int main(int /*argc*/, char** argv) {
google::InitGoogleLogging(argv[0]);
MyLogSink sink;
google::AddLogSink(&sink); // (2)!
LOG(INFO) << "logging to MySink";
google::RemoveLogSink(&sink); // (3)!
// We can directly log to a sink without registering it
LOG_TO_SINK(&sink, INFO) << "direct logging"; // (4)!
LOG_TO_SINK_BUT_NOT_TO_LOGFILE(&sink, INFO)
<< "direct logging but not to file";
}

8
gcovr.cfg Normal file
View File

@ -0,0 +1,8 @@
exclude = src/.*_unittest\.cc
exclude = src/googletest\.h
exclude = src/mock-log\.h
exclude-directories = Tests/
exclude-throw-branches = yes
exclude-unreachable-branches = yes
filter = .*/glog/.*\.h
filter = src/

15
glog-config.cmake.in Normal file
View File

@ -0,0 +1,15 @@
if (CMAKE_VERSION VERSION_LESS @glog_CMake_VERSION@)
message (FATAL_ERROR "CMake >= @glog_CMake_VERSION@ required")
endif (CMAKE_VERSION VERSION_LESS @glog_CMake_VERSION@)
@PACKAGE_INIT@
include (CMakeFindDependencyMacro)
include (${CMAKE_CURRENT_LIST_DIR}/glog-modules.cmake)
find_dependency (Threads)
@gflags_DEPENDENCY@
@Unwind_DEPENDENCY@
include (${CMAKE_CURRENT_LIST_DIR}/glog-targets.cmake)

18
glog-modules.cmake.in Normal file
View File

@ -0,0 +1,18 @@
cmake_policy (PUSH)
cmake_policy (SET CMP0057 NEW)
if (CMAKE_VERSION VERSION_LESS 3.3)
message (FATAL_ERROR "glog-modules.cmake requires the consumer "
"to use CMake 3.3 (or newer)")
endif (CMAKE_VERSION VERSION_LESS 3.3)
set (glog_MODULE_PATH "@glog_FULL_CMake_DATADIR@")
list (APPEND CMAKE_MODULE_PATH ${glog_MODULE_PATH})
if (NOT glog_MODULE_PATH IN_LIST CMAKE_MODULE_PATH)
message (FATAL_ERROR "Cannot add '${glog_MODULE_PATH}' to "
"CMAKE_MODULE_PATH. This will cause glog-config.cmake to fail at "
"locating required find modules. Make sure CMAKE_MODULE_PATH is not a cache variable.")
endif (NOT glog_MODULE_PATH IN_LIST CMAKE_MODULE_PATH)
cmake_policy (POP)

View File

@ -1,323 +0,0 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2005-05-14.22
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
chmodcmd="$chmodprog 0755"
chowncmd=
chgrpcmd=
stripcmd=
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=
dst=
dir_arg=
dstarg=
no_target_directory=
usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
-c (ignored)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
--help display this help and exit.
--version display version info and exit.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
"
while test -n "$1"; do
case $1 in
-c) shift
continue;;
-d) dir_arg=true
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
--help) echo "$usage"; exit $?;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-s) stripcmd=$stripprog
shift
continue;;
-t) dstarg=$2
shift
shift
continue;;
-T) no_target_directory=true
shift
continue;;
--version) echo "$0 $scriptversion"; exit $?;;
*) # When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
test -n "$dir_arg$dstarg" && break
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dstarg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dstarg"
shift # fnord
fi
shift # arg
dstarg=$arg
done
break;;
esac
done
if test -z "$1"; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call `install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
for src
do
# Protect names starting with `-'.
case $src in
-*) src=./$src ;;
esac
if test -n "$dir_arg"; then
dst=$src
src=
if test -d "$dst"; then
mkdircmd=:
chmodcmd=
else
mkdircmd=$mkdirprog
fi
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dstarg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dstarg
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst ;;
esac
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dstarg: Is a directory" >&2
exit 1
fi
dst=$dst/`basename "$src"`
fi
fi
# This sed command emulates the dirname command.
dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# Skip lots of stat calls in the usual case.
if test ! -d "$dstdir"; then
defaultIFS='
'
IFS="${IFS-$defaultIFS}"
oIFS=$IFS
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
shift
IFS=$oIFS
pathcomp=
while test $# -ne 0 ; do
pathcomp=$pathcomp$1
shift
if test ! -d "$pathcomp"; then
$mkdirprog "$pathcomp"
# mkdir can fail with a `File exist' error in case several
# install-sh are creating the directory concurrently. This
# is OK.
test -d "$pathcomp" || exit
fi
pathcomp=$pathcomp/
done
fi
if test -n "$dir_arg"; then
$doit $mkdircmd "$dst" \
&& { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
else
dstfile=`basename "$dst"`
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
trap '(exit $?); exit' 1 2 13 15
# Copy the file name to the temp name.
$doit $cpprog "$src" "$dsttmp" &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
# Now rename the file to the real destination.
{ $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
|| {
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
if test -f "$dstdir/$dstfile"; then
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
|| $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
|| {
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
(exit 1); exit 1
}
else
:
fi
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
}
}
fi || { (exit 1); exit 1; }
done
# The final little trick to "correctly" pass the exit status to the exit trap.
{
(exit 0); exit 0
}
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

11
libglog.pc.in Normal file
View File

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libglog
Description: Google Log (glog) C++ logging framework
Version: @VERSION@
Libs: -L${libdir} -lglog
Libs.private: @glog_libraries_options_for_static_linking@
Cflags: -I${includedir}

6871
ltmain.sh

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +0,0 @@
AC_DEFUN([AX_C___ATTRIBUTE__], [
AC_MSG_CHECKING(for __attribute__)
AC_CACHE_VAL(ac_cv___attribute__, [
AC_TRY_COMPILE(
[#include <stdlib.h>
static void foo(void) __attribute__ ((unused));
void foo(void) { exit(1); }],
[],
ac_cv___attribute__=yes,
ac_cv___attribute__=no
)])
if test "$ac_cv___attribute__" = "yes"; then
AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
fi
AC_MSG_RESULT($ac_cv___attribute__)
])

View File

@ -1,14 +0,0 @@
AC_DEFUN([AX_C___BUILTIN_EXPECT], [
AC_MSG_CHECKING(for __builtin_expect)
AC_CACHE_VAL(ac_cv___builtin_expect, [
AC_TRY_COMPILE(
[int foo(void) { if (__builtin_expect(0, 0)) return 1; return 0; }],
[],
ac_cv___builtin_expect=yes,
ac_cv___builtin_expect=no
)])
if test "$ac_cv___builtin_expect" = "yes"; then
AC_DEFINE(HAVE___BUILTIN_EXPECT, 1, [define if your compiler has __builtin_expect])
fi
AC_MSG_RESULT($ac_cv___builtin_expect)
])

View File

@ -1,31 +0,0 @@
# TODO(csilvers): it would be better to actually try to link against
# -pthreads, to make sure it defines these methods, but that may be
# too hard, since pthread support is really tricky.
# Check for support for pthread_rwlock_init() etc.
# These aren't posix, but are widely supported. To get them on linux,
# you need to define _XOPEN_SOURCE first, so this check assumes your
# application does that.
#
# Note: OS X (as of 6/1/06) seems to support pthread_rwlock, but
# doesn't define PTHREAD_RWLOCK_INITIALIZER. Therefore, we don't test
# that particularly macro. It's probably best if you don't use that
# macro in your code either.
AC_DEFUN([AC_RWLOCK],
[AC_CACHE_CHECK(support for pthread_rwlock_* functions,
ac_rwlock,
[AC_LANG_SAVE
AC_LANG_C
AC_TRY_COMPILE([#define _XOPEN_SOURCE 500
#include <pthread.h>],
[pthread_rwlock_t l; pthread_rwlock_init(&l, NULL);
pthread_rwlock_rdlock(&l);
return 0;],
ac_rwlock=yes, ac_rwlock=no)
AC_LANG_RESTORE
])
if test "$ac_rwlock" = yes; then
AC_DEFINE(HAVE_RWLOCK,1,[define if the compiler implements pthread_rwlock_*])
fi
])

View File

@ -1,353 +0,0 @@
# This was retrieved from
# http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/common/acx_pthread.m4?rev=1227
# See also (perhaps for new versions?)
# http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/common/acx_pthread.m4
dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
dnl
dnl @summary figure out how to build C programs using POSIX threads
dnl
dnl This macro figures out how to build C programs using POSIX threads.
dnl It sets the PTHREAD_LIBS output variable to the threads library and
dnl linker flags, and the PTHREAD_CFLAGS output variable to any special
dnl C compiler flags that are needed. (The user can also force certain
dnl compiler flags/libs to be tested by setting these environment
dnl variables.)
dnl
dnl Also sets PTHREAD_CC to any special C compiler that is needed for
dnl multi-threaded programs (defaults to the value of CC otherwise).
dnl (This is necessary on AIX to use the special cc_r compiler alias.)
dnl
dnl NOTE: You are assumed to not only compile your program with these
dnl flags, but also link it with them as well. e.g. you should link
dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
dnl $LIBS
dnl
dnl If you are only building threads programs, you may wish to use
dnl these variables in your default LIBS, CFLAGS, and CC:
dnl
dnl LIBS="$PTHREAD_LIBS $LIBS"
dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
dnl CC="$PTHREAD_CC"
dnl
dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
dnl
dnl ACTION-IF-FOUND is a list of shell commands to run if a threads
dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to
dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the
dnl default action will define HAVE_PTHREAD.
dnl
dnl Please let the authors know if this macro fails on any platform, or
dnl if you have any other suggestions or comments. This macro was based
dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with
dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros
dnl posted by Alejandro Forero Cuervo to the autoconf macro repository.
dnl We are also grateful for the helpful feedback of numerous users.
dnl
dnl @category InstalledPackages
dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
dnl @version 2006-05-29
dnl @license GPLWithACException
dnl
dnl Checks for GCC shared/pthread inconsistency based on work by
dnl Marcin Owsiany <marcin@owsiany.pl>
AC_DEFUN([ACX_PTHREAD], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_LANG_SAVE
AC_LANG_C
acx_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h
# requires special compiler flags (e.g. on True64 or Sequent).
# It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS,
# etcetera environment variables, and if threads linking works using
# them:
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
AC_MSG_RESULT($acx_pthread_ok)
if test x"$acx_pthread_ok" = xno; then
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
fi
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
fi
# We must check for the threads library under a number of different
# names; the ordering is very important because some systems
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
# libraries is broken (non-POSIX).
# Create a list of thread flags to try. Items starting with a "-" are
# C compiler flags, and other items are library names, except for "none"
# which indicates that we try without any flags at all, and "pthread-config"
# which is a program returning the flags for the Pth emulation library.
acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
# pthreads: AIX (must check this before -lpthread)
# none: in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
# -pthreads: Solaris/gcc
# -mthreads: Mingw32/gcc, Lynx/gcc
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads too;
# also defines -D_REENTRANT)
# ... -mt is also the pthreads flag for HP/aCC
# pthread: Linux, etcetera
# --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library)
case "${host_cpu}-${host_os}" in
*solaris*)
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (We need to link with -pthreads/-mt/
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
# a function called by this macro, so we could check for that, but
# who knows whether they'll stub that too in a future libc.) So,
# we'll just look for -pthreads and -lpthread first:
acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
;;
esac
if test x"$acx_pthread_ok" = xno; then
for flag in $acx_pthread_flags; do
case $flag in
none)
AC_MSG_CHECKING([whether pthreads work without any flags])
;;
-*)
AC_MSG_CHECKING([whether pthreads work with $flag])
PTHREAD_CFLAGS="$flag"
;;
pthread-config)
AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
if test x"$acx_pthread_config" = xno; then continue; fi
PTHREAD_CFLAGS="`pthread-config --cflags`"
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
;;
*)
AC_MSG_CHECKING([for the pthreads library -l$flag])
PTHREAD_LIBS="-l$flag"
;;
esac
save_LIBS="$LIBS"
save_CFLAGS="$CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# Check for various functions. We must include pthread.h,
# since some functions may be macros. (On the Sequent, we
# need a special flag -Kthread to make this header compile.)
# We check for pthread_join because it is in -lpthread on IRIX
# while pthread_create is in libc. We check for pthread_attr_init
# due to DEC craziness with -lpthreads. We check for
# pthread_cleanup_push because it is one of the few pthread
# functions on Solaris that doesn't have a non-functional libc stub.
# We try pthread_create on general principles.
AC_TRY_LINK([#include <pthread.h>],
[pthread_t th; pthread_join(th, 0);
pthread_attr_init(0); pthread_cleanup_push(0, 0);
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
[acx_pthread_ok=yes])
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
AC_MSG_RESULT($acx_pthread_ok)
if test "x$acx_pthread_ok" = xyes; then
break;
fi
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
done
fi
# Various other checks:
if test "x$acx_pthread_ok" = xyes; then
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
AC_MSG_CHECKING([for joinable pthread attribute])
attr_name=unknown
for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
[attr_name=$attr; break])
done
AC_MSG_RESULT($attr_name)
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
[Define to necessary symbol if this constant
uses a non-standard name on your system.])
fi
AC_MSG_CHECKING([if more special flags are required for pthreads])
flag=no
case "${host_cpu}-${host_os}" in
*-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
*solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
esac
AC_MSG_RESULT(${flag})
if test "x$flag" != xno; then
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
fi
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
# More AIX lossage: must compile with xlc_r or cc_r
if test x"$GCC" != xyes; then
AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
else
PTHREAD_CC=$CC
fi
# The next part tries to detect GCC inconsistency with -shared on some
# architectures and systems. The problem is that in certain
# configurations, when -shared is specified, GCC "forgets" to
# internally use various flags which are still necessary.
AC_MSG_CHECKING([whether to check for GCC pthread/shared inconsistencies])
check_inconsistencies=yes
case "${host_cpu}-${host_os}" in
*-darwin*) check_inconsistencies=no ;;
esac
if test x"$GCC" != xyes -o "x$check_inconsistencies" != xyes ; then
AC_MSG_RESULT([no])
else
AC_MSG_RESULT([yes])
# In order not to create several levels of indentation, we test
# the value of "$ok" until we find out the cure or run out of
# ideas.
ok="no"
#
# Prepare the flags
#
save_CFLAGS="$CFLAGS"
save_LIBS="$LIBS"
save_CC="$CC"
# Try with the flags determined by the earlier checks.
#
# -Wl,-z,defs forces link-time symbol resolution, so that the
# linking checks with -shared actually have any value
#
# FIXME: -fPIC is required for -shared on many architectures,
# so we specify it here, but the right way would probably be to
# properly detect whether it is actually required.
CFLAGS="-shared -fPIC -Wl,-z,defs $CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
CC="$PTHREAD_CC"
AC_MSG_CHECKING([whether -pthread is sufficient with -shared])
AC_TRY_LINK([#include <pthread.h>],
[pthread_t th; pthread_join(th, 0);
pthread_attr_init(0); pthread_cleanup_push(0, 0);
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
[ok=yes])
if test "x$ok" = xyes; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
#
# Linux gcc on some architectures such as mips/mipsel forgets
# about -lpthread
#
if test x"$ok" = xno; then
AC_MSG_CHECKING([whether -lpthread fixes that])
LIBS="-lpthread $PTHREAD_LIBS $save_LIBS"
AC_TRY_LINK([#include <pthread.h>],
[pthread_t th; pthread_join(th, 0);
pthread_attr_init(0); pthread_cleanup_push(0, 0);
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
[ok=yes])
if test "x$ok" = xyes; then
AC_MSG_RESULT([yes])
PTHREAD_LIBS="-lpthread $PTHREAD_LIBS"
else
AC_MSG_RESULT([no])
fi
fi
#
# FreeBSD 4.10 gcc forgets to use -lc_r instead of -lc
#
if test x"$ok" = xno; then
AC_MSG_CHECKING([whether -lc_r fixes that])
LIBS="-lc_r $PTHREAD_LIBS $save_LIBS"
AC_TRY_LINK([#include <pthread.h>],
[pthread_t th; pthread_join(th, 0);
pthread_attr_init(0); pthread_cleanup_push(0, 0);
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
[ok=yes])
if test "x$ok" = xyes; then
AC_MSG_RESULT([yes])
PTHREAD_LIBS="-lc_r $PTHREAD_LIBS"
else
AC_MSG_RESULT([no])
fi
fi
if test x"$ok" = xno; then
# OK, we have run out of ideas
AC_MSG_WARN([Impossible to determine how to use pthreads with shared libraries])
# so it's not safe to assume that we may use pthreads
acx_pthread_ok=no
fi
CFLAGS="$save_CFLAGS"
LIBS="$save_LIBS"
CC="$save_CC"
fi
else
PTHREAD_CC="$CC"
fi
AC_SUBST(PTHREAD_LIBS)
AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(PTHREAD_CC)
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test x"$acx_pthread_ok" = xyes; then
ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
:
else
acx_pthread_ok=no
$2
fi
AC_LANG_RESTORE
])dnl ACX_PTHREAD

View File

@ -1,36 +0,0 @@
# Allow users to override the namespace we define our application's classes in
# Arg $1 is the default namespace to use if --enable-namespace isn't present.
# In general, $1 should be 'google', so we put all our exported symbols in a
# unique namespace that is not likely to conflict with anyone else. However,
# when it makes sense -- for instance, when publishing stl-like code -- you
# may want to go with a different default, like 'std'.
AC_DEFUN([AC_DEFINE_GOOGLE_NAMESPACE],
[google_namespace_default=[$1]
AC_ARG_ENABLE(namespace, [ --enable-namespace=FOO to define these Google
classes in the FOO namespace. --disable-namespace
to define them in the global namespace. Default
is to define them in namespace $1.],
[case "$enableval" in
yes) google_namespace="$google_namespace_default" ;;
no) google_namespace="" ;;
*) google_namespace="$enableval" ;;
esac],
[google_namespace="$google_namespace_default"])
if test -n "$google_namespace"; then
ac_google_namespace="$google_namespace"
ac_google_start_namespace="namespace $google_namespace {"
ac_google_end_namespace="}"
else
ac_google_namespace=""
ac_google_start_namespace=""
ac_google_end_namespace=""
fi
AC_DEFINE_UNQUOTED(GOOGLE_NAMESPACE, $ac_google_namespace,
Namespace for Google classes)
AC_DEFINE_UNQUOTED(_START_GOOGLE_NAMESPACE_, $ac_google_start_namespace,
Puts following code inside the Google namespace)
AC_DEFINE_UNQUOTED(_END_GOOGLE_NAMESPACE_, $ac_google_end_namespace,
Stops putting the code inside the Google namespace)
])

View File

@ -1,15 +0,0 @@
# Checks whether the compiler implements namespaces
AC_DEFUN([AC_CXX_NAMESPACES],
[AC_CACHE_CHECK(whether the compiler implements namespaces,
ac_cv_cxx_namespaces,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE([namespace Outer {
namespace Inner { int i = 0; }}],
[using namespace Outer::Inner; return i;],
ac_cv_cxx_namespaces=yes,
ac_cv_cxx_namespaces=no)
AC_LANG_RESTORE])
if test "$ac_cv_cxx_namespaces" = yes; then
AC_DEFINE(HAVE_NAMESPACES, 1, [define if the compiler implements namespaces])
fi])

View File

@ -1,25 +0,0 @@
# We check what namespace stl code like vector expects to be executed in
AC_DEFUN([AC_CXX_STL_NAMESPACE],
[AC_CACHE_CHECK(
what namespace STL code is in,
ac_cv_cxx_stl_namespace,
[AC_REQUIRE([AC_CXX_NAMESPACES])
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE([#include <vector>],
[vector<int> t; return 0;],
ac_cv_cxx_stl_namespace=none)
AC_TRY_COMPILE([#include <vector>],
[std::vector<int> t; return 0;],
ac_cv_cxx_stl_namespace=std)
AC_LANG_RESTORE])
if test "$ac_cv_cxx_stl_namespace" = none; then
AC_DEFINE(STL_NAMESPACE,,
[the namespace where STL code like vector<> is defined])
fi
if test "$ac_cv_cxx_stl_namespace" = std; then
AC_DEFINE(STL_NAMESPACE,std,
[the namespace where STL code like vector<> is defined])
fi
])

View File

@ -1,15 +0,0 @@
AC_DEFUN([AC_CXX_USING_OPERATOR],
[AC_CACHE_CHECK(
whether compiler supports using ::operator<<,
ac_cv_cxx_using_operator,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE([#include <iostream>
std::ostream& operator<<(std::ostream&, struct s);],
[using ::operator<<; return 0;],
ac_cv_cxx_using_operator=1,
ac_cv_cxx_using_operator=0)
AC_LANG_RESTORE])
if test "$ac_cv_cxx_using_operator" = 1; then
AC_DEFINE(HAVE_USING_OPERATOR, 1, [define if the compiler supports using expression for operator])
fi])

360
missing
View File

@ -1,360 +0,0 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
scriptversion=2005-06-08.21
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
run=:
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.ac; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
msg="missing on your system"
case "$1" in
--run)
# Try to run requested program, and just exit if it succeeds.
run=
shift
"$@" && exit 0
# Exit code 63 means version mismatch. This often happens
# when the user try to use an ancient version of a tool on
# a file that requires a minimum version. In this case we
# we should proceed has if the program had been absent, or
# if --run hadn't been passed.
if test $? = 63; then
run=:
msg="probably too old"
fi
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
--run try to run the given command, and emulate it if it fails
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
tar try tar, gnutar, gtar, then tar without non-portable flags
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
Send bug reports to <bug-automake@gnu.org>."
exit $?
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
exit $?
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
esac
# Now exit if we have it, but it failed. Also exit now if we
# don't have it and --version was passed (most likely to detect
# the program).
case "$1" in
lex|yacc)
# Not GNU programs, they don't have --version.
;;
tar)
if test -n "$run"; then
echo 1>&2 "ERROR: \`tar' requires --run"
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
exit 1
fi
;;
*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
# Could not run --version or --help. This is probably someone
# running `$TOOL --version' or `$TOOL --help' to check whether
# $TOOL exists and not knowing $TOOL uses missing.
exit 1
fi
;;
esac
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
case "$1" in
aclocal*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case "$f" in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
autom4te)
echo 1>&2 "\
WARNING: \`$1' is needed, but is $msg.
You might have modified some files without having the
proper tools for further handling them.
You can get \`$1' as part of \`Autoconf' from any GNU
archive site."
file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo "#! /bin/sh"
echo "# Created by GNU Automake missing as a replacement of"
echo "# $ $@"
echo "exit 0"
chmod +x $file
exit 1
fi
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' $msg. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if [ ! -f y.tab.h ]; then
echo >y.tab.h
fi
if [ ! -f y.tab.c ]; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if [ ! -f lex.yy.c ]; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
help2man)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
fi
if [ -f "$file" ]; then
touch $file
else
test -z "$file" || exec >$file
echo ".ab help2man is required to generate this page"
exit 1
fi
;;
makeinfo)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
# The file to touch is that specified with -o ...
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
# ... or it is the one specified with @setfilename ...
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
# ... or it is derived from the source name (dir/f.texi becomes f.info)
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
fi
# If the file does not exist, the user really needs makeinfo;
# let's fail without touching anything.
test -f $file || exit 1
touch $file
;;
tar)
shift
# We have already tried tar in the generic part.
# Look for gnutar/gtar before invocation to avoid ugly error
# messages.
if (gnutar --version > /dev/null 2>&1); then
gnutar "$@" && exit 0
fi
if (gtar --version > /dev/null 2>&1); then
gtar "$@" && exit 0
fi
firstarg="$1"
if shift; then
case "$firstarg" in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
tar "$firstarg" "$@" && exit 0
;;
esac
case "$firstarg" in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
tar "$firstarg" "$@" && exit 0
;;
esac
fi
echo 1>&2 "\
WARNING: I can't seem to be able to run \`tar' with the given arguments.
You may want to install GNU tar or Free paxutils, or check the
command line arguments."
exit 1
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and is $msg.
You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequisites for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

123
mkdocs.yml Normal file
View File

@ -0,0 +1,123 @@
---
site_name: Google Logging Library
site_url: https://google.github.io/glog/
repo_url: https://github.com/google/glog
repo_name: google/glog
edit_uri: edit/master/docs/
copyright: Copyright &copy; 2024 Google Inc. &amp; contributors - <a href="#__consent">Change cookie settings</a>
markdown_extensions:
- admonition
- attr_list
- def_list
- footnotes
- md_in_html
- pymdownx.details
- pymdownx.highlight:
anchor_linenums: true
line_spans: __span
pygments_lang_class: true
- pymdownx.inlinehilite
- pymdownx.snippets:
base_path:
- '.'
check_paths: true
- pymdownx.superfences
- tables
- toc:
permalink: true
theme:
name: material
custom_dir: docs/overrides
icon:
annotation: material/chevron-right-circle
edit: material/pencil
repo: fontawesome/brands/git-alt
view: material/eye
language: en
features:
- content.action.edit
- content.code.annotate
- content.code.copy
- content.code.select
- header.autohide
- navigation.expand
- navigation.instant.preview
- navigation.instant.progress
- navigation.prune
- navigation.indexes
- toc.follow
- navigation.top
- navigation.path
# - navigation.sections
# - navigation.tabs
# - navigation.tabs.sticky
- navigation.tracking
- search.highlight
- search.share
- search.suggest
palette:
# Palette toggle for automatic mode
- media: "(prefers-color-scheme)"
toggle:
icon: material/brightness-auto
name: Switch to light mode
# Palette toggle for light mode
- media: "(prefers-color-scheme: light)"
scheme: default
primary: teal
accent: green
toggle:
icon: material/brightness-7
name: Switch to dark mode
# Palette toggle for dark mode
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: black
toggle:
icon: material/brightness-4
name: Switch to system preference
plugins:
- git-revision-date-localized:
enable_creation_date: true
- git-committers:
repository: google/glog
branch: master
- privacy
- search
- tags
extra:
version:
alias: true
default:
- dev
- stable
provider: mike
consent:
actions:
- manage
- accept
- reject
title: Cookie consent
description: >-
We use cookies to recognize your repeated visits and preferences, as well
as to measure the effectiveness of our documentation and whether users
find what they're searching for. With your consent, you're helping us to
make our documentation better.
nav:
- Getting Started:
- Overview: index.md
- Usage in CMake Projects: usage.md
- Building from Source: build.md
- Installation using Package Managers: packages.md
- User Guide:
- Logging: logging.md
- Adjusting Output: flags.md
- Custom Sinks: sinks.md
- Failure Handler: failures.md
- Log Removal: log_cleaner.md
- Stripping Log Messages: log_stripping.md
- System-specific Considerations:
- Usage on Windows: windows.md
- Linux Unwinder: unwinder.md
- Contributing: contribute.md
- License: license.md

View File

@ -1,158 +0,0 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
scriptversion=2005-06-29.22
# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain.
#
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
errstatus=0
dirmode=
usage="\
Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
Create each directory DIR (with mode MODE, if specified), including all
leading file name components.
Report bugs to <bug-automake@gnu.org>."
# process command line arguments
while test $# -gt 0 ; do
case $1 in
-h | --help | --h*) # -h for help
echo "$usage"
exit $?
;;
-m) # -m PERM arg
shift
test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
dirmode=$1
shift
;;
--version)
echo "$0 $scriptversion"
exit $?
;;
--) # stop option processing
shift
break
;;
-*) # unknown option
echo "$usage" 1>&2
exit 1
;;
*) # first non-opt arg
break
;;
esac
done
for file
do
if test -d "$file"; then
shift
else
break
fi
done
case $# in
0) exit 0 ;;
esac
# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
# mkdir -p a/c at the same time, both will detect that a is missing,
# one will create a, then the other will try to create a and die with
# a "File exists" error. This is a problem when calling mkinstalldirs
# from a parallel make. We use --version in the probe to restrict
# ourselves to GNU mkdir, which is thread-safe.
case $dirmode in
'')
if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
echo "mkdir -p -- $*"
exec mkdir -p -- "$@"
else
# On NextStep and OpenStep, the `mkdir' command does not
# recognize any option. It will interpret all options as
# directories to create, and then abort because `.' already
# exists.
test -d ./-p && rmdir ./-p
test -d ./--version && rmdir ./--version
fi
;;
*)
if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
test ! -d ./--version; then
echo "mkdir -m $dirmode -p -- $*"
exec mkdir -m "$dirmode" -p -- "$@"
else
# Clean up after NextStep and OpenStep mkdir.
for d in ./-m ./-p ./--version "./$dirmode";
do
test -d $d && rmdir $d
done
fi
;;
esac
for file
do
case $file in
/*) pathcomp=/ ;;
*) pathcomp= ;;
esac
oIFS=$IFS
IFS=/
set fnord $file
shift
IFS=$oIFS
for d
do
test "x$d" = x && continue
pathcomp=$pathcomp$d
case $pathcomp in
-*) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
else
if test ! -z "$dirmode"; then
echo "chmod $dirmode $pathcomp"
lasterr=
chmod "$dirmode" "$pathcomp" || lasterr=$?
if test ! -z "$lasterr"; then
errstatus=$lasterr
fi
fi
fi
fi
pathcomp=$pathcomp/
done
done
exit $errstatus
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

View File

@ -1,70 +0,0 @@
#!/bin/bash -e
# This takes one commandline argument, the name of the package. If no
# name is given, then we'll end up just using the name associated with
# an arbitrary .tar.gz file in the rootdir. That's fine: there's probably
# only one.
#
# Run this from the 'packages' directory, just under rootdir
## Set LIB to lib if exporting a library, empty-string else
LIB=
#LIB=lib
PACKAGE="$1"
# We can only build Debian packages, if the Debian build tools are installed
if [ \! -x /usr/bin/debuild ]; then
echo "Cannot find /usr/bin/debuild. Not building Debian packages." 1>&2
exit 0
fi
# Double-check we're in the packages directory, just under rootdir
if [ \! -r ../Makefile -a \! -r ../INSTALL ]; then
echo "Must run $0 in the 'packages' directory, under the root directory." 1>&2
echo "Also, you must run \"make dist\" before running this script." 1>&2
exit 0
fi
# Find the top directory for this package
topdir="${PWD%/*}"
# Find the tar archive built by "make dist"
archive="$(basename "$(ls -1 ${topdir}/$PACKAGE*.tar.gz | tail -n 1)" .tar.gz)"
if [ -z "${archive}" ]; then
echo "Cannot find ../$PACKAGE*.tar.gz. Run \"make dist\" first." 1>&2
exit 0
fi
# Create a pristine directory for building the Debian package files
trap 'rm -rf '`pwd`/tmp'; exit $?' EXIT SIGHUP SIGINT SIGTERM
rm -rf tmp
mkdir -p tmp
cd tmp
# Debian has very specific requirements about the naming of build
# directories, and tar archives. It also wants to write all generated
# packages to the parent of the source directory. We accommodate these
# requirements by building directly from the tar file.
ln -s "${topdir}/${archive}.tar.gz" "${LIB}${archive}.orig.tar.gz"
tar zfx "${LIB}${archive}.orig.tar.gz"
[ -n "${LIB}" ] && mv "${archive}" "${LIB}${archive}"
cd "${LIB}${archive}"
# This is one of those 'specific requirements': where the deb control files live
ln -s "packages/deb" "debian"
# Now, we can call Debian's standard build tool
debuild -uc -us
cd ../.. # get back to the original top-level dir
# We'll put the result in a subdirectory that's named after the OS version
# we've made this .deb file for.
destdir="debian-$(cat /etc/debian_version 2>/dev/null || echo UNKNOWN)"
rm -rf "$destdir"
mkdir -p "$destdir"
mv $(find tmp -mindepth 1 -maxdepth 1 -type f) "$destdir"
echo
echo "The Debian package files are located in $PWD/$destdir"

View File

@ -1,7 +0,0 @@
The list of files here isn't complete. For a step-by-step guide on
how to set this package up correctly, check out
http://www.debian.org/doc/maint-guide/
Most of the files that are in this directory are boilerplate.
However, you may need to change the list of binary-arch dependencies
in 'rules'.

View File

@ -1,5 +0,0 @@
google-glog (0.1-1) unstable; urgency=low
* Initial release.
-- Google Inc. <opensource@google.com> Sat, 10 May 2008 12:31:10 +0900

View File

@ -1 +0,0 @@
4

View File

@ -1,23 +0,0 @@
Source: google-glog
Priority: optional
Maintainer: Google Inc. <opensource@google.com>
Build-Depends: debhelper (>= 4.0.0), binutils
Standards-Version: 3.6.1
Package: libgoogle-glog-dev
Section: libdevel
Architecture: any
Depends: libgoogle-glog0 (= ${Source-Version})
Description: a library that implements application-level logging.
This library provides logging APIs based on C++-style streams and
various helper macros. The devel package contains static and debug
libraries and header files for developing applications that use the
google-glog package.
Package: libgoogle-glog0
Section: libs
Architecture: any
Depends: ${shlibs:Depends}
Description: a library that implements application-level logging.
This library provides logging APIs based on C++-style streams and
various helper macros.

View File

@ -1,35 +0,0 @@
This package was debianized by Google Inc. <opensource@google.com> on
13 June 2008.
It was downloaded from http://code.google.com/
Upstream Author: opensource@google.com
Copyright (c) 2008, Google Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,8 +0,0 @@
AUTHORS
COPYING
ChangeLog
INSTALL
NEWS
README
doc/designstyle.css
doc/glog.html

View File

@ -1,3 +0,0 @@
usr/lib
usr/include
usr/include/glog

View File

@ -1,8 +0,0 @@
usr/include/glog/*
usr/lib/lib*.so
usr/lib/lib*.a
usr/lib/*.la
debian/tmp/usr/include/glog/*
debian/tmp/usr/lib/lib*.so
debian/tmp/usr/lib/lib*.a
debian/tmp/usr/lib/*.la

View File

@ -1 +0,0 @@
usr/lib

View File

@ -1,2 +0,0 @@
usr/lib/lib*.so.*
debian/tmp/usr/lib/lib*.so.*

View File

@ -1,117 +0,0 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
CFLAGS = -Wall -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
else
CFLAGS += -O2
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
INSTALL_PROGRAM += -s
endif
# shared library versions, option 1
#version=2.0.5
#major=2
# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so
version=`ls src/.libs/lib*.so.* | \
awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
major=`ls src/.libs/lib*.so.* | \
awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`
config.status: configure
dh_testdir
# Add here commands to configure the package.
CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info
build: build-stamp
build-stamp: config.status
dh_testdir
# Add here commands to compile the package.
$(MAKE)
touch build-stamp
clean:
dh_testdir
dh_testroot
rm -f build-stamp
# Add here commands to clean up after the build process.
-$(MAKE) distclean
ifneq "$(wildcard /usr/share/misc/config.sub)" ""
cp -f /usr/share/misc/config.sub config.sub
endif
ifneq "$(wildcard /usr/share/misc/config.guess)" ""
cp -f /usr/share/misc/config.guess config.guess
endif
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# Add here commands to install the package into debian/tmp
$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs ChangeLog
dh_installdocs
dh_installexamples
dh_install --sourcedir=debian/tmp
# dh_installmenu
# dh_installdebconf
# dh_installlogrotate
# dh_installemacsen
# dh_installpam
# dh_installmime
# dh_installinit
# dh_installcron
# dh_installinfo
dh_installman
dh_link
dh_strip
dh_compress
dh_fixperms
# dh_perl
# dh_python
dh_makeshlibs
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install

View File

@ -1,75 +0,0 @@
#!/bin/sh -e
# Run this from the 'packages' directory, just under rootdir
# We can only build rpm packages, if the rpm build tools are installed
if [ \! -x /usr/bin/rpmbuild ]
then
echo "Cannot find /usr/bin/rpmbuild. Not building an rpm." 1>&2
exit 0
fi
# Check the commandline flags
PACKAGE="$1"
VERSION="$2"
fullname="${PACKAGE}-${VERSION}"
archive=../$fullname.tar.gz
if [ -z "$1" -o -z "$2" ]
then
echo "Usage: $0 <package name> <package version>" 1>&2
exit 0
fi
# Double-check we're in the packages directory, just under rootdir
if [ \! -r ../Makefile -a \! -r ../INSTALL ]
then
echo "Must run $0 in the 'packages' directory, under the root directory." 1>&2
echo "Also, you must run \"make dist\" before running this script." 1>&2
exit 0
fi
if [ \! -r "$archive" ]
then
echo "Cannot find $archive. Run \"make dist\" first." 1>&2
exit 0
fi
# Create the directory where the input lives, and where the output should live
RPM_SOURCE_DIR="/tmp/rpmsource-$fullname"
RPM_BUILD_DIR="/tmp/rpmbuild-$fullname"
trap 'rm -rf $RPM_SOURCE_DIR $RPM_BUILD_DIR; exit $?' EXIT SIGHUP SIGINT SIGTERM
rm -rf "$RPM_SOURCE_DIR" "$RPM_BUILD_DIR"
mkdir "$RPM_SOURCE_DIR"
mkdir "$RPM_BUILD_DIR"
cp "$archive" "$RPM_SOURCE_DIR"
rpmbuild -bb rpm/rpm.spec \
--define "NAME $PACKAGE" \
--define "VERSION $VERSION" \
--define "_sourcedir $RPM_SOURCE_DIR" \
--define "_builddir $RPM_BUILD_DIR" \
--define "_rpmdir $RPM_SOURCE_DIR"
# We put the output in a directory based on what system we've built for
destdir=rpm-unknown
if [ -r /etc/issue ]
then
grep "Red Hat.*release 7" /etc/issue >/dev/null 2>&1 && destdir=rh7
grep "Red Hat.*release 8" /etc/issue >/dev/null 2>&1 && destdir=rh8
grep "Red Hat.*release 9" /etc/issue >/dev/null 2>&1 && destdir=rh9
if grep Fedora /etc/issue >/dev/null; then
destdir=fc`grep Fedora /etc/issue | cut -d' ' -f 4`;
fi
fi
rm -rf "$destdir"
mkdir -p "$destdir"
# We want to get not only the main package but devel etc, hence the middle *
mv "$RPM_SOURCE_DIR"/*/"${PACKAGE}"-*"${VERSION}"*.rpm "$destdir"
echo
echo "The rpm package file(s) are located in $PWD/$destdir"

View File

@ -1,71 +0,0 @@
%define RELEASE 1
%define rel %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE}
%define prefix /usr
Name: %NAME
Summary: A C++ application logging library
Version: %VERSION
Release: %rel
Group: Development/Libraries
URL: http://code.google.com/p/google-glog
License: BSD
Vendor: Google
Packager: Google Inc. <opensource@google.com>
Source: http://%{NAME}.googlecode.com/files/%{NAME}-%{VERSION}.tar.gz
Distribution: Redhat 7 and above.
Buildroot: %{_tmppath}/%{name}-root
Prefix: %prefix
%description
The %name package contains a library that implements application-level
logging. This library provides logging APIs based on C++-style
streams and various helper macros.
%package devel
Summary: A C++ application logging library
Group: Development/Libraries
Requires: %{NAME} = %{VERSION}
%description devel
The %name-devel package contains static and debug libraries and header
files for developing applications that use the %name package.
%changelog
* Wed Mar 26 2008 <opensource@google.com>
- First draft
%prep
%setup
%build
./configure
make prefix=%prefix
%install
rm -rf $RPM_BUILD_ROOT
make prefix=$RPM_BUILD_ROOT%{prefix} install
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
## Mark all installed files within /usr/share/doc/{package name} as
## documentation. This depends on the following two lines appearing in
## Makefile.am:
## docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION)
## dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README
%docdir %{prefix}/share/doc/%{NAME}-%{VERSION}
%{prefix}/share/doc/%{NAME}-%{VERSION}/*
%{prefix}/lib/libglog.so.0
%{prefix}/lib/libglog.so.0.0.0
%files devel
%defattr(-,root,root)
%{prefix}/include/glog
%{prefix}/lib/libglog.a
%{prefix}/lib/libglog.la
%{prefix}/lib/libglog.so

View File

@ -48,70 +48,102 @@
#ifndef BASE_COMMANDLINEFLAGS_H__
#define BASE_COMMANDLINEFLAGS_H__
#include "config.h"
#include <cstdlib> // for getenv
#include <cstring> // for memchr
#include <string>
#include <string.h> // for memchr
#include <stdlib.h> // for getenv
#ifdef HAVE_LIB_GFLAGS
#include "config.h"
#include <gflags/gflags.h>
#ifdef GLOG_USE_GFLAGS
# include <gflags/gflags.h>
#else
#include "glog/logging.h"
# include "glog/logging.h"
#define DECLARE_VARIABLE(type, name, tn) \
namespace FLAG__namespace_do_not_use_directly_use_DECLARE_##tn##_instead { \
extern type FLAGS_##name; \
# define DECLARE_VARIABLE(type, shorttype, name, tn) \
namespace fL##shorttype { \
extern GLOG_EXPORT type FLAGS_##name; \
} \
using FLAG__namespace_do_not_use_directly_use_DECLARE_##tn##_instead::FLAGS_##name
#define DEFINE_VARIABLE(type, name, value, meaning, tn) \
namespace FLAG__namespace_do_not_use_directly_use_DECLARE_##tn##_instead { \
type FLAGS_##name(value); \
using fL##shorttype::FLAGS_##name
# define DEFINE_VARIABLE(type, shorttype, name, value, meaning, tn) \
namespace fL##shorttype { \
GLOG_EXPORT type FLAGS_##name(value); \
char FLAGS_no##name; \
} \
using FLAG__namespace_do_not_use_directly_use_DECLARE_##tn##_instead::FLAGS_##name
using fL##shorttype::FLAGS_##name
// bool specialization
#define DECLARE_bool(name) \
DECLARE_VARIABLE(bool, name, bool)
#define DEFINE_bool(name, value, meaning) \
DEFINE_VARIABLE(bool, name, EnvToBool("GLOG_" #name, value), meaning, bool)
# define DECLARE_bool(name) DECLARE_VARIABLE(bool, B, name, bool)
# define DEFINE_bool(name, value, meaning) \
DEFINE_VARIABLE(bool, B, name, value, meaning, bool)
// int32 specialization
#define DECLARE_int32(name) \
DECLARE_VARIABLE(@ac_google_namespace@::int32, name, int32)
#define DEFINE_int32(name, value, meaning) \
DEFINE_VARIABLE(GOOGLE_NAMESPACE::int32, name, \
EnvToInt("GLOG_" #name, value), meaning, int32)
# define DECLARE_int32(name) DECLARE_VARIABLE(google::int32, I, name, int32)
# define DEFINE_int32(name, value, meaning) \
DEFINE_VARIABLE(google::int32, I, name, value, meaning, int32)
// uint32 specialization
# ifndef DECLARE_uint32
# define DECLARE_uint32(name) \
DECLARE_VARIABLE(google::uint32, U, name, uint32)
# endif // DECLARE_uint64
# define DEFINE_uint32(name, value, meaning) \
DEFINE_VARIABLE(google::uint32, U, name, value, meaning, uint32)
// Special case for string, because we have to specify the namespace
// std::string, which doesn't play nicely with our FLAG__namespace hackery.
#define DECLARE_string(name) \
namespace FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead { \
extern std::string FLAGS_##name; \
# define DECLARE_string(name) \
namespace fLS { \
extern GLOG_EXPORT std::string& FLAGS_##name; \
} \
using FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead::FLAGS_##name
#define DEFINE_string(name, value, meaning) \
namespace FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead { \
std::string FLAGS_##name(EnvToString("GLOG_" #name, value)); \
using fLS::FLAGS_##name
# define DEFINE_string(name, value, meaning) \
namespace fLS { \
std::string FLAGS_##name##_buf(value); \
GLOG_EXPORT std::string& FLAGS_##name = FLAGS_##name##_buf; \
char FLAGS_no##name; \
} \
using FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead::FLAGS_##name
using fLS::FLAGS_##name
#endif // GLOG_USE_GFLAGS
// Define GLOG_DEFINE_* using DEFINE_* . By using these macros, we
// have GLOG_* environ variables even if we have gflags installed.
//
// If both an environment variable and a flag are specified, the value
// specified by a flag wins. E.g., if GLOG_v=0 and --v=1, the
// verbosity will be 1, not 0.
#define GLOG_DEFINE_bool(name, value, meaning) \
DEFINE_bool(name, EnvToBool("GLOG_" #name, value), meaning)
#define GLOG_DEFINE_int32(name, value, meaning) \
DEFINE_int32(name, EnvToInt("GLOG_" #name, value), meaning)
#define GLOG_DEFINE_uint32(name, value, meaning) \
DEFINE_uint32(name, EnvToUInt("GLOG_" #name, value), meaning)
#define GLOG_DEFINE_string(name, value, meaning) \
DEFINE_string(name, EnvToString("GLOG_" #name, value), meaning)
// These macros (could be functions, but I don't want to bother with a .cc
// file), make it easier to initialize flags from the environment.
#define EnvToString(envname, dflt) \
(!getenv(envname) ? (dflt) : getenv(envname))
#define EnvToString(envname, dflt) (!getenv(envname) ? (dflt) : getenv(envname))
#define EnvToBool(envname, dflt) \
(!getenv(envname) ? (dflt) : memchr("tTyY1\0", getenv(envname)[0], 6) != NULL)
(!getenv(envname) ? (dflt) \
: memchr("tTyY1\0", getenv(envname)[0], 6) != nullptr)
#define EnvToInt(envname, dflt) \
(!getenv(envname) ? (dflt) : strtol(getenv(envname), NULL, 10))
(!getenv(envname) ? (dflt) \
: static_cast<int>(strtol(getenv(envname), nullptr, 10)))
#endif // HAVE_LIB_GFLAGS
#define EnvToUInt(envname, dflt) \
(!getenv(envname) \
? (dflt) \
: static_cast<unsigned>(strtoul(getenv(envname), nullptr, 10)))
#endif // BASE_COMMANDLINEFLAGS_H__

View File

@ -35,17 +35,15 @@
class GoogleInitializer {
public:
typedef void (*void_function)(void);
GoogleInitializer(const char* name, void_function f) {
f();
}
using void_function = void (*)();
GoogleInitializer(const char*, void_function f) { f(); }
};
#define REGISTER_MODULE_INITIALIZER(name, body) \
namespace { \
static void google_init_module_##name () { body; } \
GoogleInitializer google_initializer_module_##name(#name, \
google_init_module_##name); \
static void google_init_module_##name() { body; } \
GoogleInitializer google_initializer_module_##name( \
#name, google_init_module_##name); \
}
#endif /* _GOOGLEINIT_H */

View File

@ -1,252 +0,0 @@
/* Copyright (c) 2007, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ---
* Author: Craig Silverstein.
*
* A simple mutex wrapper, supporting locks and read-write locks.
* You should assume the locks are *not* re-entrant.
*
* To use: you should define the following macros in your configure.ac:
* ACX_PTHREAD
* AC_RWLOCK
* The latter is defined in ../autoconf.
*
* This class is meant to be internal-only, so it's defined in the
* global namespace. If you want to expose it, you'll want to move
* it to the Google namespace.
*
* NOTE: by default, we have #ifdef'ed out the TryLock() method.
* This is for two reasons:
* 1) TryLock() under Windows is a bit annoying (it requires a
* #define to be defined very early).
* 2) TryLock() is broken for NO_THREADS mode, at least in NDEBUG
* mode.
* If you need TryLock(), and either these two caveats are not a
* problem for you, or you're willing to work around them, then
* feel free to #define GMUTEX_TRYLOCK, or to remove the #ifdefs
* in the code below.
*/
// TODO(hamaji): Probably we must provide way to ensure static mutexes are
// initialized before they are used.
// (Google3's NO_CONSTRUCTOR_NEEDED_FOR_STATIC_MUTEX)
#ifndef GOOGLE_MUTEX_H__
#define GOOGLE_MUTEX_H__
#include "config.h" // to figure out pthreads support
#include "utilities.h" // to get OS_* macro
#if defined(NO_THREADS)
typedef int MutexType; // to keep a lock-count
#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
// Needed for pthread_rwlock_*. If it causes problems, you could take it
// out, but then you'd have to unset HAVE_RWLOCK (at least on linux -- it
// *does* cause problems for FreeBSD, or MacOSX, but isn't needed
// for locking there.)
# ifdef __linux__
# define _XOPEN_SOURCE 500 // may be needed to get the rwlock calls
# endif
# include <pthread.h>
typedef pthread_rwlock_t MutexType;
#elif defined(HAVE_PTHREAD)
# include <pthread.h>
typedef pthread_mutex_t MutexType;
#elif defined(OS_WINDOWS)
# define WIN32_LEAN_AND_MEAN // We only need minimal includes
# ifdef GMUTEX_TRYLOCK
// We need Windows NT or later for TryEnterCriticalSection(). If you
// don't need that functionality, you can remove these _WIN32_WINNT
// lines, and change TryLock() to assert(0) or something.
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0400
# endif
# endif
// To avoid macro definition of ERROR.
# define NOGDI
# include <windows.h>
typedef CRITICAL_SECTION MutexType;
#else
# error Need to implement mutex.h for your architecture, or #define NO_THREADS
#endif
class Mutex {
public:
// Create a Mutex that is not held by anybody. This constructor is
// typically used for Mutexes allocated on the heap or the stack.
// See below for a recommendation for constructing global Mutex
// objects.
inline Mutex();
// Destructor
inline ~Mutex();
inline void Lock(); // Block if needed until free then acquire exclusively
inline void Unlock(); // Release a lock acquired via Lock()
#ifdef GMUTEX_TRYLOCK
inline bool TryLock(); // If free, Lock() and return true, else return false
#endif
// Note that on systems that don't support read-write locks, these may
// be implemented as synonyms to Lock() and Unlock(). So you can use
// these for efficiency, but don't use them anyplace where being able
// to do shared reads is necessary to avoid deadlock.
inline void ReaderLock(); // Block until free or shared then acquire a share
inline void ReaderUnlock(); // Release a read share of this Mutex
inline void WriterLock() { Lock(); } // Acquire an exclusive lock
inline void WriterUnlock() { Unlock(); } // Release a lock from WriterLock()
// TODO(hamaji): Do nothing, implement correctly.
inline void AssertHeld() {}
private:
MutexType mutex_;
// Catch the error of writing Mutex when intending MutexLock.
Mutex(Mutex *ignored) {}
// Disallow "evil" constructors
Mutex(const Mutex&);
void operator=(const Mutex&);
};
// Now the implementation of Mutex for various systems
#if defined(NO_THREADS)
// When we don't have threads, we can be either reading or writing,
// but not both. We can have lots of readers at once (in no-threads
// mode, that's most likely to happen in recursive function calls),
// but only one writer. We represent this by having mutex_ be -1 when
// writing and a number > 0 when reading (and 0 when no lock is held).
//
// In debug mode, we assert these invariants, while in non-debug mode
// we do nothing, for efficiency. That's why everything is in an
// assert.
#include <assert.h>
Mutex::Mutex() : mutex_(0) { }
Mutex::~Mutex() { assert(mutex_ == 0); }
void Mutex::Lock() { assert(--mutex_ == -1); }
void Mutex::Unlock() { assert(mutex_++ == -1); }
#ifdef GMUTEX_TRYLOCK
bool Mutex::TryLock() { if (mutex_) return false; Lock(); return true; }
#endif
void Mutex::ReaderLock() { assert(++mutex_ > 0); }
void Mutex::ReaderUnlock() { assert(mutex_-- > 0); }
#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
#include <stdlib.h> // for abort()
#define SAFE_PTHREAD(fncall) do { if ((fncall) != 0) abort(); } while (0)
Mutex::Mutex() { SAFE_PTHREAD(pthread_rwlock_init(&mutex_, NULL)); }
Mutex::~Mutex() { SAFE_PTHREAD(pthread_rwlock_destroy(&mutex_)); }
void Mutex::Lock() { SAFE_PTHREAD(pthread_rwlock_wrlock(&mutex_)); }
void Mutex::Unlock() { SAFE_PTHREAD(pthread_rwlock_unlock(&mutex_)); }
#ifdef GMUTEX_TRYLOCK
bool Mutex::TryLock() { return pthread_rwlock_trywrlock(&mutex_) == 0; }
#endif
void Mutex::ReaderLock() { SAFE_PTHREAD(pthread_rwlock_rdlock(&mutex_)); }
void Mutex::ReaderUnlock() { SAFE_PTHREAD(pthread_rwlock_unlock(&mutex_)); }
#undef SAFE_PTHREAD
#elif defined(HAVE_PTHREAD)
#include <stdlib.h> // for abort()
#define SAFE_PTHREAD(fncall) do { if ((fncall) != 0) abort(); } while (0)
Mutex::Mutex() { SAFE_PTHREAD(pthread_mutex_init(&mutex_, NULL)); }
Mutex::~Mutex() { SAFE_PTHREAD(pthread_mutex_destroy(&mutex_)); }
void Mutex::Lock() { SAFE_PTHREAD(pthread_mutex_lock(&mutex_)); }
void Mutex::Unlock() { SAFE_PTHREAD(pthread_mutex_unlock(&mutex_)); }
#ifdef GMUTEX_TRYLOCK
bool Mutex::TryLock() { return pthread_mutex_trylock(&mutex_) == 0; }
#endif
void Mutex::ReaderLock() { Lock(); } // we don't have read-write locks
void Mutex::ReaderUnlock() { Unlock(); }
#undef SAFE_PTHREAD
#elif defined(WIN32)
Mutex::Mutex() { InitializeCriticalSection(&mutex_); }
Mutex::~Mutex() { DeleteCriticalSection(&mutex_); }
void Mutex::Lock() { EnterCriticalSection(&mutex_); }
void Mutex::Unlock() { LeaveCriticalSection(&mutex_); }
#ifdef GMUTEX_TRYLOCK
bool Mutex::TryLock() { return TryEnterCriticalSection(&mutex_) != 0; }
#endif
void Mutex::ReaderLock() { Lock(); } // we don't have read-write locks
void Mutex::ReaderUnlock() { Unlock(); }
#endif
// --------------------------------------------------------------------------
// Some helper classes
// MutexLock(mu) acquires mu when constructed and releases it when destroyed.
class MutexLock {
public:
explicit MutexLock(Mutex *mu) : mu_(mu) { mu_->Lock(); }
~MutexLock() { mu_->Unlock(); }
private:
Mutex * const mu_;
// Disallow "evil" constructors
MutexLock(const MutexLock&);
void operator=(const MutexLock&);
};
// ReaderMutexLock and WriterMutexLock do the same, for rwlocks
class ReaderMutexLock {
public:
explicit ReaderMutexLock(Mutex *mu) : mu_(mu) { mu_->ReaderLock(); }
~ReaderMutexLock() { mu_->ReaderUnlock(); }
private:
Mutex * const mu_;
// Disallow "evil" constructors
ReaderMutexLock(const ReaderMutexLock&);
void operator=(const ReaderMutexLock&);
};
class WriterMutexLock {
public:
explicit WriterMutexLock(Mutex *mu) : mu_(mu) { mu_->WriterLock(); }
~WriterMutexLock() { mu_->WriterUnlock(); }
private:
Mutex * const mu_;
// Disallow "evil" constructors
WriterMutexLock(const WriterMutexLock&);
void operator=(const WriterMutexLock&);
};
// Catch bug where variable name is omitted, e.g. MutexLock (&mu);
#define MutexLock(x) COMPILE_ASSERT(0, mutex_lock_decl_missing_var_name)
#define ReaderMutexLock(x) COMPILE_ASSERT(0, rmutex_lock_decl_missing_var_name)
#define WriterMutexLock(x) COMPILE_ASSERT(0, wmutex_lock_decl_missing_var_name)
#endif /* #define GOOGLE_MUTEX_H__ */

View File

@ -0,0 +1,96 @@
// Copyright (c) 2024, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "base/commandlineflags.h"
#include "glog/logging.h"
#include "glog/raw_logging.h"
#include "googletest.h"
#ifdef GLOG_USE_GFLAGS
# include <gflags/gflags.h>
using namespace GFLAGS_NAMESPACE;
#endif
#ifdef HAVE_LIB_GMOCK
# include <gmock/gmock.h>
# include "mock-log.h"
// Introduce several symbols from gmock.
using google::glog_testing::ScopedMockLog;
using testing::_;
using testing::AllOf;
using testing::AnyNumber;
using testing::HasSubstr;
using testing::InitGoogleMock;
using testing::StrictMock;
using testing::StrNe;
#endif
using namespace google;
TEST(CleanImmediately, logging) {
using namespace std::chrono_literals;
google::SetLogFilenameExtension(".foobar");
google::EnableLogCleaner(0h);
for (unsigned i = 0; i < 1000; ++i) {
LOG(INFO) << "cleanup test";
}
google::DisableLogCleaner();
}
int main(int argc, char** argv) {
FLAGS_colorlogtostderr = false;
FLAGS_timestamp_in_logfile_name = true;
#ifdef GLOG_USE_GFLAGS
ParseCommandLineFlags(&argc, &argv, true);
#endif
// Make sure stderr is not buffered as stderr seems to be buffered
// on recent windows.
setbuf(stderr, nullptr);
// Test some basics before InitGoogleLogging:
CaptureTestStderr();
const string early_stderr = GetCapturedTestStderr();
EXPECT_FALSE(IsGoogleLoggingInitialized());
InitGoogleLogging(argv[0]);
EXPECT_TRUE(IsGoogleLoggingInitialized());
InitGoogleTest(&argc, argv);
#ifdef HAVE_LIB_GMOCK
InitGoogleMock(&argc, argv);
#endif
// so that death tests run before we use threads
CHECK_EQ(RUN_ALL_TESTS(), 0);
}

Some files were not shown because too many files have changed in this diff Show More