Skip to content

Commit

Permalink
Automated commit by Forgejo Actions - Personal Bot
Browse files Browse the repository at this point in the history
  • Loading branch information
poniatowski-bot committed Jul 23, 2024
1 parent 0109e6d commit dde6ad8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions boillog.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const (
)

// LogIt Boilerplate funtion that calls Logger, to write logs, and prints it if it fails to write it
func LogIt(logFunction string, logOutput string, message string) {
func LogIt(logFunction string, logType string, message string) {
logPath := filepath.Join(envLogLocation(), envAppName())
dir := filepath.Dir(logPath)
if err := os.MkdirAll(dir, 0755); err != nil {
Expand All @@ -77,22 +77,22 @@ func LogIt(logFunction string, logOutput string, message string) {
return
}
defer file.Close()
errCloseLogger := logger(logFunction, strings.ToUpper(logOutput), message, file)
errCloseLogger := logger(logFunction, strings.ToUpper(logType), message, file)
if errCloseLogger != nil {
log.Printf("Error writing to log: %v", errCloseLogger)
}
}

// Logger This function is called by LogIt and prints/writes logs
func logger(logFunction string, logOutput string, message string, w io.Writer) error {
func logger(logFunction string, logType string, message string, w io.Writer) error {
timeNow := time.Now()
handler := slog.NewTextHandler(w, nil)
logger := slog.New(handler)
ctx := context.Background()
ctx = context.WithValue(ctx, slog.TimeKey, timeNow)
ctx = context.WithValue(ctx, FuncKey, logFunction)

switch logOutput {
switch logType {
case "INFO":
logger.InfoContext(ctx, message)
case "WARNING":
Expand Down

0 comments on commit dde6ad8

Please sign in to comment.