Skip to content

Commit

Permalink
fix: add slog (#33)
Browse files Browse the repository at this point in the history
Signed-off-by: Ruslan Semagin <[email protected]>
  • Loading branch information
pixel365 authored Feb 21, 2025
1 parent 292416d commit f10a5dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions internal/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"io"
"log/slog"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -258,14 +259,14 @@ func zipIt(dirPath, archivePath string) error {

defer func(zipFile *os.File) {
if err := zipFile.Close(); err != nil {
fmt.Println(err)
slog.Error(err.Error())
}
}(zipFile)

zipWriter := zip.NewWriter(zipFile)
defer func(zipWriter *zip.Writer) {
if err := zipWriter.Close(); err != nil {
fmt.Println(err)
slog.Error(err.Error())
}
}(zipWriter)

Expand Down Expand Up @@ -301,7 +302,7 @@ func zipIt(dirPath, archivePath string) error {

defer func(srcFile *os.File) {
if err := srcFile.Close(); err != nil {
fmt.Println(err)
slog.Error(err.Error())
}
}(srcFile)

Expand Down
5 changes: 3 additions & 2 deletions internal/module_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package internal
import (
"context"
"fmt"
"log/slog"
"os"
"path/filepath"
"sync"
Expand All @@ -27,13 +28,13 @@ func (m *Module) Build() error {
defer func(logFile *os.File) {
err := logFile.Close()
if err != nil {
fmt.Println(err)
slog.Error(err.Error())
} else {
path := fmt.Sprintf("%s/%s", m.LogDirectory, logFile.Name())
path = filepath.Clean(path)
err := os.Rename(logFile.Name(), path)
if err != nil {
fmt.Println(err)
slog.Error(err.Error())
}
}
}(logFile)
Expand Down

0 comments on commit f10a5dc

Please sign in to comment.