Skip to content

brbranch/go-gae-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-gae-logger

Simple Logger for Google Cloud Logging that supports structured logging and Google Cloud Trace.
Currently, This package supports following service and framework:

Supporting Structure

  • severity
  • message
  • sourceLocation
  • spanId
  • trace

Usage

Using Echo

import (
	"net/http"
	
	"github.com/brbranch/go-gae-logger/logger"
	"github.com/brbranch/go-gae-logger/logger/framework/echoframework"
	"github.com/brbranch/go-gae-logger/logger/provider/otlm"
	"github.com/labstack/echo/v4"
	"github.com/labstack/echo/v4/middleware"
)

func main() {
    e := a.echo

    provider := otlm.Create("[ProjectName]/trace", os.Getenv("GOOGLE_CLOUD_PROJECT"))
    if /* expression to check local server */ {
        provider.LocalMode()
    }

    e.Use(echoframework.Middleware(provider))
    e.GET("/", func(c echo.Context) error {
        ctx , cf := logger.Span(c.Request().Context(), "index")
        defer cf()
		
		logger.Debug(ctx, "hello %s!", "logging")
		
        return c.String(http.StatusOK, "ok")
    })

    log.Fatal(e.Start(fmt.Sprintf(":%s", "8080")))
}

License

MIT

References

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages