-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,58 @@ | ||
package zlog | ||
|
||
import ( | ||
"time" | ||
|
||
"go.uber.org/zap" | ||
) | ||
|
||
// TimeValue returns a Value for a time.Time. | ||
// It discards the monotonic portion. | ||
func TimeValue(v time.Time) any { | ||
return uint64(v.UnixNano()) | ||
} | ||
|
||
// DurationValue returns a Value for a time.Duration. | ||
func DurationValue(v time.Duration) uint64 { | ||
return uint64(v.Nanoseconds()) | ||
} | ||
|
||
func Err(err error) Field { | ||
return zap.Error(err) | ||
} | ||
|
||
func String(key, v string) Field { | ||
return zap.String(key, v) | ||
} | ||
|
||
func Uint64(key string, v uint64) Field { | ||
return zap.Uint64(key, v) | ||
} | ||
|
||
func Int64(key string, v int64) Field { | ||
return zap.Int64(key, v) | ||
} | ||
|
||
func Float64(key string, v float64) Field { | ||
return zap.Float64(key, v) | ||
} | ||
|
||
func Bool(key string, b bool) Field { | ||
return zap.Bool(key, b) | ||
} | ||
|
||
func Int(key string, v int) Field { | ||
return Int64(key, int64(v)) | ||
} | ||
|
||
func Any(key string, v any) Field { | ||
return zap.Any(key, v) | ||
} | ||
|
||
func Time(key string, v time.Time) Field { | ||
return zap.Time(key, v) | ||
} | ||
|
||
func Duration(key string, v time.Duration) Field { | ||
return zap.Duration(key, v) | ||
} |