all: more log spam & logging consistency cleanup

Change-Id: Ibc38c2eed86e75afb064ba25ba586494c813f56c
This commit is contained in:
Brad Fitzpatrick 2018-04-22 11:19:42 -07:00
parent ab797685bf
commit a062b701c9
4 changed files with 17 additions and 8 deletions

View File

@ -78,16 +78,17 @@ var (
func Available() bool {
checkAvailability.Do(func() {
if ok, _ := strconv.ParseBool(os.Getenv("CAMLI_DISABLE_DJPEG")); ok {
log.Println("CAMLI_DISABLE_DJPEG set in environment. Disabling fastjpeg.")
log.Println("images/fastjpeg: CAMLI_DISABLE_DJPEG set in environment; disabling fastjpeg.")
return
}
if p, err := exec.LookPath(djpegBin); p != "" && err == nil {
available = true
log.Printf("fastjpeg enabled with %s.", p)
log.Printf("images/fastjpeg: fastjpeg enabled with %s.", p)
}
if !available {
log.Printf("%s not found in PATH, disabling fastjpeg.", djpegBin)
// TODO: also use Docker. https://github.com/perkeep/perkeep/issues/1106.
log.Printf("images/fastjpeg: %s not found in PATH, disabling fastjpeg.", djpegBin)
}
})

View File

@ -729,7 +729,7 @@ func (ia *importerAcct) maybeStart() {
}
go func() {
if err := lp.LongPoll(rc); err == nil {
log.Printf("Long poll for %s found an update. Starting run...", ia)
log.Printf("importer: long poll for %s found an update. Starting run...", ia)
timer.Stop()
ia.start()
} else {
@ -740,7 +740,7 @@ func (ia *importerAcct) maybeStart() {
return
}
log.Printf("Starting regular periodic import for %v", ia)
log.Printf("importer: starting periodic import for %v", ia)
go ia.start()
}

View File

@ -573,7 +573,7 @@ func (c *Corpus) scanPrefix(mu *sync.Mutex, s sorted.KeyValue, prefix string) (e
}
if logCorpusStats {
d := time.Since(t0)
c.logf("scanned prefix %q: %d rows, %v", prefix[:len(prefix)-1], n, d)
c.logf("loaded prefix %q: %d rows, %v", prefix[:len(prefix)-1], n, d)
}
return nil
}

View File

@ -22,6 +22,8 @@ import (
"encoding/json"
"log"
"net/http"
"os"
"strconv"
"sync"
"time"
@ -42,6 +44,8 @@ const (
maxMessageSize = 10 << 10
)
var debug, _ = strconv.ParseBool(os.Getenv("CAMLI_DEBUG"))
type wsHub struct {
sh *Handler
register chan *wsConn
@ -118,7 +122,9 @@ func (h *wsHub) run() {
q: wr.q,
}
wr.conn.queries[wr.tag] = wq
log.Printf("Added/updated search subscription for tag %q", wr.tag)
if debug {
log.Printf("websocket: added/updated search subscription for tag %q", wr.tag)
}
go h.doSearch(wq)
case wq := <-h.updatedResults:
@ -247,7 +253,9 @@ func (c *wsConn) readPump() {
if err != nil {
break
}
log.Printf("Got websocket message %#q", message)
if debug {
log.Printf("websocket: got message %#q", message)
}
cm := new(wsClientMessage)
if err := json.Unmarshal(message, cm); err != nil {
log.Printf("Ignoring bogus websocket message. Err: %v", err)