Skip to content

Commit

Permalink
refactor: 添加修改选项
Browse files Browse the repository at this point in the history
  • Loading branch information
caixw committed Apr 16, 2024
1 parent d21bdc3 commit 66b9c1f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ require (
github.com/issue9/assert/v4 v4.1.1
github.com/issue9/errwrap v0.3.2
github.com/issue9/localeutil v0.26.5
github.com/issue9/term/v3 v3.2.7
github.com/issue9/term/v3 v3.2.8
golang.org/x/text v0.14.0
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028
)

require golang.org/x/sys v0.18.0 // indirect
require golang.org/x/sys v0.19.0 // indirect

go 1.21
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ github.com/issue9/errwrap v0.3.2 h1:7KEme9Pfe75M+sIMcPCn/DV90wjnOcRbO4DXVAHj3Fw=
github.com/issue9/errwrap v0.3.2/go.mod h1:KcCLuUGiffjooLCUjL89r1cyO8/HT/VRcQrneO53N3A=
github.com/issue9/localeutil v0.26.5 h1:e78b6cOOtgzfb4g4U9uPLC8QyK6Lux+s7ZiQe+6iM1A=
github.com/issue9/localeutil v0.26.5/go.mod h1:BJXJwcAT9CyyVZOlqfmq+B5FcPbqGxGjYnTYbVuiMM8=
github.com/issue9/term/v3 v3.2.7 h1:esfhoinbQ65P3oFscXhticrDFOgZJQqUwL/IC70HiWc=
github.com/issue9/term/v3 v3.2.7/go.mod h1:DvA/fPiKzX11P/ZoVWJG5QMVpI0ia+uqiU31iZV2jHE=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
github.com/issue9/term/v3 v3.2.8 h1:vAtsr9FLwrDQRyU7S8AOUI3f+QrYsXVHT/kee9MuMkk=
github.com/issue9/term/v3 v3.2.8/go.mod h1:S/xLgjEXJNr7C6UhcGTEOV5k94mzHRcYMmtvhLJoX6A=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU=
Expand Down
10 changes: 7 additions & 3 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ func WithDetail(v bool) Option { return func(l *Logs) { l.detail = v } }
// WithCreated 指定日期的格式
//
// 如果 layout 为空将会禁用日期显示。
func WithCreated(layout string) Option {
return func(l *Logs) { l.createdFormat = layout }
}
func WithCreated(layout string) Option { return func(l *Logs) { l.createdFormat = layout } }

// WithLocation 是否显示定位信息
func WithLocation(v bool) Option { return func(l *Logs) { l.location = v } }
Expand All @@ -90,3 +88,9 @@ func (logs *Logs) SetLocation(v bool) { logs.location = v }
//
// 如果 v 为空将会禁用日期显示。
func (logs *Logs) SetCreated(v string) { logs.createdFormat = v }

// SetLocale 改变本地化对象
func (logs *Logs) SetLocale(p *localeutil.Printer) { logs.printer = p }

// SetDetail 是否显示错误的堆栈信息
func (logs *Logs) SetDetail(v bool) { logs.detail = v }

0 comments on commit 66b9c1f

Please sign in to comment.