Add plain text formatter

This commit is contained in:
Dan Jones 2024-03-07 10:10:54 -06:00
commit 89e6c2b3bd
5 changed files with 276 additions and 0 deletions

34
formatters/new.go Normal file
View file

@ -0,0 +1,34 @@
package formatters
import (
"errors"
"codeberg.org/danjones000/my-log/config"
)
type formatMaker func(oo config.Outputs) (Formatter, error)
var formatterMap = map[string]formatMaker{
"plain": newPlain,
}
func New(kind string) (f Formatter, err error) {
conf, err := config.Load()
if err != nil {
return
}
if make, ok := formatterMap[kind]; ok {
return make(conf.Outputs)
}
return nil, errors.New("unimplemented")
}
func Kinds() []string {
r := []string{}
for kind, _ := range formatterMap {
r = append(r, kind)
}
return r
}