diff --git a/.gitignore b/.gitignore index 248b04c..8bcc508 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea .vscode *.log -chialoganalyzer \ No newline at end of file +chia-log-analyzer +builds \ No newline at end of file diff --git a/README.md b/README.md index 5b48f39..1fd7363 100644 --- a/README.md +++ b/README.md @@ -1 +1,18 @@ -# Chia log analyzer \ No newline at end of file +# Chia log analyzer +Simply realtime chia log analyzer + +## Howto run +``` +chia-log-analyzer.go-linux-amd64 --log=/path/to/debug.log +``` +![Screenshot](./docs/screenshot-1.png) + +## Features +- monitoring of chia debug.log file +- simply show basic info about farming +- automatic refresh every 5s + +## Supported platforms +- Linux (tested on Ubuntu) +- RPI4 (use linux-arm builds) +- Windows10 \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..1e138e2 --- /dev/null +++ b/build.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +package=chia-log-analyzer.go +#package=$1 +#if [[ -z "$package" ]]; then +# echo "usage: $0 " +# exit 1 +#fi +package_split=(${package//\// }) +package_name=${package_split[-1]} + +platforms=("windows/amd64" "linux/amd64" "linux/arm" "darwin/amd64") + +for platform in "${platforms[@]}" +do + platform_split=(${platform//\// }) + GOOS=${platform_split[0]} + GOARCH=${platform_split[1]} + output_name=$package_name'-'$GOOS'-'$GOARCH + if [ $GOOS = "windows" ]; then + output_name+='.exe' + fi + + env GOOS=$GOOS GOARCH=$GOARCH go build -o ./builds/$output_name $package + if [ $? -ne 0 ]; then + echo 'An error has occurred! Aborting the script execution...' + exit 1 + fi +done \ No newline at end of file diff --git a/chia-log-analyzer.go b/chia-log-analyzer.go index d6ae9da..d474556 100644 --- a/chia-log-analyzer.go +++ b/chia-log-analyzer.go @@ -8,6 +8,7 @@ package main import ( "bufio" + "flag" "fmt" "log" "os" @@ -20,7 +21,7 @@ import ( "github.com/gizak/termui/v3/widgets" ) -const MYFILE = "debug.log" +var debuglogFile *string var widgetLastTimestamp *widgets.Paragraph var widgetLastPlots *widgets.Paragraph @@ -76,6 +77,11 @@ var lastParsedLinesStack = stackStruct{count: 5} var lastFarmStack = stackStructFloats{count: 29} func main() { + debuglogFile = flag.String("log", "./debug.log", "path to debug.log") + flag.Parse() + if _, err := os.Stat(*debuglogFile); os.IsNotExist(err) { + fmt.Println("Please specify path to the log file, with parameter: log (--log=/path/to/debug.log)") + } if err := ui.Init(); err != nil { log.Fatalf("failed to initialize termui: %v", err) @@ -142,10 +148,10 @@ func main() { } func loopReadFile() { - readFullFile(MYFILE) + readFullFile(*debuglogFile) c := time.Tick(5 * time.Second) for range c { - readFile(MYFILE) + readFile(*debuglogFile) } }