accesslogs

package
v0.1.72 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: MIT Imports: 21 Imported by: 8

Documentation

Index

Constants

View Source
const (
	AccessLogFieldHeader       = 1
	AccessLogFieldSentHeader   = 2
	AccessLogFieldArg          = 3
	AccessLogFieldCookie       = 4
	AccessLogFieldExtend       = 5
	AccessLogFieldReferer      = 6
	AccessLogFieldUserAgent    = 7
	AccessLogFieldRequestBody  = 8
	AccessLogFieldResponseBody = 9
)

Variables

View Source
var AccessLogFields = []maps.Map{
	{
		"code": AccessLogFieldHeader,
		"name": "请求Header列表",
	},
	{
		"code": AccessLogFieldSentHeader,
		"name": "响应Header列表",
	},
	{
		"code": AccessLogFieldArg,
		"name": "参数列表",
	},
	{
		"code": AccessLogFieldCookie,
		"name": "Cookie列表",
	},
	{
		"code": AccessLogFieldExtend,
		"name": "位置和浏览器分析",
	},
	{
		"code": AccessLogFieldReferer,
		"name": "请求来源",
	},
	{
		"code": AccessLogFieldUserAgent,
		"name": "终端信息",
	},
	{
		"code": AccessLogFieldRequestBody,
		"name": "请求Body",
	},
	{
		"code": AccessLogFieldResponseBody,
		"name": "响应Body",
	},
}

Functions

This section is empty.

Types

type AccessLog

type AccessLog struct {
	Id shared.ObjectId `var:"id" bson:"_id" json:"id"` // 数据库存储的ID

	ServerId   string `var:"serverId" bson:"serverId" json:"serverId"`       // 服务ID
	BackendId  string `var:"backendId" bson:"backendId" json:"backendId"`    // 后端服务ID
	LocationId string `var:"locationId" bson:"locationId" json:"locationId"` // 路径配置ID
	FastcgiId  string `var:"fastcgiId" bson:"fastcgiId" json:"fastcgiId"`    // Fastcgi配置ID
	RewriteId  string `var:"rewriteId" bson:"rewriteId" json:"rewriteId"`    // 重写规则ID

	TeaVersion      string  `var:"teaVersion" bson:"teaVersion" json:"teaVersion"`                // TeaWeb版本
	RemoteAddr      string  `var:"remoteAddr" bson:"remoteAddr" json:"remoteAddr"`                // 终端地址,通常是:ip:port
	RemotePort      int     `var:"remotePort" bson:"remotePort" json:"remotePort"`                // 终端端口
	RemoteUser      string  `var:"remoteUser" bson:"remoteUser" json:"remoteUser"`                // 终端用户,基于BasicAuth认证
	RequestURI      string  `var:"requestURI" bson:"requestURI" json:"requestURI"`                // 请求URI
	RequestPath     string  `var:"requestPath" bson:"requestPath" json:"requestPath"`             // 请求URI中的路径
	APIPath         string  `var:"apiPath" bson:"apiPath" json:"apiPath"`                         // API路径
	APIStatus       string  `var:"apiStatus" bson:"apiStatus" json:"apiStatus"`                   // API状态码
	RequestLength   int64   `var:"requestLength" bson:"requestLength" json:"requestLength"`       // 请求内容长度
	RequestTime     float64 `var:"requestTime" bson:"requestTime" json:"requestTime"`             // 从请求到所有响应数据发送到请求端所花时间,单位为带有小数点的秒,精确到纳秒,比如:0.000260081
	RequestMethod   string  `var:"requestMethod" bson:"requestMethod" json:"requestMethod"`       // 请求方法
	RequestFilename string  `var:"requestFilename" bson:"requestFilename" json:"requestFilename"` // 请求的文件名,包含完整的路径
	Scheme          string  `var:"scheme" bson:"scheme" json:"scheme"`                            // 请求协议,http或者https
	Proto           string  `var:"proto" bson:"proto" json:"proto"`                               // 请求协议,比如HTTP/1.0, HTTP/1.1

	BytesSent     int64               `var:"bytesSent" bson:"bytesSent" json:"bytesSent"`             // 响应的字节数,目前同 bodyBytesSent
	BodyBytesSent int64               `var:"bodyBytesSent" bson:"bodyBytesSent" json:"bodyBytesSent"` // 响应的字节数
	Status        int                 `var:"status" bson:"status" json:"status"`                      // 响应的状态码
	StatusMessage string              `var:"statusMessage" bson:"statusMessage" json:"statusMessage"` // 响应的信息
	SentHeader    map[string][]string `var:"sentHeader" bson:"sentHeader" json:"sentHeader"`          // 响应的头信息

	TimeISO8601    string              `var:"timeISO8601" bson:"timeISO8601" json:"timeISO8601"`          // ISO 8601格式的本地时间,比如 2018-07-16T23:52:24.839+08:00
	TimeLocal      string              `var:"timeLocal" bson:"timeLocal" json:"timeLocal"`                // 本地时间,比如 17/Jul/2018:09:52:24 +0800
	Msec           float64             `var:"msec" bson:"msec" json:"msec"`                               // 带有毫秒的时间,比如 1531756823.054
	Timestamp      int64               `var:"timestamp" bson:"timestamp" json:"timestamp"`                // unix时间戳,单位为秒
	Host           string              `var:"host" bson:"host" json:"host"`                               // 主机名
	Referer        string              `var:"referer" bson:"referer" json:"referer"`                      // 请求来源URL
	UserAgent      string              `var:"userAgent" bson:"userAgent" json:"userAgent"`                // 客户端信息
	Request        string              `var:"request" bson:"request" json:"request"`                      // 请求的简要说明,格式类似于 GET /hello/world HTTP/1.1
	ContentType    string              `var:"contentType" bson:"contentType" json:"contentType"`          // 请求头部的Content-Type
	Cookie         map[string]string   `bson:"cookie" json:"cookie"`                                      // Cookie cookie.name, cookie.sid
	Arg            map[string][]string `bson:"arg" json:"arg"`                                            // arg_name, arg_id
	Args           string              `var:"args" bson:"args" json:"args"`                               // name=liu&age=20
	QueryString    string              `var:"queryString" bson:"queryString" json:"queryString"`          // 同 Args
	Header         map[string][]string `bson:"header" json:"header"`                                      // 请求的头部信息,支持header_*和http_*,header_content_type, header_expires, http_content_type, http_user_agent
	ServerName     string              `var:"serverName" bson:"serverName" json:"serverName"`             // 接收请求的服务器名
	ServerPort     int                 `var:"serverPort" bson:"serverPort" json:"serverPort"`             // 服务器端口
	ServerProtocol string              `var:"serverProtocol" bson:"serverProtocol" json:"serverProtocol"` // 服务器协议,类似于HTTP/1.0”

	// 代理相关
	BackendAddress string `var:"backendAddress" bson:"backendAddress" json:"backendAddress"` // 代理的后端的地址
	FastcgiAddress string `var:"fastcgiAddress" bson:"fastcgiAddress" json:"fastcgiAddress"` // Fastcgi后端地址

	// 调试用
	RequestData        []byte `var:"" bson:"requestData" json:"requestData"`               // 请求数据
	ResponseHeaderData []byte `var:"" bson:"responseHeaderData" json:"responseHeaderData"` // 响应Header数据
	ResponseBodyData   []byte `var:"" bson:"responseBodyData" json:"responseBodyData"`     // 响应Body数据

	// 错误信息
	Errors    []string `var:"errors" bson:"errors" json:"errors"`          // 错误信息
	HasErrors bool     `var:"hasErrors" bson:"hasErrors" json:"hasErrors"` // 是否包含有错误信息

	// 扩展
	Extend *AccessLogExtend  `bson:"extend" json:"extend"`
	Attrs  map[string]string `bson:"attrs" json:"attrs"`

	// 日志
	StorageOnly      bool     `bson:"storageOnly" json:"storageOnly"`           // 是否只存储到日志策略中
	StoragePolicyIds []string `bson:"storagePolicyIds" json:"storagePolicyIds"` // 日志策略Ids
	// contains filtered or unexported fields
}

