@@ -131,8 +131,15 @@ Log::MaskType Log::GetMask() const {
131
131
return m_mask.load (std::memory_order_relaxed);
132
132
}
133
133
134
- void Log::PutCString (const char *cstr) { Printf (" %s" , cstr); }
135
- void Log::PutString (llvm::StringRef str) { PutCString (str.str ().c_str ()); }
134
+ void Log::PutCString (const char *cstr) { PutString (cstr); }
135
+
136
+ void Log::PutString (llvm::StringRef str) {
137
+ std::string FinalMessage;
138
+ llvm::raw_string_ostream Stream (FinalMessage);
139
+ WriteHeader (Stream, " " , " " );
140
+ Stream << str << " \n " ;
141
+ WriteMessage (FinalMessage);
142
+ }
136
143
137
144
// Simple variable argument logging with flags.
138
145
void Log::Printf (const char *format, ...) {
@@ -142,20 +149,10 @@ void Log::Printf(const char *format, ...) {
142
149
va_end (args);
143
150
}
144
151
145
- // All logging eventually boils down to this function call. If we have a
146
- // callback registered, then we call the logging callback. If we have a valid
147
- // file handle, we also log to the file.
148
152
void Log::VAPrintf (const char *format, va_list args) {
149
- std::string FinalMessage;
150
- llvm::raw_string_ostream Stream (FinalMessage);
151
- WriteHeader (Stream, " " , " " );
152
-
153
153
llvm::SmallString<64 > Content;
154
154
lldb_private::VASprintf (Content, format, args);
155
-
156
- Stream << Content << " \n " ;
157
-
158
- WriteMessage (FinalMessage);
155
+ PutString (Content);
159
156
}
160
157
161
158
// Printing of errors that are not fatal.
@@ -344,6 +341,8 @@ void Log::WriteHeader(llvm::raw_ostream &OS, llvm::StringRef file,
344
341
}
345
342
}
346
343
344
+ // If we have a callback registered, then we call the logging callback. If we
345
+ // have a valid file handle, we also log to the file.
347
346
void Log::WriteMessage (llvm::StringRef message) {
348
347
// Make a copy of our stream shared pointer in case someone disables our log
349
348
// while we are logging and releases the stream
0 commit comments