Categorygithub.com/PumpkinSeed/slog-cloudlogging
repositorypackage
0.2.0
Repository: https://github.com/pumpkinseed/slog-cloudlogging.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

slog: Cloud Logging handler

Go Version

A Google Cloud Logging Handler for slog Go library.

Install

go get github.com/PumpkinSeed/slog-cloudlogging

Usage

GoDoc: https://pkg.go.dev/github.com/PumpkinSeed/slog-cloudlogging

Example

package main

import (
	"errors"
	"log/slog"
	"time"

	slogcloudlogging "github.com/PumpkinSeed/slog-cloudlogging"
)

func main() {
	googleHandler := slogcloudlogging.NewHandler("test", "test-logs", nil)
	googleHandler.AutoFlush()
	slog.SetDefault(slog.New(googleHandler))

	slog.Error("test message", slog.Any("error", errors.New("this is an error")))
	time.Sleep(2 * time.Second) // Wait for the Flush
}