✨ Add plain text formatter
This commit is contained in:
parent
286ac4557d
commit
89e6c2b3bd
5 changed files with 276 additions and 0 deletions
34
formatters/new.go
Normal file
34
formatters/new.go
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue