package main

import (
	"fmt"

	log "github.com/Sirupsen/logrus"
	"github.com/ehazlett/interlock/plugins"
	"github.com/samalba/dockerclient"
)

type (
	EventHandler struct {
		Manager *Manager
	}
)

func NewEventHandler(mgr *Manager) *EventHandler {
	return &EventHandler{
		Manager: mgr,
	}
}

func (l *EventHandler) Handle(e *dockerclient.Event, ec chan error, args ...interface{}) {
	plugins.Log("interlock", log.DebugLevel,
		fmt.Sprintf("event: date=%d type=%s image=%s container=%s", e.Time, e.Status, e.From, e.Id[:12]))

	go plugins.DispatchEvent(l.Manager.Config, l.Manager.Client, e, ec)
}

package main

import (
	"fmt"

	log "github.com/Sirupsen/logrus"
	"github.com/ehazlett/interlock/plugins"
	"github.com/samalba/dockerclient"
)

type (
	EventHandler struct {
		Manager *Manager
	}
)

func NewEventHandler(mgr *Manager) *EventHandler {
	return &EventHandler{
		Manager: mgr,
	}
}

func (l *EventHandler) Handle(e *dockerclient.Event, ec chan error, args ...interface{}) {
	plugins.Log("interlock", log.DebugLevel,
		fmt.Sprintf("event: date=%d type=%s image=%s container=%s", e.Time, e.Status, e.From, e.Id))

	go plugins.DispatchEvent(l.Manager.Config, l.Manager.Client, e, ec)
}

Fix crash when event Id is less than 12 chars
Fix crash when event Id is less than 12 chars

Was sometimes getting "slice bounds out of range".

May as well print out the whole thing in debug mode. This is
sometimes names instead of IDs depending on the event.

Signed-off-by: Ben Firshman <73675debcd8a436be48ec22211dcf44fe0df0a64@firshman.co.uk>
