docs(log): say the logs go to standard error

This commit is contained in:
Julien Neuhart
2026-11-05 16:18:54 +01:00
parent c7ecf208fb
commit 86265d7506
2 changed files with 5 additions and 5 deletions

View File

@@ -36,9 +36,9 @@ func Run() {
// Logging & telemetry flags. // Logging & telemetry flags.
fs.String("log-level", gotenberg.InfoLoggingLevel, "Set the log level") fs.String("log-level", gotenberg.InfoLoggingLevel, "Set the log level")
fs.String("log-fields-prefix", "", "Prepend a specified prefix to each log field key") fs.String("log-fields-prefix", "", "Prepend a specified prefix to each log field key")
fs.String("log-std-format", gotenberg.AutoLoggingFormat, "Set the log format for standard output") fs.String("log-std-format", gotenberg.AutoLoggingFormat, "Set the format of the logs Gotenberg writes to standard error")
fs.Bool("log-std-enable-gcp-fields", false, "Use GCP-compatible field names in log output") fs.Bool("log-std-enable-gcp-fields", false, "Use GCP-compatible field names in log output")
fs.String("log-std-level-case", gotenberg.LowerLevelCase, "Set the case of the level field in the standard output, either lower or upper") fs.String("log-std-level-case", gotenberg.LowerLevelCase, "Set the case of the level field in the logs Gotenberg writes to standard error, either lower or upper")
descriptors := gotenberg.GetModuleDescriptors() descriptors := gotenberg.GetModuleDescriptors()
for _, desc := range descriptors { for _, desc := range descriptors {

View File

@@ -18,7 +18,7 @@ const (
) )
// traceContextHandler is an internal wrapper that specifically injects // traceContextHandler is an internal wrapper that specifically injects
// trace_id and span_id into the log record before they are written to the standard output. // trace_id and span_id into the log record before they are written to the standard error.
type traceContextHandler struct { type traceContextHandler struct {
slog.Handler slog.Handler
} }
@@ -51,11 +51,11 @@ func (h traceContextHandler) WithGroup(name string) slog.Handler {
} }
// upperLevelCase is the value of the level-case setting that keeps the level // upperLevelCase is the value of the level-case setting that keeps the level
// field uppercase in the standard output. It mirrors gotenberg.UpperLevelCase, // field uppercase in the standard error. It mirrors gotenberg.UpperLevelCase,
// duplicated here because the internal log package cannot import gotenberg. // duplicated here because the internal log package cannot import gotenberg.
const upperLevelCase = "upper" const upperLevelCase = "upper"
// NewStdHandler returns a [slog.Handler] instance for the standard output. // NewStdHandler returns a [slog.Handler] instance that writes to the standard error.
func NewStdHandler(level slog.Level, format string, fieldsPrefix string, enableGcpFields bool, levelCase string) (slog.Handler, error) { func NewStdHandler(level slog.Level, format string, fieldsPrefix string, enableGcpFields bool, levelCase string) (slog.Handler, error) {
// #nosec: G115 // #nosec: G115
isTerminal := term.IsTerminal(int(os.Stdout.Fd())) isTerminal := term.IsTerminal(int(os.Stdout.Fd()))