Compare commits

...

2 Commits

Author SHA1 Message Date
bel
a127d9fd25 no newline in log 2022-01-27 08:16:20 -07:00
bel
8c6b55301d moer logging 2022-01-27 08:13:32 -07:00
2 changed files with 7 additions and 4 deletions

View File

@@ -297,7 +297,9 @@ func (ntg NTGVision) _search(states []config.State) (io.ReadCloser, error) {
if resp.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(resp.Body)
resp.Body.Close()
logtr.Debugf("ntg auth bad status: url=%s, status=%v, body=%s", request.URL.String(), resp.StatusCode, b)
request2, _ := ntg.newRequest(states)
requestb, _ := ioutil.ReadAll(request2.Body)
logtr.Debugf("ntg auth bad status: url=%s, status=%v, body=%s, headers=%+v, request=%+v, requestb=%s", request.URL.String(), resp.StatusCode, b, resp.Header, request2, requestb)
if resp.StatusCode > 400 && resp.StatusCode < 404 {
logtr.Debugf("ntg auth bad status: err no auth")
return nil, ErrNoAuth

View File

@@ -83,14 +83,15 @@ func SetLevel(l Level) {
func logf(l Level, format string, args []interface{}) {
format = fmt.Sprintf("%v: %v: %s\n", time.Now().Format("01-02T15:04:05"), l.String(), strings.TrimSpace(format))
logContent := strings.ReplaceAll(fmt.Sprintf(format, args...), "\n", "") + "\n"
cLevel := level
cAnsoser := ansoser
if l >= cLevel {
fmt.Fprintf(os.Stderr, format, args...)
fmt.Fprint(os.Stderr, logContent)
}
fmt.Fprintf(logger, format, args...)
fmt.Fprint(logger, logContent)
if l == SOS && cAnsoser != nil {
if err := cAnsoser.Send(fmt.Sprintf(format, args...)); err != nil {
if err := cAnsoser.Send(logContent); err != nil {
Errorf("failed to SOS: %v", err)
}
}