diff --git a/.github/workflows/feature.yml b/.github/workflows/feature.yml new file mode 100644 index 0000000..9bc6b7f --- /dev/null +++ b/.github/workflows/feature.yml @@ -0,0 +1,37 @@ +name: Feature_CI + +on: + push: + branches: + - feature/* + pull_request: + branches: + - feature/* + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18 + + - name: Build + run: go build -v ./... + + - name: Test + run: go test -v ./... + + - name: Tags + run: | + git fetch --prune --unshallow + git describe --tags + CURV=$(git describe --tags --abbrev=0) + IFS='.' read -ra VR <<< "$CURV" + INC=`expr ${VR[2]} + 1` + FV="${VR[0]}.${VR[1]}.$INC" + shell: bash diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..c17cb57 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,80 @@ +name: Go + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + ci: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18 + +# - name: Install dependencies +# run: | +# go version +# go get -u golang.org/x/lint/golint + + - name: Build + run: go build -v ./... + +# - name: Test With Coverage +# run: go test -v -coverprofile=coverage.txt -covermode=atomic ./... + +# - name: Upload coverage to Codecov +# run: bash <(curl -s https://codecov.io/bash) + + tag: + needs: ci + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set env + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18 + + - name: Tag and Deploy + run: | + git fetch --prune --unshallow + CURV=$(git describe --tags --abbrev=0) + IFS='.' read -ra VR <<< "$CURV" + INC=`expr ${VR[2]} + 1` + FV="${VR[0]}.${VR[1]}.$INC" + eval "git tag $FV && git push origin $FV" + eval "GOPROXY=proxy.golang.org go list -m github.com/aurc/loggo@$FV" + shell: bash + release: + needs: tag + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - + name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18 + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.HOMEBREW_LOGGO_GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 5781491..20f8836 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ main .idea loggo testdata/log.txt +dist/ # Test binary, built with `go test -c` *.test diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..5603786 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,64 @@ +project_name: loggo +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 +nfpms: + - maintainer: Aurelio Calegari (aurcbot@gmail.com) + description: Rich Terminal User Interface for JSON logs + homepage: https://github.com/aurc/loggo + license: MIT + formats: + - deb + - rpm + - apk +brews: + - + name: loggo + # GOARM to specify which 32-bit arm version to use if there are multiple versions + # from the build section. Brew formulas support atm only one 32-bit version. + # Default is 6 for all artifacts or each id if there a multiple versions. + goarm: 6 + + tap: + owner: aurc + name: homebrew-loggo + branch: main + # # Optionally a token can be provided, if it differs from the token provided to GoReleaser + # token: "{{ .Env.HOMEBREW_LOGGO_GITHUB_TOKEN }}" + + url_template: "https://github.com/aurc/loggo/releases/download/{{ .Tag }}/{{ .ArtifactName }}" + + commit_author: + name: aurc_bot + email: aurcbot@gmail.com + + # The project name and current git tag are used in the format string. + commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}" + + # Folder inside the repository to put the formula. + # Default is the root folder. + folder: Formula + + # Caveats for the user of your binary. + # Default is empty. + caveats: "How to use this binary" + + # Your app's homepage. + # Default is empty. + homepage: "https://github.com/aurc/homebrew-loggo" + + # Template of your app's description. + # Default is empty. + description: "Rich Terminal User Interface for JSON logs" + + # SPDX identifier of your app's license. + # Default is empty. + license: "MIT" + diff --git a/config-sample/gcp.yaml b/config-sample/gcp.yaml index 6776f70..32c1304 100644 --- a/config-sample/gcp.yaml +++ b/config-sample/gcp.yaml @@ -2,6 +2,9 @@ keys: - name: timestamp type: datetime layout: 2006-01-02T15:04:05-0700 + color: + foreground: purple + background: black - name: severity type: string color: @@ -26,7 +29,16 @@ keys: background: black - name: resource/labels/container_name type: string + color: + foreground: darkgreen + background: black - name: trace type: string + color: + foreground: white + background: black - name: jsonPayload/message - type: string \ No newline at end of file + type: string + color: + foreground: white + background: black \ No newline at end of file diff --git a/img/loggo_short.png b/img/loggo_short.png new file mode 100644 index 0000000..0de76b6 Binary files /dev/null and b/img/loggo_short.png differ diff --git a/internal/char/canvas_test.go b/internal/char/canvas_test.go index 7f3c269..12f7a18 100644 --- a/internal/char/canvas_test.go +++ b/internal/char/canvas_test.go @@ -131,14 +131,14 @@ func TestCanvas_BlankCanvasAsString(t *testing.T) { name: "Test l`oGGo", words: LoggoLogo, wants: `╔╦╦╦╦╦╦╦╦▓▓░╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╗ -╠▓▓▓░╬╬╬╬▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓░╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣ -╠╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓░╬╬╬╬▓▓▓░╬╬╬╬╬▓▓▓░╬╬╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣ -╠╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣ -╠╬╬▓▓░╬╬╬╬╬╬▓▓▓▓▓░╬╬╬╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓░╬╬╬╬╬▓▓▓▓▓░╬╬╬╬╬╬╣ -╠╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬▓▓░╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓░╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬╣ -╠╬╬▓▓░╬╬╬▓▓░╬╬╬╬╬╬▓▓░╬▓▓░╬╬╬╬╬╬╬▓▓▓▓▓░╬▓▓▓▓▓░╬╬╬╬╬╬╬▓▓░╬▓▓░╬╬╬╬╬╬▓▓░╬╬╬╣ -╠╬╬▓▓░╬╬╬▓▓░╬╬╬╬╬╬▓▓░╬▓▓░╬╬╬╬╬╬╬╬╬▓▓░╬╬╬▓▓░╬╬╬╬╬╬╬╬╬▓▓░╬▓▓░╬╬╬╬╬╬▓▓░╬╬╬╣ -╠╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬╬╬▓▓▓░╬╬╬▓▓▓░╬╬╬╬╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬╣ +╠▓▓▓░╬╬╬╬▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓░╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣ +╠╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓░╬╬╬╬▓▓░╬╬╬╬╬╬╬▓▓░╬╬╬╬▓▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣ +╠╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓░╬╬╬╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣ +╠╬╬▓▓░╬╬╬╬╬╬▓▓▓▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓░╬╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓░╬╬╬╬╬╬╣ +╠╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓░╬▓▓░╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬╣ +╠╬╬▓▓░╬╬╬▓▓░╬╬╬╬╬╬▓▓░╬▓▓▓▓▓░╬╬╬╬╬╬╬▓▓░╬▓▓░╬╬╬╬╬╬╬▓▓▓▓▓░╬▓▓░╬╬╬╬╬╬▓▓░╬╬╬╣ +╠╬╬▓▓░╬╬╬▓▓░╬╬╬╬╬╬▓▓░╬╬▓▓░╬╬╬╬╬╬╬╬╬▓▓░╬▓▓░╬╬╬╬╬╬╬╬╬▓▓░╬╬▓▓░╬╬╬╬╬╬▓▓░╬╬╬╣ +╠╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬▓▓░╬╬╬▓▓▓░╬╬╬╬╬╬▓▓░╬╬╬╬╬▓▓░╬╬╬╬╬╬▓▓▓░╬╬╬▓▓░╬╬╬╬▓▓░╬╬╬╬╣ ╠╬╬╬▓▓▓░╬╬╬╬▓▓▓▓▓░╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓░╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓░╬╬╬╬╬╬╬╬▓▓▓▓▓░╬╬╬╬╬╬╣ ╚╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╝`, }, diff --git a/internal/config/log_config_test.go b/internal/config/log_config_test.go index 1085da2..5855770 100644 --- a/internal/config/log_config_test.go +++ b/internal/config/log_config_test.go @@ -61,6 +61,7 @@ func TestMakeConfig(t *testing.T) { } for _, test := range tests { t.Run(test.name, func(t *testing.T) { + test.wants.LastSavedName = test.givenFile c, err := MakeConfig(test.givenFile) if test.wantsError { assert.Error(t, err) @@ -121,6 +122,10 @@ var defConfig = Config{ Name: "timestamp", Type: TypeDateTime, Layout: "2006-01-02T15:04:05-0700", + Color: Color{ + Foreground: "purple", + Background: "black", + }, }, { Name: "severity", @@ -140,22 +145,22 @@ var defConfig = Config{ { MatchValue: "INFO", Color: Color{ - Foreground: "white", + Foreground: "green", Background: "black", }, }, { MatchValue: "WARN", Color: Color{ - Foreground: "red", - Background: "yellow", + Foreground: "yellow", + Background: "black", }, }, { MatchValue: "DEBUG", Color: Color{ - Foreground: "white", - Background: "blue", + Foreground: "blue", + Background: "black", }, }, }, @@ -163,14 +168,26 @@ var defConfig = Config{ { Name: "resource/labels/container_name", Type: TypeString, + Color: Color{ + Foreground: "darkgreen", + Background: "black", + }, }, { Name: "trace", Type: TypeString, + Color: Color{ + Foreground: "white", + Background: "black", + }, }, { Name: "jsonPayload/message", Type: TypeString, + Color: Color{ + Foreground: "white", + Background: "black", + }, }, }, }