Browse Source

add timestamp and change untagged -> untag

Victor Vieux 12 years ago
parent
commit
b8d52ec266
2 changed files with 7 additions and 2 deletions
  1. 3 2
      server.go
  2. 4 0
      utils/utils.go

+ 3 - 2
server.go

@@ -19,6 +19,7 @@ import (
 	"runtime"
 	"runtime"
 	"strings"
 	"strings"
 	"sync"
 	"sync"
+	"time"
 )
 )
 
 
 func (srv *Server) DockerVersion() APIVersion {
 func (srv *Server) DockerVersion() APIVersion {
@@ -953,7 +954,7 @@ func (srv *Server) deleteImage(img *Image, repoName, tag string) ([]APIRmi, erro
 	}
 	}
 	if tagDeleted {
 	if tagDeleted {
 		imgs = append(imgs, APIRmi{Untagged: img.ShortID()})
 		imgs = append(imgs, APIRmi{Untagged: img.ShortID()})
-		srv.SendEvent("untagged", img.ShortID())
+		srv.SendEvent("untag", img.ShortID())
 	}
 	}
 	if len(srv.runtime.repositories.ByID()[img.ID]) == 0 {
 	if len(srv.runtime.repositories.ByID()[img.ID]) == 0 {
 		if err := srv.deleteImageAndChildren(img.ID, &imgs); err != nil {
 		if err := srv.deleteImageAndChildren(img.ID, &imgs); err != nil {
@@ -1180,7 +1181,7 @@ func NewServer(flGraphPath string, autoRestart, enableCors bool, dns ListOpts) (
 
 
 func (srv *Server) SendEvent(action, id string) {
 func (srv *Server) SendEvent(action, id string) {
 	for _, c := range srv.events {
 	for _, c := range srv.events {
-		c <- utils.JSONMessage{Status: action, ID: id}
+		c <- utils.JSONMessage{Status: action, ID: id, Time: time.Now().Unix()}
 	}
 	}
 }
 }
 
 

+ 4 - 0
utils/utils.go

@@ -612,9 +612,13 @@ type JSONMessage struct {
 	Progress string `json:"progress,omitempty"`
 	Progress string `json:"progress,omitempty"`
 	Error    string `json:"error,omitempty"`
 	Error    string `json:"error,omitempty"`
 	ID	 string `json:"id,omitempty"`
 	ID	 string `json:"id,omitempty"`
+	Time	 int64 `json:"time,omitempty"`
 }
 }
 
 
 func (jm *JSONMessage) Display(out io.Writer) (error) {
 func (jm *JSONMessage) Display(out io.Writer) (error) {
+	if jm.Time != 0 {
+		fmt.Fprintf(out, "[%s] ", time.Unix(jm.Time, 0))
+	}
 	if jm.Progress != "" {
 	if jm.Progress != "" {
 		fmt.Fprintf(out, "%s %s\r", jm.Status, jm.Progress)
 		fmt.Fprintf(out, "%s %s\r", jm.Status, jm.Progress)
 	} else if jm.Error != "" {
 	} else if jm.Error != "" {