mirror of https://bitbucket.org/ausocean/av.git
Improving logging
This commit is contained in:
parent
683bb923cb
commit
adc62a6442
|
@ -135,7 +135,6 @@ func (m *broadcastManager) recv(w http.ResponseWriter, r *http.Request) {
|
|||
done := m.dogNotifier.handlerInvoked("recv")
|
||||
defer done()
|
||||
|
||||
m.log.Debug("recv handler")
|
||||
q := r.URL.Query()
|
||||
ma := MAC(q.Get("ma"))
|
||||
|
||||
|
@ -304,16 +303,15 @@ func (m *broadcastManager) createOrUpdate(broadcast Broadcast) error {
|
|||
}
|
||||
|
||||
switch broadcast.status {
|
||||
case statusCreate:
|
||||
fallthrough
|
||||
case statusActive, statusPlay:
|
||||
case statusActive, statusPlay, statusCreate:
|
||||
m.log.Info("updating configuration for mac","mac",broadcast.mac)
|
||||
signal, ok := m.slateExitSignals[broadcast.mac]
|
||||
if ok {
|
||||
close(signal)
|
||||
delete(m.slateExitSignals, broadcast.mac)
|
||||
}
|
||||
case statusSlate:
|
||||
m.log.Debug("slate request")
|
||||
m.log.Info("slate request")
|
||||
// If there's a signal channel it means that we're already writing the slate
|
||||
// image and theres nothing to do, so return.
|
||||
_, ok := m.slateExitSignals[broadcast.mac]
|
||||
|
@ -382,5 +380,6 @@ func main() {
|
|||
|
||||
go m.dogNotifier.notify()
|
||||
|
||||
log.Info("listening", "host", *host, "port", *port)
|
||||
http.ListenAndServe(*host+":"+*port, nil)
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ LICENSE
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"sync"
|
||||
|
@ -132,6 +131,7 @@ func (n *watchdogNotifier) notify() {
|
|||
|
||||
// If this fails for any reason it indicates a systemd service configuration
|
||||
// issue, and therefore programmer error, so do fatal log to cause crash.
|
||||
n.log.Debug("notifying watchdog")
|
||||
supported, err := daemon.SdNotify(false, daemon.SdNotifyWatchdog)
|
||||
if err != nil {
|
||||
n.log.Fatal("error from systemd watchdog notify", "error", err)
|
||||
|
@ -167,6 +167,7 @@ func (n *watchdogNotifier) handlersUnhealthy() bool {
|
|||
func (n *watchdogNotifier) handlerInvoked(name string) func() {
|
||||
n.mu.Lock()
|
||||
defer n.mu.Unlock()
|
||||
n.log.Info("handler invoked", "name", name)
|
||||
|
||||
id := n.curId
|
||||
n.curId++
|
||||
|
@ -175,9 +176,10 @@ func (n *watchdogNotifier) handlerInvoked(name string) func() {
|
|||
return func() {
|
||||
n.mu.Lock()
|
||||
defer n.mu.Unlock()
|
||||
n.log.Info("handler done", "name", name)
|
||||
|
||||
if _, ok := n.activeHandlers[id]; !ok {
|
||||
log.Fatal("handler id not in map", "name", name)
|
||||
n.log.Fatal("handler id not in map", "name", name)
|
||||
}
|
||||
|
||||
delete(n.activeHandlers, id)
|
||||
|
|
Loading…
Reference in New Issue