| Index: services/log/log_impl.h
|
| diff --git a/services/log/log_impl.h b/services/log/log_impl.h
|
| index 28a5782e283af8dc25f9aa2401d0791125dce4da..6a94ef29d9e3b519408d3abdb61cb361e35741c8 100644
|
| --- a/services/log/log_impl.h
|
| +++ b/services/log/log_impl.h
|
| @@ -5,8 +5,7 @@
|
| #ifndef SERVICES_LOG_LOG_IMPL_H_
|
| #define SERVICES_LOG_LOG_IMPL_H_
|
|
|
| -#include <stdio.h>
|
| -
|
| +#include <functional>
|
| #include <string>
|
|
|
| #include "base/macros.h"
|
| @@ -22,19 +21,22 @@ class ApplicationConnection;
|
| namespace log {
|
|
|
| // This is an implementation of the log service
|
| -// (see mojo/services/log/interfaces/log.mojom). It formats incoming messages
|
| -// and writes them to the supplied FILE stream. It does not take ownership of
|
| -// the FILE stream.
|
| +// (see mojo/services/log/interfaces/log.mojom). It formats incoming messages
|
| +// and "prints" them using a supplied function.
|
| //
|
| // This service implementation binds a new Log implementation for each incoming
|
| // application connection.
|
| class LogImpl : public Log {
|
| public:
|
| - // LogImpl does not take ownership of |out_file|, so |out_file| must live for
|
| - // the duration of the incoming connection (which is left undefined).
|
| + // Function that prints the given (fully-formatted) log message.
|
| + using PrintLogMessageFunction =
|
| + std::function<void(const std::string& message)>;
|
| +
|
| + // Note that |print_log_message_function| may be called many times, for the
|
| + // lifetime of the created object.
|
| static void Create(ApplicationConnection* connection,
|
| InterfaceRequest<Log> request,
|
| - FILE* out_file);
|
| + PrintLogMessageFunction print_log_message_function);
|
|
|
| // |Log| implementation:
|
| void AddEntry(EntryPtr entry) override;
|
| @@ -42,14 +44,14 @@ class LogImpl : public Log {
|
| private:
|
| LogImpl(const std::string& remote_url,
|
| InterfaceRequest<Log> request,
|
| - FILE* out_file);
|
| + PrintLogMessageFunction print_log_message_function);
|
| ~LogImpl() override;
|
|
|
| std::string FormatEntry(const EntryPtr& entry);
|
|
|
| const std::string remote_url_;
|
| StrongBinding<Log> binding_;
|
| - FILE* out_file_;
|
| + const PrintLogMessageFunction print_log_message_function_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(LogImpl);
|
| };
|
|
|