| 
									
										
										
										
											2024-03-07 10:10:54 -06:00
										 |  |  | package formatters | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"errors" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	"codeberg.org/danjones000/my-log/config" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-07 21:19:45 -06:00
										 |  |  | type formatMaker func(config.Formatters) (Formatter, error) | 
					
						
							| 
									
										
										
										
											2024-03-07 10:10:54 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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 { | 
					
						
							| 
									
										
										
										
											2024-03-07 21:19:45 -06:00
										 |  |  | 		return make(conf.Formatters) | 
					
						
							| 
									
										
										
										
											2024-03-07 10:10:54 -06:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return nil, errors.New("unimplemented") | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func Kinds() []string { | 
					
						
							|  |  |  | 	r := []string{} | 
					
						
							|  |  |  | 	for kind, _ := range formatterMap { | 
					
						
							|  |  |  | 		r = append(r, kind) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return r | 
					
						
							|  |  |  | } |