X-Git-Url: http://www.git.cypherpunks.ru/?p=nncp.git;a=blobdiff_plain;f=src%2Flog.go;h=bc91043e2198352f26c4c13249da790885c59284;hp=b83db340170668ead8821ac96f67ea2903e8ebee;hb=1d2ce674b042d07fd9b37a46578c8b62bb0345b7;hpb=b2e36aeaa5dc1c9649c6895d938208d92ddc3fa3 diff --git a/src/log.go b/src/log.go index b83db34..bc91043 100644 --- a/src/log.go +++ b/src/log.go @@ -40,7 +40,14 @@ func sdFmt(who string, sds SDS) string { result := make([]string, 0, 1+len(keys)) result = append(result, "["+who) for _, k := range keys { - result = append(result, fmt.Sprintf(`%s="%s"`, k, sds[k])) + var value string + switch v := sds[k].(type) { + case int, int8, uint8, int64, uint64: + value = fmt.Sprintf("%d", v) + default: + value = fmt.Sprintf("%s", v) + } + result = append(result, fmt.Sprintf(`%s="%s"`, k, value)) } return strings.Join(result, " ") + "]" } @@ -103,13 +110,8 @@ func (ctx *Ctx) LogI(who string, sds SDS, msg string) { ctx.Log(msg) } -func (ctx *Ctx) LogP(who string, sds SDS, msg string) { - if !ctx.Quiet { - fmt.Fprintln(os.Stderr, ctx.Humanize(msgFmt(LogLevel("P"), who, sds, msg))) - } -} - -func (ctx *Ctx) LogE(who string, sds SDS, msg string) { +func (ctx *Ctx) LogE(who string, sds SDS, err error, msg string) { + sds["err"] = err.Error() msg = msgFmt(LogLevel("E"), who, sds, msg) if len(msg) > 2048 { msg = msg[:2048]