Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refact: rename package to fmtjournal and add tools #16

Merged
merged 2 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
journalfmt
/fmtjournal
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <number> 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` \* `<number>`

## Tips

Copy ./tools/journalctl to your ~/.local/bin then
your journalctl output is format automatically.
6 changes: 3 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/black-desk/journalfmt
module github.com/black-desk/fmtjournal

go 1.20

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/black-desk/journalfmt/cmd"
import "github.com/black-desk/fmtjournal/cmd"

func main() {
cmd.Execute()
Expand Down
3 changes: 3 additions & 0 deletions tools/journalctl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/env sh

/usr/bin/journalctl -o json --all "$@" | fmtjournal | less -r