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