5 #ifndef V8_LOG_UTILS_H_ 6 #define V8_LOG_UTILS_H_ 12 #include "src/allocation.h" 13 #include "src/base/compiler-specific.h" 14 #include "src/base/optional.h" 15 #include "src/base/platform/mutex.h" 16 #include "src/flags.h" 17 #include "src/ostreams.h" 26 enum class LogSeparator { kSeparator };
31 Log(
Logger* log,
const char* log_file_name);
33 void stop() { is_stopped_ =
true; }
35 static bool InitLogAtStart() {
36 return FLAG_log || FLAG_log_api || FLAG_log_code || FLAG_log_handles ||
37 FLAG_log_suspect || FLAG_ll_prof || FLAG_perf_basic_prof ||
38 FLAG_perf_prof || FLAG_log_source_code || FLAG_gdbjit ||
39 FLAG_log_internal_timer_events || FLAG_prof_cpp || FLAG_trace_ic ||
40 FLAG_log_function_events;
49 bool IsEnabled() {
return !is_stopped_ && output_handle_ !=
nullptr; }
52 static const int kMessageBufferSize = 2048;
56 static const char*
const kLogToTemporaryFile;
57 static const char*
const kLogToConsole;
68 void AppendString(
String str,
71 void AppendString(
const char* str);
72 void AppendString(
const char* str,
size_t length);
73 void PRINTF_FORMAT(2, 3) AppendFormatString(
const char* format, ...);
74 void AppendCharacter(
char c);
75 void AppendSymbolName(
Symbol symbol);
86 void WriteToLogFile();
91 int PRINTF_FORMAT(2, 0)
92 FormatStringIntoBuffer(
const char* format, va_list args);
94 void AppendSymbolNameDetails(
String str,
bool show_impl_info);
96 void PRINTF_FORMAT(2, 3) AppendRawFormatString(
const char* format, ...);
97 void AppendRawCharacter(
const char character);
100 base::MutexGuard lock_guard_;
104 static FILE* CreateOutputHandle(
const char* file_name);
107 int WriteToFile(
const char* msg,
int length) {
108 DCHECK_NOT_NULL(output_handle_);
109 os_.write(msg, length);
119 FILE* output_handle_;
128 char* format_buffer_;
136 Log::MessageBuilder& Log::MessageBuilder::operator<<<LogSeparator>(
137 LogSeparator separator);
139 Log::MessageBuilder& Log::MessageBuilder::operator<<<void*>(
void* pointer);
141 Log::MessageBuilder& Log::MessageBuilder::operator<<<const char*>(
144 Log::MessageBuilder& Log::MessageBuilder::operator<<<char>(
char c);
146 Log::MessageBuilder& Log::MessageBuilder::operator<<<String>(
String string);
148 Log::MessageBuilder& Log::MessageBuilder::operator<<<Symbol>(
Symbol symbol);
150 Log::MessageBuilder& Log::MessageBuilder::operator<<<Name>(
Name name);
155 #endif // V8_LOG_UTILS_H_