Compare commits

...

8 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
bel
3c36948269 whoops cant compile 2022-01-27 07:49:46 -07:00
bel
bc2efe928a better ntg errs 2022-01-27 07:47:55 -07:00
bel
e1b4460ebd add day to log as i can only login to ntg 30 times per week it seems 2022-01-27 07:44:30 -07:00
bel
9bb9929ff6 cant edit, but on job no more, del entry 2022-01-19 06:12:13 -07:00
bel
a6c1b8505a ew at least del image 2022-01-18 14:43:04 -07:00
bel
c755aa88fb no 2022-01-18 14:41:37 -07:00
3 changed files with 17 additions and 5 deletions

View File

@@ -228,12 +228,14 @@ func setNTGToken(token string) {
func (ntg NTGVision) search(states []config.State) (io.ReadCloser, error) {
if getNTGToken() == "" {
logtr.Debugf("NTG token is empty, refreshing ntg auth")
if err := ntg.refreshAuth(); err != nil {
return nil, err
}
}
rc, err := ntg._search(states)
if err == ErrNoAuth {
logtr.Debugf("err no auth on search, refreshing ntg auth")
if err := ntg.refreshAuth(); err != nil {
return nil, err
}
@@ -295,7 +297,11 @@ func (ntg NTGVision) _search(states []config.State) (io.ReadCloser, error) {
if resp.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(resp.Body)
resp.Body.Close()
if resp.StatusCode > 400 && resp.StatusCode < 500 && resp.StatusCode != 404 && resp.StatusCode != 410 {
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
}
return nil, fmt.Errorf("bad status searching ntg: %d: %s", resp.StatusCode, b)

View File

@@ -82,15 +82,16 @@ func SetLevel(l Level) {
}
func logf(l Level, format string, args []interface{}) {
format = fmt.Sprintf("%v: %v: %s\n", time.Now().Format("15:04:05"), l.String(), strings.TrimSpace(format))
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)
}
}

View File

@@ -350,9 +350,14 @@ func updateDeadJobs(jobs []broker.Job) error {
if err := json.Unmarshal(b, &recorded); err != nil {
return err
}
/* // TODO this beeps on fluffychat
if err := message.NewMatrix().Update(recorded.MatrixID, recorded.Job.FormatMultilineTextDead()); err != nil {
return err
}
*/
if err := message.NewMatrix().Remove(recorded.MatrixID); err != nil {
return err
}
if err := db.Set(listEntry, nil); err != nil {
return err
}