mirror of https://github.com/status-im/msgstat.git
Update readme and usage info
This commit is contained in:
parent
03ea9391f8
commit
280fa72b50
12
README.md
12
README.md
|
@ -3,20 +3,20 @@ Msgstat
|
|||
Msgstat provides a CLI tool which analyses status-go log files and generates corresponding output of information
|
||||
related to messages delivered over whisper (either rpc or p2p).
|
||||
|
||||
## Commands
|
||||
## Usage
|
||||
|
||||
### `read`
|
||||
Msgstat provides the processing functionality for the processing of all log files which would be used to produced aggregated collection of message delivery facts.
|
||||
|
||||
The command `read` provides the processing functionality for the processing of all log files which would be used to produced aggregated collection of message delivery facts.
|
||||
|
||||
The `read` command expects processing data to be delivered either through sending given logs through `stdin` or through the use of the `file` flag.
|
||||
It by defaults expects processing data to be delivered either through sending given logs through `stdin` or through the use of the `file` flag.
|
||||
|
||||
- Processing log lines through stdin
|
||||
|
||||
```bash
|
||||
> cat ./logs/status-im/status-go/11.21.2017.log | msgstat read
|
||||
> cat ./logs/status-im/status-go/11.21.2017.log | msgstat
|
||||
```
|
||||
|
||||
- Processing log lines from a file
|
||||
|
||||
```bash
|
||||
> msgstat read -file=./logs/status-im/status-go/11.21.2017.log
|
||||
```
|
||||
|
|
19
main.go
19
main.go
|
@ -110,21 +110,10 @@ Msgstat processes status-go lines to generate useful message delivery facts.
|
|||
|
||||
EXAMPLES:
|
||||
|
||||
1. Read from stdin
|
||||
|
||||
cat ./statusim/status.log | msgstat read
|
||||
|
||||
2. Read from file
|
||||
|
||||
msgstat read -file=./statusim/status.log
|
||||
|
||||
3. Read from file and write to output file
|
||||
|
||||
msgstat read -file=./statusim/status.log -out=./processed-log.json
|
||||
|
||||
4. Read from file and write in yaml format
|
||||
|
||||
msgstat read -format=yaml -file=./statusim/status.log -out=./processed-log.json
|
||||
cat status.log | msgstat # read from stdin
|
||||
msgstat -file=status.log # read from file
|
||||
msgstat -file=status.log -out=proc.json # read from file and write to output file
|
||||
msgstat -format=yaml -file=status.log -out=proc.json # read from file and write in yaml format
|
||||
|
||||
FLAGS:
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package stats
|
||||
|
||||
import "io"
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
// AggregateLogs processes incoming data from the reader and writes appropriate
|
||||
// data with respect to format required.
|
||||
|
@ -8,5 +12,21 @@ func AggregateLogs(r io.ReadCloser, w io.WriteCloser, format string) error {
|
|||
defer w.Close()
|
||||
defer r.Close()
|
||||
|
||||
bufReader := bufio.NewReader(r)
|
||||
|
||||
for {
|
||||
line, _, err := bufReader.ReadLine()
|
||||
|
||||
// if we have reach end of file, just return.
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
return nil
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("Currentline: %+q", line)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue