MCPcopy Create free account
hub / github.com/android/ndk-samples / LogMessageData

Class LogMessageData

base/src/main/cpp/logging.cpp:188–221  ·  view source on GitHub ↗

This indirection greatly reduces the stack impact of having lots of checks/logging in a function.

Source from the content-addressed store, hash-verified

186// This indirection greatly reduces the stack impact of having lots of
187// checks/logging in a function.
188class LogMessageData {
189 public:
190 LogMessageData(const char* file, unsigned int line, LogSeverity severity,
191 const char* tag, int error)
192 : file_(GetFileBasename(file)),
193 line_number_(line),
194 severity_(severity),
195 tag_(tag),
196 error_(error) {}
197
198 DISALLOW_COPY_AND_ASSIGN(LogMessageData);
199
200 const char* GetFile() const { return file_; }
201
202 unsigned int GetLineNumber() const { return line_number_; }
203
204 LogSeverity GetSeverity() const { return severity_; }
205
206 const char* GetTag() const { return tag_; }
207
208 int GetError() const { return error_; }
209
210 std::ostream& GetBuffer() { return buffer_; }
211
212 std::string ToString() const { return buffer_.str(); }
213
214 private:
215 std::ostringstream buffer_;
216 const char* const file_;
217 const unsigned int line_number_;
218 const LogSeverity severity_;
219 const char* const tag_;
220 const int error_;
221};
222
223LogMessage::LogMessage(const char* file, unsigned int line, LogId,
224 LogSeverity severity, const char* tag, int error)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected