1 // NNCP -- Node to Node copy, utilities for store-and-forward data exchange
2 // Copyright (C) 2016-2024 Sergey Matveev <stargrave@stargrave.org>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, version 3 of the License.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 "go.cypherpunks.ru/recfile"
26 func (ctx *Ctx) HumanizeRec(rec string) string {
27 r := recfile.NewReader(strings.NewReader(rec))
28 le, err := r.NextMap()
32 humanized, err := ctx.Humanize(le)
34 return fmt.Sprintf("Can not humanize: %s\n%s", err, rec)
39 func (ctx *Ctx) Humanize(le map[string]string) (string, error) {
40 when, err := time.Parse(time.RFC3339Nano, le["When"])
46 if errMsg, isErr := le["Err"]; isErr {
50 return fmt.Sprintf("%s %s%s", when.Format(time.RFC3339), level, msg), nil