/*
NNCP -- Node to Node copy, utilities for store-and-forward data exchange
-Copyright (C) 2016-2019 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2016-2021 Sergey Matveev <stargrave@stargrave.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
package main
import (
- "bufio"
"flag"
"fmt"
+ "io"
"log"
"os"
"go.cypherpunks.ru/nncp/v5"
+ "go.cypherpunks.ru/recfile"
)
func usage() {
return
}
- ctx, err := nncp.CtxFromCmdline(*cfgPath, "", *logPath, false, *debug)
+ ctx, err := nncp.CtxFromCmdline(*cfgPath, "", *logPath, false, false, false, *debug)
if err != nil {
log.Fatalln("Error during initialization:", err)
}
if err != nil {
log.Fatalln("Can not open log:", err)
}
- scanner := bufio.NewScanner(fd)
- for scanner.Scan() {
- t := scanner.Text()
+ r := recfile.NewReader(fd)
+ for {
+ le, err := r.NextMap()
+ if err != nil {
+ if err == io.EOF {
+ break
+ }
+ log.Fatalln("Can not read log:", err)
+ }
if *debug {
- fmt.Println(t)
+ fmt.Println(le)
}
- fmt.Println(ctx.Humanize(t))
- }
- if err = scanner.Err(); err != nil {
- log.Fatalln("Can not read log:", err)
+ s, err := ctx.Humanize(le)
+ if err != nil {
+ s = fmt.Sprintf("Can not humanize: %s\n%s", err, le)
+ }
+ fmt.Println(s)
}
}