Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Unified Diff: services/log/log_impl.cc

Issue 1928613002: Simplify LogImpl a bit. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/log/log_impl.h ('k') | services/log/log_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/log/log_impl.cc
diff --git a/services/log/log_impl.cc b/services/log/log_impl.cc
index 2388882ddc1f7f1a5875030ddc4fcb55d8df559f..b02459fa500fc6633dd75db08d9d69f106d345df 100644
--- a/services/log/log_impl.cc
+++ b/services/log/log_impl.cc
@@ -4,8 +4,6 @@
#include "services/log/log_impl.h"
-#include <stdio.h>
-
#include <utility>
#include "base/logging.h"
@@ -41,19 +39,19 @@ std::string LogLevelToString(int32_t log_level) {
LogImpl::LogImpl(const std::string& remote_url,
InterfaceRequest<Log> request,
- FILE* out_file)
+ PrintLogMessageFunction print_log_message_function)
: remote_url_(remote_url),
binding_(this, std::move(request)),
- out_file_(out_file) {}
+ print_log_message_function_(print_log_message_function) {}
LogImpl::~LogImpl() {}
// static
void LogImpl::Create(ApplicationConnection* connection,
InterfaceRequest<Log> request,
- FILE* out_file) {
+ PrintLogMessageFunction print_log_message_function) {
DCHECK(connection);
- DCHECK(out_file);
+ DCHECK(print_log_message_function);
const std::string& remote_url = connection->GetRemoteApplicationURL();
if (remote_url.empty()) {
@@ -61,15 +59,13 @@ void LogImpl::Create(ApplicationConnection* connection,
return;
}
- new LogImpl(remote_url, std::move(request), out_file);
+ new LogImpl(remote_url, std::move(request),
+ std::move(print_log_message_function));
}
void LogImpl::AddEntry(EntryPtr entry) {
DCHECK(entry);
-
- // In order to keep LogImpl thread-safe (for the future), we should only print
- // one thing here (otherwise, it could interleave with other prints).
- fprintf(out_file_, "%s\n", FormatEntry(entry).c_str());
+ print_log_message_function_(FormatEntry(entry));
}
// This should return:
« no previous file with comments | « services/log/log_impl.h ('k') | services/log/log_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698