Skip to content

Commit

Permalink
(Closed #8) Added -with-time option
Browse files Browse the repository at this point in the history
  • Loading branch information
hahwul committed Feb 8, 2021
1 parent e888d3b commit 3b48149
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
10 changes: 6 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func main() {
appendOption := flag.Bool("append", false, "Append mode for files")
chunkedLineOption := flag.Int("chunked", 0, "Chuked files from line (e.g output / output_1 / output_2)")
withLineOption := flag.Bool("with-line", false, "With line number")
withTimeOption := flag.Bool("with-time", false, "With timestamp")
flag.Parse()

// Show version
Expand All @@ -35,10 +36,11 @@ func main() {

// Set Options
options := model.Options{
Files: files,
Append: *appendOption,
ChunkedLine: *chunkedLineOption,
WithLine: *withLineOption,
Files: files,
Append: *appendOption,
ChunkedLine: *chunkedLineOption,
WithLine: *withLineOption,
WithTimestamp: *withTimeOption,
}

// Running gee app
Expand Down
3 changes: 3 additions & 0 deletions pkg/gee/gee.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ func Gee(options model.Options) {
if options.WithLine {
l = "[" + strconv.Itoa(stdLine) + "] " + l
}
if options.WithTimestamp {
l = "[" + GetNowTime() + "] " + l
}

line = l

Expand Down
14 changes: 14 additions & 0 deletions pkg/gee/time.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package gee

import (
"fmt"
"time"
)

// GetNowTime is Get time string now
func GetNowTime() string {
now := time.Now()
sec := now.Unix()
rtn := fmt.Sprintf("%v", time.Unix(sec, 0))
return rtn
}

0 comments on commit 3b48149

Please sign in to comment.