diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 81a72d3..9915dcb 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -4,6 +4,10 @@ on: [pull_request] jobs: checks: + permissions: + checks: write + contents: read + pull-requests: write runs-on: ubuntu-latest steps: - - uses: black-desk/checks@v1 + - uses: black-desk/checks@master diff --git a/.gitignore b/.gitignore index 5aa411f..db95ef6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -journalfmt +/fmtjournal diff --git a/README.md b/README.md index 3c7a904..9510ac2 100644 --- a/README.md +++ b/README.md @@ -44,15 +44,20 @@ Then go to check the [default format](./consts/consts.go), Here are something you should know: - `{{.timestamp}}` - + Formatted `__REALTIME_TIMESTAMP` stored in `.timestamp` - `{{.extra}}` - + Custom fields not list in `man systemd.journal-fields` is place in a `map[string]any` at `.extra` - `{{indent string}}` - + There is a helper function `indent` you can use it to format your string, it replace all `\n` in your string with `\n` and `\t` \* `` + +## Tips + +Copy ./tools/journalctl to your ~/.local/bin then +your journalctl output is format automatically. diff --git a/cmd/root.go b/cmd/root.go index 28e3833..86b5480 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -18,14 +18,14 @@ import ( "github.com/adrg/xdg" "github.com/spf13/cobra" - "github.com/black-desk/journalfmt/consts" - "github.com/black-desk/journalfmt/types" + "github.com/black-desk/fmtjournal/consts" + "github.com/black-desk/fmtjournal/types" ) var flags types.Flags var rootCmd = &cobra.Command{ - Use: "journalfmt", + Use: "fmtjournal", Short: "A tool format journalctl json stream from stdin.", RunE: func(_ *cobra.Command, args []string) (err error) { return rootCmdRun(flags) diff --git a/go.mod b/go.mod index 6de75db..9a1878c 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/black-desk/journalfmt +module github.com/black-desk/fmtjournal go 1.20 diff --git a/main.go b/main.go index 69e1420..763213f 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,6 @@ package main -import "github.com/black-desk/journalfmt/cmd" +import "github.com/black-desk/fmtjournal/cmd" func main() { cmd.Execute() diff --git a/tools/journalctl b/tools/journalctl new file mode 100755 index 0000000..d774328 --- /dev/null +++ b/tools/journalctl @@ -0,0 +1,3 @@ +#!/bin/env sh + +/usr/bin/journalctl -o json --all "$@" | fmtjournal | less -r