Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/itsubaki/logger
Logger for Google Cloud Logging
https://github.com/itsubaki/logger
google-cloud logger
Last synced: 28 days ago
JSON representation
Logger for Google Cloud Logging
- Host: GitHub
- URL: https://github.com/itsubaki/logger
- Owner: itsubaki
- License: mit
- Created: 2022-09-18T04:40:39.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-19T12:15:56.000Z (9 months ago)
- Last Synced: 2024-06-19T01:51:57.010Z (7 months ago)
- Topics: google-cloud, logger
- Language: Go
- Homepage:
- Size: 120 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# logger
Example of using gin-gonic/gin.
```go
import (
"net/http""github.com/gin-gonic/gin"
"github.com/itsubaki/logger"
"github.com/itsubaki/tracer"
"go.opentelemetry.io/otel"
)var tr = otel.Tracer("mypackage/myfunc")
func Func(c *gin.Context) {
traceID := c.GetString("trace_id")
spanID := c.GetString("span_id")
traceTrue := c.GetBool("trace_true")log := logger.New(c.Request, traceID, spanID)
parent, err := tracer.Context(c.Request.Context(), traceID, spanID, traceTrue)
if err != nil {
log.ErrorReport("new context: %v", err)
return
}
log.Info("new tracer context")func() {
_, s := tr.Start(parent, "something to do")
defer s.End()log.Span(s).Info("something to do")
}()...
}
```