types

package
v0.0.0-...-db893c4 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetServerIP = getServerIP

GetServerIP is a function for the unit test

View Source
var WriteEmptyAccessLog = func(context.Context, HTTPRequest) {}

WriteEmptyAccessLog writes empty log

Functions

This section is empty.

Types

type AccessLog

type AccessLog struct {
	Severity    string      `json:"severity"`
	Time        time.Time   `json:"time"`
	Trace       string      `json:"logging.googleapis.com/trace"`
	HTTPRequest HTTPRequest `json:"httpRequest"`
}

AccessLog is a log written by the service each time it is accessed by the client

type ApplicationLog

type ApplicationLog struct {
	Severity       string         `json:"severity"`
	Message        string         `json:"message"`
	Time           time.Time      `json:"time"`
	SourceLocation SourceLocation `json:"logging.googleapis.com/sourceLocation"`
	Trace          string         `json:"logging.googleapis.com/trace"`
	SpanID         string         `json:"logging.googleapis.com/spanId"`
	TraceSampled   bool           `json:"logging.googleapis.com/trace_sampled"`
}

ApplicationLog is a log written by the developer by any timing

type Duration

type Duration struct {
	Nanos   int32 `json:"nanos"`
	Seconds int64 `json:"seconds"`
}

Duration is duration format for protobuf see: https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#duration

func MakeDuration

func MakeDuration(d time.Duration) Duration

MakeDuration makes duration struct from time.Duration

type HTTPRequest

type HTTPRequest struct {
	RequestMethod string   `json:"requestMethod"`
	RequestURL    string   `json:"requestUrl"`
	RequestSize   string   `json:"requestSize,omitempty"`
	Status        int      `json:"status"`
	ResponseSize  string   `json:"responseSize,omitempty"`
	UserAgent     string   `json:"userAgent,omitempty"`
	RemoteIP      string   `json:"remoteIp,omitempty"`
	ServerIP      string   `json:"serverIp,omitempty"`
	Referer       string   `json:"referer,omitempty"`
	Latency       Duration `json:"latency"`
	Protocol      string   `json:"protocol"`
}

HTTPRequest is a http request struct for the access log

func MakeHTTPRequest

func MakeHTTPRequest(r http.Request, status, responseSize int, elapsed time.Duration) HTTPRequest

MakeHTTPRequest makes HTTPRequest struct from http.Request

type SourceLocation

type SourceLocation struct {
	File     string `json:"file"`
	Line     string `json:"line"`
	Function string `json:"function"`
}

SourceLocation is a location of source

type WriteAccessLogFunc

type WriteAccessLogFunc func(ctx context.Context, req HTTPRequest)

WriteAccessLogFunc is function type that writes an access log

Jump to

Keyboard shortcuts

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