fix log FATAL
This commit is contained in:
parent
ea3dfc9ca8
commit
54a52c2faa
@ -7,6 +7,7 @@ set(tile_VERSION_BUILD $ENV{CI_STEP_NUMBER})
|
||||
if (NOT tile_VERSION_BUILD)
|
||||
set(tile_VERSION_BUILD "0")
|
||||
endif()
|
||||
set(TILE_VERSION "${tile_VERSION_MAJOR}.${tile_VERSION_MINOR}.${tile_VERSION_PATCH}.${tile_VERSION_BUILD}")
|
||||
project(
|
||||
tile
|
||||
VERSION "${tile_VERSION_MAJOR}.${tile_VERSION_MINOR}.${tile_VERSION_PATCH}"
|
||||
|
@ -20,7 +20,7 @@
|
||||
#define TILE_SYSTEM_PROCESSOR "@CMAKE_SYSTEM_PROCESSOR@"
|
||||
#define TILE_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@"
|
||||
#define TILE_SYSTEM_VERSION "@CMAKE_SYSTEM_VERSION@"
|
||||
#define TILE_VERSION "@PROJECT_VERSOIN@"
|
||||
#define TILE_VERSION "@TILE_VERSION@"
|
||||
|
||||
// clang-format on
|
||||
|
||||
|
@ -146,6 +146,7 @@ private:
|
||||
}
|
||||
}
|
||||
void SendToLog() {
|
||||
ColoredWriteToStdout(severity_, message_text_, num_chars_to_log_);
|
||||
LogToSinks(severity_, fullname(), basename(), line(), time(),
|
||||
message_text_ + num_prefix_chars_,
|
||||
num_chars_to_log_ - num_prefix_chars_ - 1);
|
||||
@ -280,6 +281,25 @@ std::string LogSink::ToString(LogSeverity severity, const char *file, int line,
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
static void ColoredWriteToStderrOrStdout(FILE *output, LogSeverity severity,
|
||||
const char *message, size_t len) {
|
||||
fwrite(message, len, 1, output);
|
||||
fflush(output);
|
||||
}
|
||||
|
||||
void ColoredWriteToStdout(LogSeverity severity, const char *message,
|
||||
size_t len) {
|
||||
FILE *output = stdout;
|
||||
if (severity >= TILE_FATAL) {
|
||||
output = stderr;
|
||||
}
|
||||
ColoredWriteToStderrOrStdout(output, severity, message, len);
|
||||
}
|
||||
void ColoredWriteToStderr(LogSeverity severity, const char *message,
|
||||
size_t len) {
|
||||
ColoredWriteToStderrOrStdout(stderr, severity, message, len);
|
||||
}
|
||||
|
||||
void AddLogSink(LogSink *dest) {
|
||||
std::lock_guard<std::mutex> _(g_sink_mutex);
|
||||
g_sinks.insert(dest);
|
||||
|
@ -706,6 +706,10 @@ public:
|
||||
size_t message_len);
|
||||
};
|
||||
|
||||
void ColoredWriteToStdout(LogSeverity severity, const char *message,
|
||||
size_t len);
|
||||
void ColoredWriteToStderr(LogSeverity severity, const char *message,
|
||||
size_t len);
|
||||
void AddLogSink(LogSink *dest);
|
||||
void RemoveLogSink(LogSink *dest);
|
||||
void SetStderrLogging(LogSeverity min_severity);
|
||||
|
0
tile/base/internal/sinks/splitter_sink.h
Normal file
0
tile/base/internal/sinks/splitter_sink.h
Normal file
Loading…
Reference in New Issue
Block a user