34 lines
554 B
Go
34 lines
554 B
Go
package formatters
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"codeberg.org/danjones000/my-log/config"
|
|
)
|
|
|
|
type formatMaker func(config.Formatters) (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.Formatters)
|
|
}
|
|
|
|
return nil, errors.New("unimplemented")
|
|
}
|
|
|
|
func Kinds() []string {
|
|
r := []string{}
|
|
for kind, _ := range formatterMap {
|
|
r = append(r, kind)
|
|
}
|
|
return r
|
|
}
|