Commit 1385d6a0 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Hook up logging between tts service library and Chrome

R=dmazzoni@chromium.org, rni@google.com

Change-Id: Id876d13aa592850ea5a771cfe66da80aafbe6d0e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2230932
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776241}
parent 0f4c62e4
...@@ -42,6 +42,7 @@ generate_library_loader("libchrometts") { ...@@ -42,6 +42,7 @@ generate_library_loader("libchrometts") {
bundled_header = "\"chromeos/services/tts/chrome_tts.h\"" bundled_header = "\"chromeos/services/tts/chrome_tts.h\""
functions = [ functions = [
"GoogleTtsSetLogger",
"GoogleTtsInit", "GoogleTtsInit",
"GoogleTtsShutdown", "GoogleTtsShutdown",
"GoogleTtsInstallVoice", "GoogleTtsInstallVoice",
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
void GoogleTtsSetLogger(void (*logger_func)(int severity, const char* message));
bool GoogleTtsInit(const char* pipeline_path, const char* path_prefix); bool GoogleTtsInit(const char* pipeline_path, const char* path_prefix);
void GoogleTtsShutdown(); void GoogleTtsShutdown();
......
...@@ -12,6 +12,23 @@ ...@@ -12,6 +12,23 @@
namespace chromeos { namespace chromeos {
namespace tts { namespace tts {
// Simple helper to bridge logging in the shared library to Chrome's logging.
void HandleLibraryLogging(int severity, const char* message) {
switch (severity) {
case logging::LOG_INFO:
// Suppressed.
break;
case logging::LOG_WARNING:
LOG(WARNING) << message;
break;
case logging::LOG_ERROR:
LOG(ERROR) << message;
break;
default:
break;
}
}
// TtsService is mostly glue code that adapts the TtsStream interface into a // TtsService is mostly glue code that adapts the TtsStream interface into a
// form needed by libchrometts.so. As is convention with shared objects, the // form needed by libchrometts.so. As is convention with shared objects, the
// lifetime of all arguments passed to the library is scoped to the function. // lifetime of all arguments passed to the library is scoped to the function.
...@@ -24,6 +41,8 @@ TtsService::TtsService(mojo::PendingReceiver<mojom::TtsService> receiver) ...@@ -24,6 +41,8 @@ TtsService::TtsService(mojo::PendingReceiver<mojom::TtsService> receiver)
bool loaded = libchrometts_.Load(kLibchromettsPath); bool loaded = libchrometts_.Load(kLibchromettsPath);
if (!loaded) if (!loaded)
LOG(ERROR) << "Unable to load libchrometts.so: " << dlerror(); LOG(ERROR) << "Unable to load libchrometts.so: " << dlerror();
else
libchrometts_.GoogleTtsSetLogger(HandleLibraryLogging);
} }
TtsService::~TtsService() = default; TtsService::~TtsService() = default;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment