Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow to set styles in options #133

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ type Options struct {
Fields []interface{}
// Formatter is the formatter for the logger. The default is TextFormatter.
Formatter Formatter
// Styles is the logger styles for the TextFormatter.
Styles *Styles
}
2 changes: 1 addition & 1 deletion pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewWithOptions(w io.Writer, o Options) *Logger {

l.SetOutput(w)
l.SetLevel(Level(l.level))
l.SetStyles(DefaultStyles())
l.SetStyles(o.Styles)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
l.SetStyles(o.Styles)
styles := o.Styles
if styles == nil {
styles = DefaultStyles()
}
l.SetStyles(styles)


if l.callerFormatter == nil {
l.callerFormatter = ShortCallerFormatter
Expand Down
Loading