on main help sign in
refactor(log): rename log initialization function for clarity
commitc2d0d64c7d70582466e309bbc3bb36fce86fe26c authorAyman Bagabas <ayman.bagabas@gmail.com> dateTue 8 Jul 2025, 15:55 (1 year ago) parentedd4996
3 files changed+6−10
internal/config/load.go+2−6 internal/fsext/fileutil.go+2−2 internal/log/log.go+2−2
internal/config/load.go+2−6
@@ -52,16 +52,12 @@ func Load(workingDir string, debug bool) (*Config, error) {
5252 cfg.Options.Debug = true
5353 }
5454
55− // Init logs
56− log.Init(
55+ // Setup logs
56+ log.Setup(
5757 filepath.Join(cfg.Options.DataDirectory, "logs", fmt.Sprintf("%s.log", appName)),
5858 cfg.Options.Debug,
5959 )
6060
61− if err != nil {
62− return nil, fmt.Errorf("failed to load config: %w", err)
63− }
64−
6561 // Load known providers, this loads the config from fur
6662 providers, err := LoadProviders(client.New())
6763 if err != nil || len(providers) == 0 {
internal/fsext/fileutil.go+2−2
@@ -26,13 +26,13 @@ func init() {
2626 var err error
2727 rgPath, err = exec.LookPath("rg")
2828 if err != nil {
29− if log.IsInitialized() {
29+ if log.Initialized() {
3030 slog.Warn("Ripgrep (rg) not found in $PATH. Some features might be limited or slower.")
3131 }
3232 }
3333 fzfPath, err = exec.LookPath("fzf")
3434 if err != nil {
35− if log.IsInitialized() {
35+ if log.Initialized() {
3636 slog.Warn("FZF not found in $PATH. Some features might be limited or slower.")
3737 }
3838 }
internal/log/log.go+2−2
@@ -17,7 +17,7 @@ var (
1717 initialized atomic.Bool
1818)
1919
20−func Init(logFile string, debug bool) {
20+func Setup(logFile string, debug bool) {
2121 initOnce.Do(func() {
2222 logRotator := &lumberjack.Logger{
2323 Filename: logFile,
@@ -42,7 +42,7 @@ func Init(logFile string, debug bool) {
4242 })
4343}
4444
45−func IsInitialized() bool {
45+func Initialized() bool {
4646 return initialized.Load()
4747}
4848