Skip to content

Commit

Permalink
fix: create logs directory if non existent, close #63
Browse files Browse the repository at this point in the history
  • Loading branch information
HilkopterBob committed Oct 8, 2024
1 parent cb6a1f7 commit 2c13e1c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion logger/logger.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package logger

import (
"os"

"github.com/k0kubun/pp"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
Expand All @@ -9,7 +12,11 @@ var Logger *zap.SugaredLogger

// InitLogger initializes the zap.Logger once and returns the instance.
func InitLogger() (*zap.SugaredLogger, error) {
var err error
err := os.MkdirAll("logs/", os.ModePerm)
if err != nil {
pp.Printf("Couldn't create 'logs' directory. Got: %s", err)
panic(err)
}

// Ensure the logger is initialized only once
loggerConfig := zap.Config{
Expand Down

0 comments on commit 2c13e1c

Please sign in to comment.