diff --git a/console.go b/console.go index afc88b7..3dc202b 100644 --- a/console.go +++ b/console.go @@ -33,8 +33,8 @@ type Console struct { wrLock sync.Mutex writeMessage func(b *bytes.Buffer, l Level, scope string, caller string, m string) - writeKey func(b *bytes.Buffer, s string) - writeValue func(b *bytes.Buffer, s string) + writeKey func(b *bytes.Buffer, k interface{}) + writeValue func(b *bytes.Buffer, v interface{}) writeScope func(b *bytes.Buffer, scope string) writeCaller func(b *bytes.Buffer, caller string) } @@ -126,17 +126,17 @@ func (c *Console) writeMessageColor(b *bytes.Buffer, l Level, scope string, call b.WriteString(m) } -func (c *Console) writeKeyColor(b *bytes.Buffer, s string) { +func (c *Console) writeKeyColor(b *bytes.Buffer, k interface{}) { b.WriteByte(32) // Space c.setColor(b, "34") - b.WriteString(s) + fmt.Fprint(b, k) c.resetColor(b) b.WriteByte('=') } -func (c *Console) writeValueColor(b *bytes.Buffer, s string) { +func (c *Console) writeValueColor(b *bytes.Buffer, v interface{}) { c.setColor(b, "36") - b.WriteString(s) + fmt.Fprint(b, v) c.resetColor(b) } @@ -153,15 +153,15 @@ func (c *Console) writeMessageSimple(b *bytes.Buffer, l Level, scope string, cal b.WriteByte('"') } -func (c *Console) writeKeySimple(b *bytes.Buffer, s string) { +func (c *Console) writeKeySimple(b *bytes.Buffer, k interface{}) { b.WriteByte(' ') - b.WriteString(s) + fmt.Fprint(b, k) b.WriteByte('=') } -func (c *Console) writeValueSimple(b *bytes.Buffer, s string) { +func (c *Console) writeValueSimple(b *bytes.Buffer, v interface{}) { b.WriteByte('"') - b.WriteString(s) + fmt.Fprint(b, v) b.WriteByte('"') } @@ -229,11 +229,11 @@ func (c *Console) writeBuf(buf *bytes.Buffer) { func (c *Console) writeValues(buf *bytes.Buffer, keysValues []interface{}) { lenValues := len(keysValues) for i := 0; i < lenValues; i++ { - c.writeKey(buf, fmt.Sprint(keysValues[i])) + c.writeKey(buf, keysValues[i]) i++ if i < lenValues { - c.writeValue(buf, fmt.Sprint(keysValues[i])) + c.writeValue(buf, keysValues[i]) } else { c.writeValue(buf, "!VALUE") } diff --git a/core.go b/core.go index df78c2d..1e774e1 100644 --- a/core.go +++ b/core.go @@ -93,96 +93,6 @@ func (c *core) printv1(l Level, s string, skip int, message string, keysValues [ } } -// // func (c *core) print2(l Level, s string, messages ...interface{}) { -// // t := fmt.Sprint(messages...) - -// // caller := "" -// // if c.writers[0].caller || c.writers[1].caller { -// // caller = c.getCaller() -// // } - -// // stack := "" -// // if c.writers[0].stack(l, s) || c.writers[1].stack(l, s) { -// // stack = c.getStack() -// // } - -// // w := c.writers[0] -// // if w.isEnable(l, s) { -// // c1 := "" -// // s1 := "" - -// // if w.caller { -// // c1 = caller -// // } - -// // if w.caller { -// // s1 = stack -// // } - -// // w.Print(l, s, c1, s1, t) -// // } - -// // w = c.writers[1] -// // if w.isEnable(l, s) { -// // if w.caller { -// // w.Print(l, s, caller, stack, t) -// // } else { -// // w.Print(l, s, "", stack, t) -// // } -// // } -// // } - -// // func (c *core) printf2(l Level, s string, format string, args []interface{}) { -// // message := fmt.Sprintf(format, args...) -// // caller := "" -// // if c.writers[0].caller || c.writers[1].caller { -// // caller = c.getCaller() -// // } - -// // w := c.writers[0] -// // if w.isEnable(l, s) { -// // if w.caller { -// // w.Print(l, s, caller, message) -// // } else { -// // w.Print(l, s, "", message) -// // } -// // } - -// // w = c.writers[1] -// // if w.isEnable(l, s) { -// // if w.caller { -// // w.Print(l, s, caller, message) -// // } else { -// // w.Print(l, s, "", message) -// // } -// // } -// // } - -// func (c *core) printv2(l Level, s string, message string, keysValues []interface{}) { -// w := c.writers[0] -// caller := "" -// if c.writers[0].caller || c.writers[1].caller { -// caller = c.getCaller() -// } - -// if w.isEnable(l, s) { -// if w.caller { -// w.Printv(l, s, caller, message, keysValues) -// } else { -// w.Printv(l, s, "", message, keysValues) -// } -// } - -// w = c.writers[1] -// if w.isEnable(l, s) { -// if w.caller { -// w.Printv(l, s, caller, message, keysValues) -// } else { -// w.Printv(l, s, "", message, keysValues) -// } -// } -// } - func (c *core) printAll(l Level, s string, skip int, messages []interface{}) { caller := "" var stack []string