mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-18 05:02:15 +01:00
improving logging (#5)
* small refactoring of error messages * (very) small refactoring of structs instantiation * improving logging with debug messages * using INFO level as default + changing previous debug message to info message
This commit is contained in:
@@ -8,7 +8,9 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/thecodingmachine/gotenberg/app/config"
|
||||
"github.com/thecodingmachine/gotenberg/app/logger"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/satori/go.uuid"
|
||||
)
|
||||
|
||||
@@ -30,10 +32,7 @@ func NewFile(workingDir string, r io.Reader, fileName string) (*File, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
f := &File{
|
||||
Extension: ext,
|
||||
Path: MakeFilePath(workingDir, ext),
|
||||
}
|
||||
f := &File{ext, MakeFilePath(workingDir, ext)}
|
||||
|
||||
file, err := os.Create(f.Path)
|
||||
if err != nil {
|
||||
@@ -42,7 +41,7 @@ func NewFile(workingDir string, r io.Reader, fileName string) (*File, error) {
|
||||
|
||||
defer file.Close()
|
||||
|
||||
_, err = io.Copy(file, r)
|
||||
n, err := io.Copy(file, r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -50,6 +49,7 @@ func NewFile(workingDir string, r io.Reader, fileName string) (*File, error) {
|
||||
// resets the read pointer.
|
||||
file.Seek(0, 0)
|
||||
|
||||
logger.Debugf("working file %s has been created from %s (%s copied)", f.Path, fileName, humanize.Bytes(uint64(n)))
|
||||
return f, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user