35 lines
		
	
	
	
		
			551 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			35 lines
		
	
	
	
		
			551 B
		
	
	
	
		
			Go
		
	
	
	
	
	
|  | 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 | ||
|  | } |