Skip to content

Commit

Permalink
Merge pull request #11 from mundipagg/fix/change-readall
Browse files Browse the repository at this point in the history
[BPROC-253] ♻️ change function
  • Loading branch information
Leonardo Jasmim authored Oct 27, 2021
2 parents 086db27 + 9367b8c commit 64b6490
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions seq.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import (
"bytes"
"errors"
"fmt"
"github.com/json-iterator/go"
"github.com/mralves/tracer"
"github.com/mundipagg/tracer-seq-writer/buffer"
"github.com/mundipagg/tracer-seq-writer/json"
"github.com/mundipagg/tracer-seq-writer/strings"
"io"
"net/http"
"os"
"regexp"
str "strings"
"sync"
"time"

jsoniter "github.com/json-iterator/go"
"github.com/mralves/tracer"
"github.com/mundipagg/tracer-seq-writer/buffer"
"github.com/mundipagg/tracer-seq-writer/json"
"github.com/mundipagg/tracer-seq-writer/strings"
)

type Writer struct {
Expand Down Expand Up @@ -108,12 +110,13 @@ func (sw *Writer) send(events []interface{}) error {
}
defer response.Body.Close()
if response.StatusCode != 201 {
bodyBytes, err := io.ReadAll(response.Body)
buffer := new(str.Builder)
_, err := io.Copy(buffer, response.Body)
if err != nil {
stderr("ERROR PARSER SEQ RESPONSE %s", err)
}

stderr("COULD NOT SEND LOG TO SEQ BECAUSE %v; request: %s; response: %s", response.Status, string(body), string(bodyBytes))
stderr("COULD NOT SEND LOG TO SEQ BECAUSE %v; request: %s; response: %s", response.Status, string(body), buffer.String())
return errors.New(fmt.Sprintf("request returned %v", response.StatusCode))
}
return nil
Expand Down

0 comments on commit 64b6490

Please sign in to comment.