expose the time object to allow custom formatting

ref - http://bugs.activestate.com/show_bug.cgi?id=96009
This commit is contained in:
Sridhar Ratnakumar 2012-10-29 19:53:48 -07:00
parent 989b0425dc
commit 683e11c27d
1 changed files with 2 additions and 7 deletions

View File

@ -12,7 +12,7 @@ import (
type Line struct { type Line struct {
Text string Text string
UnixTime int64 Time time.Time
} }
type Config struct { type Config struct {
@ -150,7 +150,7 @@ func (tail *Tail) tailFileSync() {
if err == nil { if err == nil {
if line != nil { if line != nil {
now := getCurrentTime() now := time.Now()
if tail.MaxLineSize > 0 && len(line) > tail.MaxLineSize { if tail.MaxLineSize > 0 && len(line) > tail.MaxLineSize {
for _, line := range partitionString(string(line), tail.MaxLineSize) { for _, line := range partitionString(string(line), tail.MaxLineSize) {
tail.Lines <- &Line{line, now} tail.Lines <- &Line{line, now}
@ -213,11 +213,6 @@ func (tail *Tail) tailFileSync() {
} }
} }
// getCurrentTime returns the current time as UNIX timestamp
func getCurrentTime() int64 {
return time.Now().UTC().Unix()
}
// partitionString partitions the string into chunks of given size, // partitionString partitions the string into chunks of given size,
// with the last chunk of variable size. // with the last chunk of variable size.
func partitionString(s string, chunkSize int) []string { func partitionString(s string, chunkSize int) []string {