WIP: refactoring logging system

This commit is contained in:
Julien Neuhart
2019-07-01 17:11:23 +02:00
parent 8ca9866440
commit a4aa8dafac
19 changed files with 225 additions and 391 deletions

View File

@@ -7,9 +7,9 @@ import (
"io/ioutil"
"path/filepath"
"github.com/labstack/gommon/random"
"github.com/microcosm-cc/bluemonday"
"github.com/russross/blackfriday/v2"
"github.com/thecodingmachine/gotenberg/internal/pkg/rand"
)
// NewMarkdown returns a Markdown printer.
@@ -27,10 +27,7 @@ func NewMarkdown(fpath string, opts *ChromeOptions) (Printer, error) {
if err := tmpl.Execute(&buffer, data); err != nil {
return nil, fmt.Errorf("%s: executing template: %v", fpath, err)
}
baseFilename, err := rand.Get()
if err != nil {
return nil, err
}
baseFilename := random.String(32)
dst := fmt.Sprintf("%s/%s.html", dirPath, baseFilename)
if err := ioutil.WriteFile(dst, buffer.Bytes(), 0644); err != nil {
return nil, fmt.Errorf("%s: writing file: %v", dst, err)

View File

@@ -9,7 +9,7 @@ import (
"sync"
"time"
"github.com/thecodingmachine/gotenberg/internal/pkg/rand"
"github.com/labstack/gommon/random"
)
type office struct {
@@ -38,10 +38,7 @@ func (p *office) Print(destination string) error {
fpaths := make([]string, len(p.fpaths))
dirPath := filepath.Dir(destination)
for i, fpath := range p.fpaths {
baseFilename, err := rand.Get()
if err != nil {
return err
}
baseFilename := random.String(32)
tmpDest := fmt.Sprintf("%s/%d%s.pdf", dirPath, i, baseFilename)
if err := unoconv(ctx, fpath, tmpDest, p.opts); err != nil {
return err