grim/convey

Port from logrus to log/slog
default tip
4 months ago, Elliott Sales de Andrade
c588f9b3f559
Port from logrus to log/slog

This doesn't really take much advantage of structured logging beyond what is already done (`id` and `idColor`), and consequently the log handler does not try to do any handling of anything more than that (i.e., grouping, or arbitrary attributes beyond those defined).

One should maybe have a `Context` available to pass in, but there isn't one, and anyway, the log handler doesn't use it, so I've passed in a `TODO` instead.

Everything else is just normal import/rename changes.

Testing Done:
Ran `go run . run`

Reviewed at https://reviews.imfreedom.org/r/2871/
//go:build !windows
package script
import (
"testing"
"github.com/stretchr/testify/assert"
"keep.imfreedom.org/grim/convey/yaml"
)
func TestShellDefaults(t *testing.T) {
s := &Shell{
Filename: "/dev/null",
}
s.Valid()
assert.Equal(t, s.Shell, "/bin/sh")
}
func TestShellCommands(t *testing.T) {
s := &Shell{
Commands: yaml.StringOrSlice{"uptime"},
}
assert.NoError(t, s.Valid())
}
func TestShellFilename(t *testing.T) {
s := &Shell{
Filename: "/dev/null",
}
assert.NoError(t, s.Valid())
}
func TestShellNeitherFilenameNorCommands(t *testing.T) {
s := &Shell{}
assert.ErrorIs(t, s.Valid(), ErrNoCommandsOrFilename)
}
func TestShellBothFilenameAndCommands(t *testing.T) {
s := &Shell{
Commands: yaml.StringOrSlice{"uptime"},
Filename: "/dev/null",
}
assert.ErrorIs(t, s.Valid(), ErrOnlyFilenameOrCommands)
}