func NewAccessLog

func NewAccessLog() *AccessLog

获取新对象

func (*AccessLog) CleanFields

func (this *AccessLog) CleanFields()

清除不必要的的字段

func (*AccessLog) Format

func (this *AccessLog) Format(format string) string

func (*AccessLog) GetHeader

func (this *AccessLog) GetHeader(name string) string

获取Header内容

func (*AccessLog) MarshalJSON

func (j *AccessLog) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*AccessLog) MarshalJSONBuf

func (j *AccessLog) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*AccessLog) Parse

func (this *AccessLog) Parse()

分析mime,扩展名、代理设置等

func (*AccessLog) SentContentType

func (this *AccessLog) SentContentType() string

func (*AccessLog) SetShouldStat

func (this *AccessLog) SetShouldStat(b bool)

设置是否支持统计

func (*AccessLog) SetShouldWrite

func (this *AccessLog) SetShouldWrite(b bool)

设置是否写入

func (*AccessLog) SetWritingFields

func (this *AccessLog) SetWritingFields(fields []int)

设置写入的字段

func (*AccessLog) ShouldStat

func (this *AccessLog) ShouldStat() bool

是否支持统计

func (*AccessLog) ShouldWrite

func (this *AccessLog) ShouldWrite() bool

是否支持写入

func (*AccessLog) Time

func (this *AccessLog) Time() time.Time

获取访问日志的请求时间

func (*AccessLog) UnmarshalJSON

func (j *AccessLog) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*AccessLog) UnmarshalJSONFFLexer

func (j *AccessLog) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type AccessLogClient

type AccessLogClient struct {
	OS      AccessLogClientOS      `bson:"os" json:"os"`
	Device  AccessLogClientDevice  `bson:"device" json:"device"`
	Browser AccessLogClientBrowser `bson:"browser" json:"browser"`
}

func (*AccessLogClient) MarshalJSON

func (j *AccessLogClient) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*AccessLogClient) MarshalJSONBuf

