Documentation ¶
Index ¶
- func Flush(ctx context.Context)
- func FlushWithHTTPResponse(ctx context.Context, response *HTTPResponse)
- func Info(ctx context.Context, message interface{})
- func SetSpanID(ctx context.Context, spanID string)
- func SetTraceID(ctx context.Context, traceID string)
- func WithValue(ctx context.Context) context.Context
- func WithValueForHTTP(ctx context.Context, r *http.Request) context.Context
- type HTTPRequest
- type HTTPResponse
- type KV
- type LogContainer
- type LogEntry
- type LogEntryOperation
- type Severity
- type Timestamp
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FlushWithHTTPResponse ¶
func FlushWithHTTPResponse(ctx context.Context, response *HTTPResponse)
func Info ¶
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 SetTraceID ¶
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 LogContainer ¶
type LogContainer struct {
Entry LogEntry `json:"entry"`
}
LogContainer is Log Object
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
Click to show internal directories.
Click to hide internal directories.