Skip to content

Commit

Permalink
Merge pull request #11 from emahiro/fix/goreportcard_feedback
Browse files Browse the repository at this point in the history
Fix/goreportcard feedback
  • Loading branch information
Hiromichi Ema authored Aug 9, 2019
2 parents b47a3b1 + 761dbc1 commit e897d4e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Build Status](https://travis-ci.org/emahiro/ae-plain-logger.svg?branch=master)](https://travis-ci.org/emahiro/ae-plain-logger)
[![Go Report Card](https://goreportcard.com/badge/github.com/emahiro/ae-plain-logger)](https://goreportcard.com/report/github.com/emahiro/ae-plain-logger)


# App Engine Plain Logger
Expand Down
20 changes: 6 additions & 14 deletions log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,31 @@ import (
"github.com/emahiro/ae-plain-logger/spancontext"
)

const (
LevelDebug = "DEBUG"
LevelInfo = "INFO"
LevelWarning = "WARNING"
LevelError = "ERROR"
LevelCritical = "CRITICAL"
)

var projectID = os.Getenv("GOOGLE_CLOUD_PROJECT")

// Debugf is output of debug level log
func Debugf(ctx context.Context, format string, a ...interface{}) {
out(ctx, LevelDebug, format, a)
out(ctx, "DEBUG", format, a)
}

// Infof is output of infomation level log
// Infof is output of information level log
func Infof(ctx context.Context, format string, a ...interface{}) {
out(ctx, LevelInfo, format, a)
out(ctx, "INFO", format, a)
}

// Warningf is output of warning level log
func Warningf(ctx context.Context, format string, a ...interface{}) {
out(ctx, LevelWarning, format, a)
out(ctx, "WARNING", format, a)
}

// Errorf is output of error level log
func Errorf(ctx context.Context, format string, a ...interface{}) {
out(ctx, LevelError, format, a)
out(ctx, "ERROR", format, a)
}

// Criticalf is output of critical level log
func Criticalf(ctx context.Context, format string, a ...interface{}) {
out(ctx, LevelCritical, format, a)
out(ctx, "CRITICAL", format, a)
}

type jsonPayload struct {
Expand Down
3 changes: 3 additions & 0 deletions spancontext/spancontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import (
"go.opencensus.io/trace"
)

// AEPlainLogSpanContext is SpanContext struct of AppEnginePlainLogger
type AEPlainLogSpanContext struct {
SpanID string
TraceID string
}

// Get is method of get AEPlainLogSpanContext
func Get(ctx context.Context) AEPlainLogSpanContext {
sc := trace.FromContext(ctx).SpanContext()
return AEPlainLogSpanContext{
Expand All @@ -21,6 +23,7 @@ func Get(ctx context.Context) AEPlainLogSpanContext {
}
}

// Set is method of set SpanContext in request
func Set(r *http.Request, label string) (context.Context, func()) {
ctx := r.Context()
span := new(trace.Span)
Expand Down

0 comments on commit e897d4e

Please sign in to comment.