Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultGoogleCloudLoggingHandlerLevelMapper ¶
DefaultGoogleCloudLoggingHandlerLevelMapper is a default function for mapping slog levels to GCP logging levels.
func NewGoogleCloudLoggingHandler ¶
func NewGoogleCloudLoggingHandler(opts GoogleCloudLoggingHandlerOptions) (*googleCloudLoggingHandler, error)
NewGoogleCloudLoggingHandler creates a new handler object.
Types ¶
type GoogleCloudLoggingHandlerOptions ¶
type GoogleCloudLoggingHandlerOptions struct { // ClientOptions is a list of options for the Google Cloud Logging client. ClientOptions []option.ClientOption // EnableAsync will execute the Handle() function in a separate goroutine. // // When async is enabled, you should be sure to call the Shutdown() function or use the slogx.Shutdown() // function to ensure all goroutines are finished and any pending records have been written. EnableAsync bool // Level is the minimum log level to write to the handler. // // By default, the level will be set to slog.LevelInfo if not supplied. Level slog.Leveler // LevelMapper is a function to use to map an slog.Leveler level to the corresponding Google Cloud Logging severity. // // If nil, the default mapper will be used, which should be fine for most cases. LevelMapper func(slog.Leveler) logging.Severity // LoggerOptions is a list of options to pass to the Google Cloud Logging client's underlying logger. LoggerOptions []logging.LoggerOption // LogName is the name of the log to use when logging messages. // // This option is required. LogName string // ProjectID is the ID of the GCP project to which the logger belongs. // // This option is required. ProjectID string // RecordFormatter specifies the formatter to use to format the record before sending it to the GCP logger. // // You should always be sure to format the buffer into a proper JSON payload. // // If no formatter is supplied, formatter.DefaultJSONFormatter is used to format the output. RecordFormatter formatter.BufferFormatter }
GoogleCloudLoggingHandlerOptions holds the options for the JSON handler.
func DefaultGoogleCloudLoggingHandlerOptions ¶ added in v0.2.0
func DefaultGoogleCloudLoggingHandlerOptions() GoogleCloudLoggingHandlerOptions
DefaultGoogleCloudLoggingHandlerOptions returns a default set of options for the handler.
func GetGoogleCloudLoggingHandlerOptionsFromContext ¶ added in v0.2.0
func GetGoogleCloudLoggingHandlerOptionsFromContext(ctx context.Context) *GoogleCloudLoggingHandlerOptions
GetGoogleCloudLoggingHandlerOptionsFromContext retrieves the options from the context.
If the options are not set in the context, a set of default options is returned instead.
func (*GoogleCloudLoggingHandlerOptions) AddToContext ¶ added in v0.2.0
func (o *GoogleCloudLoggingHandlerOptions) AddToContext(ctx context.Context) context.Context
AddToContext adds the options to the given context and returns the new context.
Click to show internal directories.
Click to hide internal directories.