-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🪵 logging: revamp usage of zap logger
- Add more presets. - Disable caller info by default. - Use a fake clock in "notime" presets.
- Loading branch information
1 parent
ac0b891
commit 7326c29
Showing
6 changed files
with
119 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package jsonhelper | ||
|
||
import "time" | ||
|
||
// Duration is [time.Duration] but implements [encoding.TextMarshaler] and [encoding.TextUnmarshaler]. | ||
type Duration time.Duration | ||
|
||
// MarshalText implements [encoding.TextMarshaler.MarshalText]. | ||
func (d Duration) MarshalText() ([]byte, error) { | ||
return []byte(time.Duration(d).String()), nil | ||
} | ||
|
||
// UnmarshalText implements [encoding.TextUnmarshaler.UnmarshalText]. | ||
func (d *Duration) UnmarshalText(text []byte) error { | ||
duration, err := time.ParseDuration(string(text)) | ||
if err != nil { | ||
return err | ||
} | ||
*d = Duration(duration) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters