Documentation ¶
Index ¶
- Constants
- Variables
- func CloudLoggingOptions(minimumLevel slog.Level) *slog.HandlerOptions
- func Ctx(ctx context.Context) *slog.Logger
- func WithCloudTraceContext(h http.Handler) http.Handler
- func WithLogger(ctx context.Context, l *slog.Logger) context.Context
- type CloudLoggingHandler
- func (h *CloudLoggingHandler) Enabled(ctx context.Context, level slog.Level) bool
- func (h *CloudLoggingHandler) Handle(ctx context.Context, rec slog.Record) error
- func (h *CloudLoggingHandler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *CloudLoggingHandler) WithGroup(name string) slog.Handler
Constants ¶
View Source
const (
LevelCritical = slog.Level(12)
)
Variables ¶
View Source
var ProjectID = os.Getenv("GOOGLE_CLOUD_PROJECT")
ProjectID is required for the trace entry.
Functions ¶
func CloudLoggingOptions ¶
func CloudLoggingOptions(minimumLevel slog.Level) *slog.HandlerOptions
CloudLoggingOptions return options for writing structured Google logging entries
func WithCloudTraceContext ¶
WithCloudTraceContext is HTTP Middleware that adds the Cloud Trace ID to the context This is used to correlate the structured logs with the Cloud Run request log.
Types ¶
type CloudLoggingHandler ¶
type CloudLoggingHandler struct {
// contains filtered or unexported fields
}
Handler that outputs JSON understood by the structured log agent. See https://cloud.google.com/logging/docs/agent/logging/configuration#special-fields
func NewCloudLoggingHandler ¶
func NewCloudLoggingHandler(minLevel slog.Level) *CloudLoggingHandler
NewCloudLoggingHandler return a new Handler that outputs JSON understood by the structured log agent.
Click to show internal directories.
Click to hide internal directories.