Skip to content

Commit

Permalink
Merge pull request #12 from fortio/goroutine
Browse files Browse the repository at this point in the history
Goroutine id color decoding
  • Loading branch information
ldemailly authored Jul 22, 2023
2 parents 119bb5d + b2cfe7c commit afa8311
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ tests:
go test -v ./...

manual-check:
@echo "======= With Timestamp: ==========="
@echo "=========== With Everything: ==========="
go run ./levelsDemo 2>&1 | TZ=UTC go run -race .
@echo "======= Without: =================="
go run ./levelsDemo -logger-timestamp=false 2>&1 | TZ=UTC go run -race .
@echo "=========== Without Timestamp nor go Routine ID: ==========="
go run ./levelsDemo -logger-timestamp=false -logger-goroutine=false 2>&1 | go run -race .

.PHONY: tests manual-check
Binary file modified example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ go 1.18

require (
fortio.org/cli v1.2.0
fortio.org/log v1.7.0
fortio.org/scli v1.8.0
fortio.org/log v1.8.1
fortio.org/scli v1.9.0
)

require (
fortio.org/dflag v1.5.2 // indirect
fortio.org/sets v1.0.3 // indirect
fortio.org/version v1.0.2 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
golang.org/x/exp v0.0.0-20230420155640-133eef4313cb // indirect
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect
golang.org/x/sys v0.10.0 // indirect
)
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ fortio.org/cli v1.2.0 h1:MXmbYnbNHcclf0xYLZjeCnTINby7FpooJxR01+hnBmM=
fortio.org/cli v1.2.0/go.mod h1:zJwHjRnvVqneF7ES+REfElc33xMjhbRDJslSrqIK9Kk=
fortio.org/dflag v1.5.2 h1:F9XVRj4Qr2IbJP7BMj7XZc9wB0Q/RZ61Ool+4YPVad8=
fortio.org/dflag v1.5.2/go.mod h1:ppb/A8u+KKg+qUUYZNYuvRnXuVb8IsdHb/XGzsmjkN8=
fortio.org/log v1.7.0 h1:4MbU81zqe/3RYuHpXADNgJwd2KEMAwmMUtuF5qtZTug=
fortio.org/log v1.7.0/go.mod h1:u/8/2lyczXq52aT5Nw6reD+3cR6m/EbS2jBiIYhgiTU=
fortio.org/scli v1.8.0 h1:JKxPdHeb1vAXFmaliPkfz0Eq2VI35LVUKileOfxdgks=
fortio.org/scli v1.8.0/go.mod h1:QdIJu32otZ3yGztI3NZoUriMZchXq06u2Ttp+/Tm6u8=
fortio.org/log v1.8.1 h1:Ybtjp+qDXb124ESnZ0XVuXJ6khDrWcom/C55YPupoKg=
fortio.org/log v1.8.1/go.mod h1:u/8/2lyczXq52aT5Nw6reD+3cR6m/EbS2jBiIYhgiTU=
fortio.org/scli v1.9.0 h1:laTn/mACr1+TRKH3ZKaQWw58kTzQ1ntpg2sH02KUJAA=
fortio.org/scli v1.9.0/go.mod h1:Ox3nhp3eJpF2rQsZ8fBKXqdJGQPTQHWEZpLikDnkzjY=
fortio.org/sets v1.0.3 h1:HzewdGjH69YmyW06yzplL35lGr+X4OcqQt0qS6jbaO4=
fortio.org/sets v1.0.3/go.mod h1:QZVj0r6KP/ZD9ebySW9SgxVNy/NjghUfyHW9NN+WU+4=
fortio.org/version v1.0.2 h1:8NwxdX58aoeKx7T5xAPO0xlUu1Hpk42nRz5s6e6eKZ0=
fortio.org/version v1.0.2/go.mod h1:2JQp9Ax+tm6QKiGuzR5nJY63kFeANcgrZ0osoQFDVm0=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
golang.org/x/exp v0.0.0-20230420155640-133eef4313cb h1:rhjz/8Mbfa8xROFiH+MQphmAmgqRM0bOMnytznhWEXk=
golang.org/x/exp v0.0.0-20230420155640-133eef4313cb/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw=
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
5 changes: 5 additions & 0 deletions logc.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@ func ProcessLogLine(w io.Writer, prevDate *time.Time, noColor bool, line []byte)
tsStr := ""
reset := log.Colors.Reset
darkGrey := log.Colors.DarkGray
grey := log.Colors.Gray
// uppercase single letter level + color extraction
lvl, color := LevelToColor(e.Level)
if noColor {
color = ""
reset = ""
darkGrey = ""
grey = ""
}
if e.TS != 0 {
ts := e.Time()
Expand All @@ -98,6 +100,9 @@ func ProcessLogLine(w io.Writer, prevDate *time.Time, noColor bool, line []byte)
// Use full microseconds resolution unlike the log built in color version which stops at millis.
tsStr = ts.Format(darkGrey + "15:04:05.000000 ")
}
if e.R > 0 {
tsStr += fmt.Sprintf(grey+"[%d] ", e.R)
}
fileLine := ""
if e.Line != 0 {
fileLine = fmt.Sprintf("%s:%d> ", e.File, e.Line)
Expand Down

0 comments on commit afa8311

Please sign in to comment.