https://github.com/pumpkinseed/slog-cloudlogging
Google Cloud Logging handler for Golang's slog package
https://github.com/pumpkinseed/slog-cloudlogging
Last synced: 6 months ago
JSON representation
Google Cloud Logging handler for Golang's slog package
- Host: GitHub
- URL: https://github.com/pumpkinseed/slog-cloudlogging
- Owner: PumpkinSeed
- License: mit
- Created: 2023-08-18T10:00:59.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-17T11:46:56.000Z (about 1 year ago)
- Last Synced: 2025-04-14T13:16:01.206Z (6 months ago)
- Language: Go
- Size: 24.4 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# slog: Cloud Logging handler

A Google Cloud Logging Handler for [slog](https://pkg.go.dev/log/slog) Go library.
## Install
```sh
go get github.com/PumpkinSeed/slog-cloudlogging
```## Usage
GoDoc: [https://pkg.go.dev/github.com/PumpkinSeed/slog-cloudlogging](https://pkg.go.dev/github.com/PumpkinSeed/slog-cloudlogging)
### Example
```go
package mainimport (
"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
}
```