From 41562cbdd3acfdab401e0c96452a5e0f4e45cdea Mon Sep 17 00:00:00 2001 From: Yoshida Hiroshi Date: Wed, 24 Jan 2024 12:53:40 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E3=83=A1=E3=83=83?= =?UTF-8?q?=E3=82=BB=E3=83=BC=E3=82=B8=E9=80=81=E4=BF=A1=E6=99=82=E3=81=AE?= =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E3=82=92=E3=83=AD=E3=82=B0=E3=81=AB?= =?UTF-8?q?=E5=87=BA=E5=8A=9B=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- amazon_transcribe_handler.go | 9 ++++++--- speech_to_text_handler.go | 9 ++++++--- test_handler.go | 20 ++++++++++++++------ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/amazon_transcribe_handler.go b/amazon_transcribe_handler.go index 705b15b..fe6866c 100644 --- a/amazon_transcribe_handler.go +++ b/amazon_transcribe_handler.go @@ -103,9 +103,12 @@ func (h *AmazonTranscribeHandler) Handle(ctx context.Context, reader io.Reader) case *transcribestreamingservice.TranscriptEvent: if h.OnResultFunc != nil { if err := h.OnResultFunc(ctx, w, h.ChannelID, h.ConnectionID, h.LanguageCode, e.Transcript.Results); err != nil { - errResponse := NewSuzuErrorResponse(err.Error()) - if err := encoder.Encode(errResponse); err != nil { - // TODO: ログを書く + if err := encoder.Encode(NewSuzuErrorResponse(err.Error())); err != nil { + zlog.Error(). + Err(err). + Str("channel_id", h.ChannelID). + Str("connection_id", h.ConnectionID). + Send() } w.CloseWithError(err) return diff --git a/speech_to_text_handler.go b/speech_to_text_handler.go index 7fbe192..5681390 100644 --- a/speech_to_text_handler.go +++ b/speech_to_text_handler.go @@ -144,9 +144,12 @@ func (h *SpeechToTextHandler) Handle(ctx context.Context, reader io.Reader) (*io if h.OnResultFunc != nil { if err := h.OnResultFunc(ctx, w, h.ChannelID, h.ConnectionID, h.LanguageCode, resp.Results); err != nil { - errResponse := NewSuzuErrorResponse(err.Error()) - if err := encoder.Encode(errResponse); err != nil { - // TODO: ログを書く + if err := encoder.Encode(NewSuzuErrorResponse(err.Error())); err != nil { + zlog.Error(). + Err(err). + Str("channel_id", h.ChannelID). + Str("connection_id", h.ConnectionID). + Send() } w.CloseWithError(err) return diff --git a/test_handler.go b/test_handler.go index 4b143fe..15fc137 100644 --- a/test_handler.go +++ b/test_handler.go @@ -5,6 +5,8 @@ import ( "encoding/json" "fmt" "io" + + zlog "github.com/rs/zerolog/log" ) func init() { @@ -61,9 +63,12 @@ func (h *TestHandler) Handle(ctx context.Context, reader io.Reader) (*io.PipeRea n, err := reader.Read(buf) if err != nil { if err != io.EOF { - errResponse := NewSuzuErrorResponse(err.Error()) - if err := encoder.Encode(errResponse); err != nil { - // TODO: ログを書く + if err := encoder.Encode(NewSuzuErrorResponse(err.Error())); err != nil { + zlog.Error(). + Err(err). + Str("channel_id", h.ChannelID). + Str("connection_id", h.ConnectionID). + Send() } } w.CloseWithError(err) @@ -77,9 +82,12 @@ func (h *TestHandler) Handle(ctx context.Context, reader io.Reader) (*io.PipeRea if h.OnResultFunc != nil { if err := h.OnResultFunc(ctx, w, h.ChannelID, h.ConnectionID, h.LanguageCode, result); err != nil { - errResponse := NewSuzuErrorResponse(err.Error()) - if err := encoder.Encode(errResponse); err != nil { - // TODO: ログを書く + if err := encoder.Encode(NewSuzuErrorResponse(err.Error())); err != nil { + zlog.Error(). + Err(err). + Str("channel_id", h.ChannelID). + Str("connection_id", h.ConnectionID). + Send() } w.CloseWithError(err) return