wip refactoring: better logging and error systems

This commit is contained in:
Julien Neuhart
2019-07-07 17:45:07 +02:00
parent a4aa8dafac
commit c8f7ea934c
36 changed files with 1346 additions and 1096 deletions

View File

@@ -5,7 +5,7 @@ import (
"time"
"github.com/mafredri/cdp/devtool"
log "github.com/thecodingmachine/gotenberg/internal/pkg/logger"
"github.com/thecodingmachine/gotenberg/internal/pkg/logger"
)
const warmupTime = 10 * time.Second
@@ -16,7 +16,7 @@ type chrome struct {
// NewChrome returns a Google Chrome
// headless process.
func NewChrome(logger *log.StandardLogger) Process {
func NewChrome(logger *logger.Logger) Process {
return &chrome{
manager: &processManager{logger: logger},
}
@@ -61,7 +61,10 @@ func (p *chrome) viable() bool {
// check if Google Chrome is correctly running.
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
p.manager.logger.Debugf("%s: checking liveness via debug version endpoint http://localhost:9222/json/version", p.Fullname())
p.manager.logger.Debugf(
"%s: checking liveness via debug version endpoint http://localhost:9222/json/version",
p.Fullname(),
)
v, err := devtool.New("http://localhost:9222").Version(ctx)
if err != nil {
p.manager.logger.Debugf("%s: debug version endpoint returned error: %v", p.Fullname(), err)

View File

@@ -7,7 +7,7 @@ import (
"os/exec"
"strings"
log "github.com/thecodingmachine/gotenberg/internal/pkg/logger"
"github.com/thecodingmachine/gotenberg/internal/pkg/logger"
)
const (
@@ -30,7 +30,7 @@ type Process interface {
type processManager struct {
heuristicState int32
logger *log.StandardLogger
logger *logger.Logger
}
func (m *processManager) start(p Process) error {

View File

@@ -1,7 +1,7 @@
package pm2
import (
log "github.com/thecodingmachine/gotenberg/internal/pkg/logger"
"github.com/thecodingmachine/gotenberg/internal/pkg/logger"
)
type unoconv struct {
@@ -10,7 +10,7 @@ type unoconv struct {
// NewUnoconv returns a unoconv listener
// process.
func NewUnoconv(logger *log.StandardLogger) Process {
func NewUnoconv(logger *logger.Logger) Process {
return &unoconv{
manager: &processManager{logger: logger},
}