mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-17 20:52:14 +01:00
feat: improve 'logger' field from logger
This commit is contained in:
@@ -31,7 +31,7 @@ func Command(logger *zap.Logger, binPath string, args ...string) Cmd {
|
|||||||
|
|
||||||
return Cmd{
|
return Cmd{
|
||||||
ctx: nil,
|
ctx: nil,
|
||||||
logger: logger.Named("cmd"),
|
logger: logger.Named(strings.ReplaceAll(binPath, "/", "")),
|
||||||
process: cmd,
|
process: cmd,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ func CommandContext(ctx context.Context, logger *zap.Logger, binPath string, arg
|
|||||||
|
|
||||||
return Cmd{
|
return Cmd{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
logger: logger.Named("cmd"),
|
logger: logger.Named(strings.ReplaceAll(binPath, "/", "")),
|
||||||
process: cmd,
|
process: cmd,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
@@ -147,10 +148,17 @@ func loggerMiddleware(logger *zap.Logger, disableLoggingForPaths []string) echo.
|
|||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
startTime := c.Get("startTime").(time.Time)
|
startTime := c.Get("startTime").(time.Time)
|
||||||
trace := c.Get("trace").(string)
|
trace := c.Get("trace").(string)
|
||||||
|
rootPath := c.Get("rootPath").(string)
|
||||||
|
|
||||||
// Create the request logger and add it to our locals.
|
// Create the request logger and add it to our locals.
|
||||||
reqLogger := logger.With(zap.String("trace", trace))
|
reqLogger := logger.With(zap.String("trace", trace))
|
||||||
c.Set("logger", reqLogger)
|
c.Set("logger", reqLogger.Named(func() string {
|
||||||
|
return strings.ReplaceAll(
|
||||||
|
strings.ReplaceAll(c.Request().URL.Path, rootPath, ""),
|
||||||
|
"/",
|
||||||
|
"",
|
||||||
|
)
|
||||||
|
}()))
|
||||||
|
|
||||||
// Call the next middleware in the chain.
|
// Call the next middleware in the chain.
|
||||||
err := next(c)
|
err := next(c)
|
||||||
@@ -159,7 +167,6 @@ func loggerMiddleware(logger *zap.Logger, disableLoggingForPaths []string) echo.
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, path := range disableLoggingForPaths {
|
for _, path := range disableLoggingForPaths {
|
||||||
rootPath := c.Get("rootPath").(string)
|
|
||||||
URI := fmt.Sprintf("%s%s", rootPath, path)
|
URI := fmt.Sprintf("%s%s", rootPath, path)
|
||||||
|
|
||||||
if c.Request().RequestURI == URI {
|
if c.Request().RequestURI == URI {
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ func (mod Chromium) Routes() ([]api.Route, error) {
|
|||||||
// drastically. In such a scenario, the given context may also be done before
|
// drastically. In such a scenario, the given context may also be done before
|
||||||
// the end of the conversion.
|
// the end of the conversion.
|
||||||
func (mod Chromium) PDF(ctx context.Context, logger *zap.Logger, URL, outputPath string, options Options) error {
|
func (mod Chromium) PDF(ctx context.Context, logger *zap.Logger, URL, outputPath string, options Options) error {
|
||||||
debug := debugLogger{logger: logger.Named("chromium.debug")}
|
debug := debugLogger{logger: logger.Named("browser")}
|
||||||
userProfileDirPath := gotenberg.NewDirPath()
|
userProfileDirPath := gotenberg.NewDirPath()
|
||||||
|
|
||||||
args := append(chromedp.DefaultExecAllocatorOptions[:],
|
args := append(chromedp.DefaultExecAllocatorOptions[:],
|
||||||
|
|||||||
Reference in New Issue
Block a user