Skip to content

Commit e2f5e88

Browse files
erikogenvikwendigo
authored andcommitted
Allow shortened length to be specified.
1 parent b558733 commit e2f5e88

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ This image bundles headless Chrome in the latest version so debugger is ready to
5050
-q do not show logs on stdout
5151
-r string
5252
remote address (default "localhost:9222")
53-
-s shorten requests and responses
53+
-s max_length
54+
shorten requests and responses to max_length
5455
-version
5556
display version information
5657
```

flags.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
var (
88
flagListen = flag.String("l", "localhost:9223", "listen address")
99
flagRemote = flag.String("r", "localhost:9222", "remote address")
10-
flagEllipsis = flag.Bool("s", false, "shorten requests and responses")
10+
flagEllipsis = flag.Int("s", 0, "shorten requests and responses if above length")
1111
flagOnce = flag.Bool("once", false, "debug single session")
1212
flagShowRequests = flag.Bool("i", false, "include request frames as they are sent")
1313
flagDistributeLogs = flag.Bool("d", false, "write logs file per targetId")

utils.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ import (
66
"strings"
77
)
88

9-
const (
10-
ellipsisLength = 80
11-
)
12-
139
func center(message string, length int) string {
1410
padding := (length - len(message)) / 2
1511

@@ -32,8 +28,8 @@ func serialize(value interface{}) string {
3228

3329
buff, err := json.Marshal(value)
3430
if err == nil {
35-
if *flagEllipsis && len(buff) > ellipsisLength {
36-
return string(buff[:ellipsisLength]) + "..."
31+
if *flagEllipsis != 0 && len(buff) > *flagEllipsis {
32+
return string(buff[:*flagEllipsis]) + "..."
3733
}
3834

3935
serialized := string(buff)

0 commit comments

Comments
 (0)