-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This should address a weird segmentation fault issue we have seen during logging shutdown with older versions of the glog library. I'm also disabling symlinks with SetLogSymlink(), to prevent the duplicate "UNKNOWN.INFO" logfile. Doing so also helps with FreeBSD, because there was an issue with std::filesystem::remove_all (used in our unit test) which was fixed only recently, causing it to error out due to the dangling symlinks: llvm/llvm-project#79540 Bug: b/352597329 Change-Id: Ie4faf2740e8eabc7f9dda9127f571084f1a510b3
- Loading branch information
Showing
2 changed files
with
22 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ void GrpcLog(gpr_log_func_args* args) { | |
// Map gRPC severities to glog severities. | ||
// gRPC severities: ERROR, INFO, DEBUG | ||
// glog severities: FATAL, ERROR, WARNING, INFO | ||
int severity; | ||
google::LogSeverity severity; | ||
switch (args->severity) { | ||
// gRPC ERROR -> glog WARNING. gRPC errors aren't necessarily errors for | ||
// us; see e.g. https://github.com/grpc/grpc/issues/22613. We should emit | ||
|
@@ -61,7 +61,7 @@ void GrpcLog(gpr_log_func_args* args) { | |
class GlogSink : public absl::LogSink { | ||
public: | ||
virtual void Send(const absl::LogEntry& entry) override { | ||
int severity; | ||
google::LogSeverity severity; | ||
switch (entry.log_severity()) { | ||
case absl::LogSeverity::kError: | ||
severity = google::GLOG_ERROR; | ||
|
@@ -108,25 +108,33 @@ absl::Status InitializeLogging(std::string_view output_directory, | |
{google::GLOG_INFO, google::GLOG_WARNING, google::GLOG_ERROR, | ||
google::GLOG_FATAL}) { | ||
google::SetLogDestination(severity, ""); | ||
google::SetLogSymlink(severity, ""); | ||
} | ||
} else { | ||
// FATAL logs crash the program; emit these to standard error as well. | ||
google::SetStderrLogging(google::GLOG_FATAL); | ||
|
||
google::SetLogDestination( | ||
google::GLOG_INFO, | ||
absl::StrCat(output_directory, "/libkmsp11.log-").c_str()); | ||
if (!output_filename_suffix.empty()) { | ||
google::SetLogDestination( | ||
google::GLOG_INFO, absl::StrCat(output_directory, "/libkmsp11.log-", | ||
output_filename_suffix, "-") | ||
.c_str()); | ||
} else { | ||
google::SetLogDestination( | ||
google::GLOG_INFO, | ||
absl::StrCat(output_directory, "/libkmsp11.log-").c_str()); | ||
} | ||
|
||
// Disable symlink creation, which causes removal issues on FreeBSD. | ||
// https://www.mail-archive.com/[email protected]/msg79713.html | ||
google::SetLogSymlink(google::GLOG_INFO, ""); | ||
|
||
// Disable discrete log files for all levels but INFO -- they all still | ||
// get logged to the INFO logfile. | ||
for (google::LogSeverity severity : | ||
{google::GLOG_WARNING, google::GLOG_ERROR, google::GLOG_FATAL}) { | ||
google::SetLogDestination(severity, ""); | ||
} | ||
|
||
if (!output_filename_suffix.empty()) { | ||
google::SetLogFilenameExtension( | ||
absl::StrCat(output_filename_suffix, "-").c_str()); | ||
google::SetLogSymlink(severity, ""); | ||
} | ||
} | ||
|
||
|