func (j *AccessLogClient) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*AccessLogClient) UnmarshalJSON

func (j *AccessLogClient) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*AccessLogClient) UnmarshalJSONFFLexer

func (j *AccessLogClient) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type AccessLogClientBrowser

type AccessLogClientBrowser struct {
	Family string `bson:"family" json:"family"`
	Major  string `bson:"major" json:"major"`
	Minor  string `bson:"minor" json:"minor"`
	Patch  string `bson:"patch" json:"patch"`
}

func (*AccessLogClientBrowser) MarshalJSON

func (j *AccessLogClientBrowser) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*AccessLogClientBrowser) MarshalJSONBuf

func (j *AccessLogClientBrowser) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*AccessLogClientBrowser) UnmarshalJSON

func (j *AccessLogClientBrowser) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*AccessLogClientBrowser) UnmarshalJSONFFLexer

func (j *AccessLogClientBrowser) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type AccessLogClientDevice

type AccessLogClientDevice struct {
	Family string `bson:"family" json:"family"`
	Brand  string `bson:"brand" json:"brand"`
	Model  string `bson:"model" json:"model"`
}

func (*AccessLogClientDevice) MarshalJSON

func (j *AccessLogClientDevice) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*AccessLogClientDevice) MarshalJSONBuf

func (j *AccessLogClientDevice) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*AccessLogClientDevice) UnmarshalJSON

func (j *AccessLogClientDevice) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*AccessLogClientDevice) UnmarshalJSONFFLexer

func (j *AccessLogClientDevice) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type AccessLogClientOS

type AccessLogClientOS struct {
	Family     string `bson:"family" json:"family"`
	Major      string `bson:"major" json:"major"`
	Minor      string `bson:"minor" json:"minor"`
	Patch      string `bson:"patch" json:"patch"`
	PatchMinor string `bson:"patchMinor" json:"patchMinor"`
}

func (*AccessLogClientOS) MarshalJSON

func (j *AccessLogClientOS) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*AccessLogClientOS) MarshalJSONBuf

func (j *AccessLogClientOS) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*AccessLogClientOS) UnmarshalJSON

func (j *AccessLogClientOS) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*AccessLogClientOS) UnmarshalJSONFFLexer

func (j *AccessLogClientOS) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type AccessLogExtend

type AccessLogExtend struct {
	File   AccessLogFile   `bson:"file" json:"file"`
	Client AccessLogClient `bson:"client" json:"client"`
	Geo    AccessLogGeo    `bson:"geo" json:"geo"`
}

func (*AccessLogExtend) MarshalJSON

func (j *AccessLogExtend) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*AccessLogExtend) MarshalJSONBuf

func (j *AccessLogExtend) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*AccessLogExtend) UnmarshalJSON

func (j *AccessLogExtend) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*AccessLogExtend) UnmarshalJSONFFLexer

func (j *AccessLogExtend) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type AccessLogField

type AccessLogField = int

type AccessLogFile

type AccessLogFile struct {
	MimeType  string `bson:"mimeType" json:"mimeType"`   // 类似于 image/jpeg
	Extension string `bson:"extension" json:"extension"` // 扩展名,不带点(.)
	Charset   string `bson:"charset" json:"charset"`     // 字符集,统一大写
}

func (*AccessLogFile) MarshalJSON

func (j *AccessLogFile) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*AccessLogFile) MarshalJSONBuf

func (j *AccessLogFile) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*AccessLogFile) UnmarshalJSON

func (j *AccessLogFile) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*AccessLogFile) UnmarshalJSONFFLexer

func (j *AccessLogFile) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type AccessLogGeo

type AccessLogGeo struct {
	Region   string               `bson:"region" json:"region"`
	State    string               `bson:"state" json:"state"`
	City     string               `bson:"city" json:"city"`
	Location AccessLogGeoLocation `bson:"location" json:"location"`
}

func (*AccessLogGeo) MarshalJSON

func (j *AccessLogGeo) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*AccessLogGeo) MarshalJSONBuf

func (j *AccessLogGeo) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*AccessLogGeo) UnmarshalJSON

func (j *AccessLogGeo) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*AccessLogGeo) UnmarshalJSONFFLexer

func (j *AccessLogGeo) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type AccessLogGeoLocation

type AccessLogGeoLocation struct {
	Latitude       float64 `bson:"latitude" json:"latitude"`
	Longitude      float64 `bson:"longitude" json:"longitude"`
	TimeZone       string  `bson:"timeZone" json:"timeZone"`
	AccuracyRadius uint16  `bson:"accuracyRadius" json:"accuracyRadius"`
	MetroCode      uint    `bson:"metroCode" json:"metroCode"`
}

func (*AccessLogGeoLocation) MarshalJSON

func (j *AccessLogGeoLocation) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*AccessLogGeoLocation) MarshalJSONBuf

func (j *AccessLogGeoLocation) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*AccessLogGeoLocation) UnmarshalJSON

func (j *AccessLogGeoLocation) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*AccessLogGeoLocation) UnmarshalJSONFFLexer

func (j *AccessLogGeoLocation) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

Jump to

Keyboard shortcuts

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