Skip to content

Instantly share code, notes, and snippets.

@helinwang
Last active March 11, 2018 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save helinwang/88ac9780def34d5ce108b84b47b39d5e to your computer and use it in GitHub Desktop.
Save helinwang/88ac9780def34d5ce108b84b47b39d5e to your computer and use it in GitHub Desktop.
Improve golang log15 library
diff --git a/format.go b/format.go
index bce4914..fb40b9d 100644
--- a/format.go
+++ b/format.go
@@ -12,8 +12,8 @@ import (
)
const (
- timeFormat = "2006-01-02T15:04:05-0700"
- termTimeFormat = "01-02|15:04:05"
+ timeFormat = time.StampMilli
+ termTimeFormat = time.StampMilli
floatFormat = 'f'
termMsgJust = 40
)
@@ -220,9 +220,9 @@ func formatLogfmtValue(value interface{}) string {
case bool:
return strconv.FormatBool(v)
case float32:
- return strconv.FormatFloat(float64(v), floatFormat, 3, 64)
+ return strconv.FormatFloat(float64(v), floatFormat, -1, 64)
case float64:
- return strconv.FormatFloat(v, floatFormat, 3, 64)
+ return strconv.FormatFloat(v, floatFormat, -1, 64)
case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64:
return fmt.Sprintf("%d", value)
case string:
diff --git a/logger.go b/logger.go
index 5ec26da..2f3f130 100644
--- a/logger.go
+++ b/logger.go
@@ -108,7 +108,6 @@ func (l *logger) write(msg string, lvl Lvl, ctx []interface{}) {
Lvl: lvl,
Msg: msg,
Ctx: newContext(l.ctx, ctx),
// the line below degrades performance according to CPU profiler.
- Call: stack.Caller(2),
KeyNames: RecordKeyNames{
Time: timeKey,
Msg: msgKey,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment