Skip to content

Commit

Permalink
fix timestamps for lambda plain text logs
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Nov 25, 2017
1 parent 4b2b961 commit 42cffcd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions platform/lambda/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package lambda

import (
"encoding/json"
"fmt"
"io"
"os"
"strings"
Expand All @@ -16,7 +15,6 @@ import (
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
"github.com/tj/go/term"

"github.com/apex/up/internal/colors"
"github.com/apex/up/internal/logs/parser"
"github.com/apex/up/internal/logs/text"
"github.com/apex/up/internal/util"
Expand Down Expand Up @@ -126,7 +124,11 @@ func (l *Logs) start() {
}

// lambda textual logs
fmt.Printf(" %s\n", colors.Gray(line))
handler.HandleLog(&log.Entry{
Timestamp: l.Timestamp,
Level: log.InfoLevel,
Message: strings.TrimRight(l.Message, " \n"),
})
}

// TODO: refactor interface to delegate
Expand Down
2 changes: 2 additions & 0 deletions platform/lambda/logs/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ func (l *Log) fetch(nextToken *string, start int64, ch chan<- *Event) (*string,

for _, event := range res.Events {
start = *event.Timestamp + 1
sec := *event.Timestamp / 1000
ch <- &Event{
Timestamp: time.Unix(sec, 0),
GroupName: l.GroupName,
Message: *event.Message,
}
Expand Down
1 change: 1 addition & 0 deletions platform/lambda/logs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

// Event is a single log event from a group.
type Event struct {
Timestamp time.Time
GroupName string
Message string
}
Expand Down

0 comments on commit 42cffcd

Please sign in to comment.