aboutsummaryrefslogtreecommitdiff
path: root/tar.go
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2021-09-14 15:37:50 +0200
committern-peugnet <n.peugnet@free.fr>2021-09-14 15:41:44 +0200
commit33967236e18c33d0d83b34b76f8238c3d588b21d (patch)
tree9bd3334b6eabb7cd3b07d7efb9c4c90aa8726a6d /tar.go
parentd85847ec99d44e1010a95c71579a754ac9f7c646 (diff)
downloaddna-backup-33967236e18c33d0d83b34b76f8238c3d588b21d.tar.gz
dna-backup-33967236e18c33d0d83b34b76f8238c3d588b21d.zip
logger add panic + colors & remove ln variants & use it
Diffstat (limited to 'tar.go')
-rw-r--r--tar.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/tar.go b/tar.go
index e2703c8..ba7f3a5 100644
--- a/tar.go
+++ b/tar.go
@@ -3,8 +3,9 @@ package main
import (
"archive/tar"
"io"
- "log"
"os"
+
+ "github.com/n-peugnet/dna-backup/logger"
)
func streamFilesTar(files []File, stream io.WriteCloser) {
@@ -12,30 +13,30 @@ func streamFilesTar(files []File, stream io.WriteCloser) {
for _, f := range files {
file, err := os.Open(f.Path)
if err != nil {
- log.Printf("Error reading file '%s': %s\n", f.Path, err)
+ logger.Errorf("reading file '%s': %s", f.Path, err)
continue
}
stat, err := file.Stat()
if err != nil {
- log.Printf("Error getting stat of file '%s': %s\n", f.Path, err)
+ logger.Errorf("getting stat of file '%s': %s", f.Path, err)
continue
}
hdr, err := tar.FileInfoHeader(stat, "")
if err != nil {
- log.Printf("Error creating tar header for file '%s': %s\n", f.Path, err)
+ logger.Errorf("creating tar header for file '%s': %s", f.Path, err)
continue
}
if err := tarStream.WriteHeader(hdr); err != nil {
- log.Panicf("Error writing tar header to stream for file '%s': %s\n", f.Path, err)
+ logger.Panicf("writing tar header to stream for file '%s': %s", f.Path, err)
}
if _, err := io.Copy(tarStream, file); err != nil {
- log.Panicf("Error writing file to stream '%s': %s\n", f.Path, err)
+ logger.Panicf("writing file to stream '%s': %s", f.Path, err)
}
}
if err := tarStream.Close(); err != nil {
- log.Panic("Error closing tar stream:", err)
+ logger.Panic("closing tar stream:", err)
}
if err := stream.Close(); err != nil {
- log.Panic("Error closing stream:", err)
+ logger.Panic("closing stream:", err)
}
}