| 
									
										
										
										
											2024-02-04 18:19:19 -06:00
										 |  |  | package config | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"fmt" | 
					
						
							|  |  |  | 	"os" | 
					
						
							|  |  |  | 	fp "path/filepath" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	"github.com/BurntSushi/toml" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-10 13:35:47 -06:00
										 |  |  | const ConfigStr = `# Configuration for my-log | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:19:19 -06:00
										 |  |  | [input] | 
					
						
							| 
									
										
										
										
											2024-02-10 13:35:47 -06:00
										 |  |  | # Path to where the log files are stored | 
					
						
							|  |  |  | path = "%s" | 
					
						
							|  |  |  | # File extension for log files | 
					
						
							| 
									
										
										
										
											2024-02-04 18:19:19 -06:00
										 |  |  | ext = "txt" | 
					
						
							| 
									
										
										
										
											2024-02-10 13:35:47 -06:00
										 |  |  | # Whether to look in sub-folders | 
					
						
							| 
									
										
										
										
											2024-02-04 18:19:19 -06:00
										 |  |  | recurse = true | 
					
						
							| 
									
										
										
										
											2024-02-26 19:30:32 -06:00
										 |  |  | # Whether to use a dot as a folder separator in log names | 
					
						
							|  |  |  | dotFolder = true | 
					
						
							| 
									
										
										
										
											2024-02-04 18:19:19 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-10 13:35:47 -06:00
										 |  |  | # config for output types | 
					
						
							| 
									
										
										
										
											2024-02-04 18:19:19 -06:00
										 |  |  | [output] | 
					
						
							| 
									
										
										
										
											2024-02-10 13:35:47 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | # This one just prints the logs to stdout when run | 
					
						
							| 
									
										
										
										
											2024-02-04 18:19:19 -06:00
										 |  |  | [output.stdout] | 
					
						
							|  |  |  | enabled = true | 
					
						
							|  |  |  | [output.stdout.config] | 
					
						
							| 
									
										
										
										
											2024-02-10 13:35:47 -06:00
										 |  |  | # Whether to output as JSON. Maybe useful to pipe elsewhere. | 
					
						
							| 
									
										
										
										
											2024-02-04 18:19:19 -06:00
										 |  |  | json = false | 
					
						
							| 
									
										
										
										
											2024-02-10 13:35:47 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-04 18:19:19 -06:00
										 |  |  | ` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-10 13:35:47 -06:00
										 |  |  | func DefaultStr() string { | 
					
						
							| 
									
										
										
										
											2024-02-04 18:19:19 -06:00
										 |  |  | 	home, _ := os.UserHomeDir() | 
					
						
							|  |  |  | 	inDir := fp.Join(home, "my-log") | 
					
						
							| 
									
										
										
										
											2024-02-10 13:35:47 -06:00
										 |  |  | 	return fmt.Sprintf(ConfigStr, inDir) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func DefaultConfig() (Config, error) { | 
					
						
							|  |  |  | 	s := DefaultStr() | 
					
						
							| 
									
										
										
										
											2024-02-04 18:19:19 -06:00
										 |  |  | 	c := Config{} | 
					
						
							|  |  |  | 	_, err := toml.Decode(s, &c) | 
					
						
							|  |  |  | 	return c, err | 
					
						
							|  |  |  | } |