https://github.com/wayneashleyberry/zaperations
Package zaperations provides a Google Cloud operations suite (formerly Stackdriver) compatible config for the uber-go/zap logger.
https://github.com/wayneashleyberry/zaperations
cloud config driver gcp go google googlecloud logger logging operation stack stackdriver zap
Last synced: 5 days ago
JSON representation
Package zaperations provides a Google Cloud operations suite (formerly Stackdriver) compatible config for the uber-go/zap logger.
- Host: GitHub
- URL: https://github.com/wayneashleyberry/zaperations
- Owner: wayneashleyberry
- License: mit
- Created: 2021-11-06T08:02:18.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-06T08:37:38.000Z (over 4 years ago)
- Last Synced: 2024-06-20T13:35:38.446Z (over 1 year ago)
- Topics: cloud, config, driver, gcp, go, google, googlecloud, logger, logging, operation, stack, stackdriver, zap
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
> Package zaperations provides a [Google Cloud Operations](https://cloud.google.com/products/operations) (formerly Stackdriver) compatible config for the excellent [uber-go/zap](https://github.com/uber-go/zap) logger.
[](https://pkg.go.dev/github.com/wayneashleyberry/zaperations)
[](https://github.com/wayneashleyberry/zaperations/actions/workflows/go.yml)
[](https://goreportcard.com/report/github.com/wayneashleyberry/zaperations)
## Example
_This example is using unreleased functionality from go tip that is set to be released in 1.18._
```go
package main
import (
"runtime/debug"
"github.com/wayneashleyberry/zaperations/pkg/logger"
"github.com/wayneashleyberry/zaperations/pkg/meta"
"go.uber.org/zap"
)
func main() {
log, err := logger.NewProduction()
if err != nil {
panic(err)
}
info, ok := debug.ReadBuildInfo()
if !ok {
panic("could not read build info")
}
var version string
for _, setting := range info.Settings {
if setting.Key == "gitrevision" {
version = setting.Value
}
}
log = log.With(zap.Object("serviceContext", meta.ServiceContext{
Service: "logger-demo",
Version: version,
}))
log.Info("Hello, World!")
}
```