slog

package module
v2.0.0-...-d5bc6a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Flush

func Flush(ctx context.Context)

func FlushWithHTTPResponse

func FlushWithHTTPResponse(ctx context.Context, response *HTTPResponse)

func Info

func Info(ctx context.Context, message interface{})
Example
sn := dogtime.StockNower{}
dogtime.SetNower(&sn)

now := time.Date(2019, 1, 2, 3, 4, 5, 6, time.UTC)
sn.AddStockTime(now)

ctx := slog.WithValue(context.Background())
slog.Info(ctx, slog.KV{"hoge", "fuga"})
slog.Flush(ctx)
Output:

{"timestamp":{"seconds":1546398245,"nanos":6},"messages":["{\"key\":\"hoge\",\"value\":\"fuga\"}"]}

func SetSpanID

func SetSpanID(ctx context.Context, spanID string)

func SetTraceID

func SetTraceID(ctx context.Context, traceID string)

func WithValue

func WithValue(ctx context.Context) context.Context

WithVlaue is WithValue

func WithValueForHTTP

func WithValueForHTTP(ctx context.Context, r *http.Request) context.Context

WithValueForHTTP is WithValue for HTTP Request

Types

type HTTPRequest

type HTTPRequest struct {
	RequestMethod                  string `json:"requestMethod"`
	RequestURL                     string `json:"requestUrl"`
	RequestSize                    int64  `json:"requestSize,string,omitempty"`
	Status                         int    `json:"status,omitempty"`
	ResponseSize                   int64  `json:"responseSize,string,omitempty"`
	UserAgent                      string `json:"userAgent,omitempty"`
	RemoteIP                       string `json:"remoteIp,omitempty"`
	Referer                        string `json:"referer,omitempty"`
	Latency                        string `json:"latency,omitempty"`
	CacheLookup                    *bool  `json:"cacheLookup,omitempty"`
	CacheHit                       *bool  `json:"cacheHit,omitempty"`
	CacheValidatedWithOriginServer *bool  `json:"cacheValidatedWithOriginServer,omitempty"`
	CacheFillBytes                 *int64 `json:"cacheFillBytes,string,omitempty"`
	Protocol                       string `json:"protocol"`
}

HTTPRequest provides HTTPRequest log. spec: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#httprequest

type HTTPResponse

type HTTPResponse struct {
	Status int
}

HTTPResponse is FlushWithHTTPResponse にHTTP Responseの状態を渡すためのstruct

type KV

type KV struct {
	Key   string      `json:"key"`
	Value interface{} `json:"value"`
}

type LogContainer

type LogContainer struct {
	Entry LogEntry `json:"entry"`
}

LogContainer is Log Object

func Value

func Value(ctx context.Context) (*LogContainer, bool)

Value is return to LogEntry

type LogEntry

type LogEntry struct {
	LogName   string            `json:"logName"`
	Timestamp Timestamp         `json:"timestamp"`
	TraceID   string            `json:"trace,omitempty"`
	SpanID    string            `json:"spanId,omitempty"`
	Operation LogEntryOperation `json:"operation,omitempty"`
	Messages  []string          `json:"messages"`
	Severity  string            `json:"severity,omitempty"`

	HTTPRequest *HTTPRequest `json:"httpRequest,omitempty"`
	// contains filtered or unexported fields
}

LogEntry is Stackdriver Logging Entry

type LogEntryOperation

type LogEntryOperation struct {
	ID       string `json:"id"`
	Producer string `json:"producer"`
	First    bool   `json:"first"`
	Last     bool   `json:"last"`
}

LogEntryOperation is Additional information about a potentially long-running operation with which a log entry is associated. spec: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#logentryoperation

type Severity

type Severity int

Severity is Stackdriver Logging Log Level

const (
	DEBUG Severity = iota
	INFO
	WARNING
	ERROR
)

Stackdriver Logging Log Level List

type Timestamp

type Timestamp struct {
	Seconds int64 `json:"seconds"`
	Nanos   int   `json:"nanos"`
}

Timestamp is Stackdriver Logging Timestamp

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL