Skip to content

Commit

Permalink
Merge branch 'remove_src_type'
Browse files Browse the repository at this point in the history
[finishes #62648082]
  • Loading branch information
Ted Young committed Dec 19, 2013
2 parents d001fcf + 233c7d0 commit f083753
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/cf/api/log_message_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ func logMessageForBenchmark(b *testing.B, messageString string, timestamp int64)

func generateMessage(messageString string, timestamp int64) *logmessage.LogMessage {
messageType := logmessage.LogMessage_OUT
sourceType := logmessage.LogMessage_DEA
sourceName := "DEA"
return &logmessage.LogMessage{
Message: []byte(messageString),
AppId: proto.String("my-app-guid"),
MessageType: &messageType,
SourceType: &sourceType,
SourceName: &sourceName,
Timestamp: proto.Int64(timestamp),
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/cf/api/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestRecentLogsFor(t *testing.T) {
assert.NoError(t, err)

assert.Equal(t, len(dumpedMessages), 1)
assert.Equal(t, dumpedMessages[0].GetShortSourceTypeName(), expectedMessage.GetShortSourceTypeName())
assert.Equal(t, dumpedMessages[0].GetLogMessage().GetSourceName(), expectedMessage.GetLogMessage().GetSourceName())
assert.Equal(t, dumpedMessages[0].GetLogMessage().GetMessage(), expectedMessage.GetLogMessage().GetMessage())
assert.Equal(t, dumpedMessages[0].GetLogMessage().GetMessageType(), expectedMessage.GetLogMessage().GetMessageType())
}
Expand Down Expand Up @@ -261,12 +261,12 @@ func TestMessageOutputWhenFlushingAfterServerDeath(t *testing.T) {

func marshalledLogMessageWithTime(t *testing.T, messageString string, timestamp int64) []byte {
messageType := logmessage.LogMessage_OUT
sourceType := logmessage.LogMessage_DEA
sourceName := "DEA"
protoMessage := &logmessage.LogMessage{
Message: []byte(messageString),
AppId: proto.String("my-app-guid"),
MessageType: &messageType,
SourceType: &sourceType,
SourceName: &sourceName,
Timestamp: proto.Int64(timestamp),
}

Expand Down
12 changes: 5 additions & 7 deletions src/cf/commands/application/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ const (

func NewLogMessage(msgText, appGuid, sourceName string, timestamp time.Time) (msg *logmessage.Message) {
messageType := logmessage.LogMessage_ERR
sourceType := logmessage.LogMessage_UNKNOWN

logMsg := logmessage.LogMessage{
Message: []byte(msgText),
AppId: proto.String(appGuid),
MessageType: &messageType,
SourceType: &sourceType,
SourceName: proto.String(sourceName),
Timestamp: proto.Int64(timestamp.UnixNano()),
}
Expand Down Expand Up @@ -54,17 +52,17 @@ func logMessageOutput(msg *logmessage.Message) string {

func extractLogHeader(msg *logmessage.Message) (logHeader, coloredLogHeader string) {
logMsg := msg.GetLogMessage()
sourceType := msg.GetShortSourceTypeName()
sourceId := logMsg.GetSourceId()
sourceName := logMsg.GetSourceName()
sourceID := logMsg.GetSourceId()
t := time.Unix(0, logMsg.GetTimestamp())
timeFormat := TIMESTAMP_FORMAT
timeString := t.Format(timeFormat)

logHeader = fmt.Sprintf("%s [%s]", timeString, sourceType)
logHeader = fmt.Sprintf("%s [%s]", timeString, sourceName)
coloredLogHeader = terminal.LogSysHeaderColor(logHeader)

if logMsg.GetSourceType() == logmessage.LogMessage_WARDEN_CONTAINER {
logHeader = fmt.Sprintf("%s [%s/%s]", timeString, sourceType, sourceId)
if sourceName == "App" {
logHeader = fmt.Sprintf("%s [%s/%s]", timeString, sourceName, sourceID)
coloredLogHeader = terminal.LogAppHeaderColor(logHeader)
}

Expand Down
14 changes: 7 additions & 7 deletions src/cf/commands/application/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ func TestTimestampFormat(t *testing.T) {
}

func TestLogMessageOutput(t *testing.T) {
cloud_controller := logmessage.LogMessage_CLOUD_CONTROLLER
router := logmessage.LogMessage_ROUTER
uaa := logmessage.LogMessage_UAA
dea := logmessage.LogMessage_DEA
wardenContainer := logmessage.LogMessage_WARDEN_CONTAINER
cloud_controller := "API"
router := "RTR"
uaa := "UAA"
dea := "DEA"
wardenContainer := "App"

stdout := logmessage.LogMessage_OUT
stderr := logmessage.LogMessage_ERR
Expand Down Expand Up @@ -78,8 +78,8 @@ func TestLogMessageOutput(t *testing.T) {
assert.Contains(t, logMessageOutput(msg), terminal.LogStderrColor("ERR Hello World!"))
}

func createMessage(t *testing.T, protoMsg *logmessage.LogMessage, sourceType *logmessage.LogMessage_SourceType, msgType *logmessage.LogMessage_MessageType) (msg *logmessage.Message) {
protoMsg.SourceType = sourceType
func createMessage(t *testing.T, protoMsg *logmessage.LogMessage, sourceName *string, msgType *logmessage.LogMessage_MessageType) (msg *logmessage.Message) {
protoMsg.SourceName = sourceName
protoMsg.MessageType = msgType

data, err := proto.Marshal(protoMsg)
Expand Down
2 changes: 1 addition & 1 deletion src/cf/commands/application/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (cmd Start) tailStagingLogs(app cf.Application, startChan chan bool, stopCh

func (cmd Start) displayLogMessages(logChan chan *logmessage.Message) {
for msg := range logChan {
if msg.GetShortSourceTypeName() != LogMessageTypeStaging {
if msg.GetLogMessage().GetSourceName() != "STG" {
continue
}
cmd.ui.Say(simpleLogMessageOutput(msg))
Expand Down
2 changes: 1 addition & 1 deletion src/github.com/cloudfoundry/loggregatorlib

0 comments on commit f083753

Please sign in to comment.