Documentation
¶
Index ¶
- Constants
- Variables
- func AddAccessLogHook(hook *AccessLogHook)
- func AllStorageFormats() []maps.Map
- func AllStorages() []maps.Map
- func CallAccessLogHooks(accessLog *AccessLog)
- func FindPolicyName(policyId string) string
- func FindStorageFormatName(code string) string
- func FindStorageTypeName(storageType string) string
- func ResetPolicyStorage(policyId string)
- type AccessLog
- func (this *AccessLog) CleanFields()
- func (this *AccessLog) Format(format string) string
- func (this *AccessLog) GetHeader(name string) string
- func (j *AccessLog) MarshalJSON() ([]byte, error)
- func (j *AccessLog) MarshalJSONBuf(buf fflib.EncodingBuffer) error
- func (this *AccessLog) Parse()
- func (this *AccessLog) SentContentType() string
- func (this *AccessLog) SetShouldStat(b bool)
- func (this *AccessLog) SetShouldWrite(b bool)
- func (this *AccessLog) SetWritingFields(fields []int)
- func (this *AccessLog) ShouldStat() bool
- func (this *AccessLog) ShouldWrite() bool
- func (this *AccessLog) Time() time.Time
- func (j *AccessLog) UnmarshalJSON(input []byte) error
- func (j *AccessLog) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
- type AccessLogClient
- type AccessLogClientBrowser
- func (j *AccessLogClientBrowser) MarshalJSON() ([]byte, error)
- func (j *AccessLogClientBrowser) MarshalJSONBuf(buf fflib.EncodingBuffer) error
- func (j *AccessLogClientBrowser) UnmarshalJSON(input []byte) error
- func (j *AccessLogClientBrowser) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
- type AccessLogClientDevice
- func (j *AccessLogClientDevice) MarshalJSON() ([]byte, error)
- func (j *AccessLogClientDevice) MarshalJSONBuf(buf fflib.EncodingBuffer) error
- func (j *AccessLogClientDevice) UnmarshalJSON(input []byte) error
- func (j *AccessLogClientDevice) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
- type AccessLogClientOS
- type AccessLogExtend
- type AccessLogField
- type AccessLogFile
- type AccessLogGeo
- type AccessLogGeoLocation
- func (j *AccessLogGeoLocation) MarshalJSON() ([]byte, error)
- func (j *AccessLogGeoLocation) MarshalJSONBuf(buf fflib.EncodingBuffer) error
- func (j *AccessLogGeoLocation) UnmarshalJSON(input []byte) error
- func (j *AccessLogGeoLocation) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
- type AccessLogHook
- type AccessLogQueue
- type AccessLogger
- type CommandStorage
- type ESStorage
- type FileStorage
- type MySQLStorage
- type Query
- func (this *Query) Action(action QueryAction) *Query
- func (this *Query) Asc(field string) *Query
- func (this *Query) Attr(field string, value interface{}) *Query
- func (this *Query) Debug() *Query
- func (this *Query) Desc(field string) *Query
- func (this *Query) Duration(duration QueryDuration) *Query
- func (this *Query) Execute() (interface{}, error)
- func (this *Query) Find() (*AccessLog, error)
- func (this *Query) FindAll() ([]*AccessLog, error)
- func (this *Query) For(field string) *Query
- func (this *Query) From(time time.Time) *Query
- func (this *Query) Group(group []string) *Query
- func (this *Query) Gt(field string, value interface{}) *Query
- func (this *Query) Gte(field string, value interface{}) *Query
- func (this *Query) Id(idString string) *Query
- func (this *Query) Limit(size int64) *Query
- func (this *Query) Lt(field string, value interface{}) *Query
- func (this *Query) Lte(field string, value interface{}) *Query
- func (this *Query) Not(field string, value interface{}) *Query
- func (this *Query) Offset(offset int64) *Query
- func (this *Query) Op(op string, field string, value interface{})
- func (this *Query) Result(field ...string) *Query
- func (this *Query) To(time time.Time) *Query
- type QueryAction
- type QueryDuration
- type Storage
- type StorageFormat
- type StorageInterface
- type StorageType
- type TCPStorage
Constants ¶
const ( AccessLogFieldHeader = 1 AccessLogFieldSentHeader = 2 AccessLogFieldArg = 3 AccessLogFieldCookie = 4 AccessLogFieldExtend = 5 AccessLogFieldReferer = 6 AccessLogFieldUserAgent = 7 AccessLogFieldRequestBody = 8 AccessLogFieldResponseBody = 9 )
const ( QueryDurationYearly = "yearly" QueryDurationMonthly = "monthly" QueryDurationDaily = "daily" QueryDurationHourly = "hourly" QueryDurationMinutely = "minutely" QueryDurationSecondly = "secondly" )
const ( QueryActionCount = "count" QueryActionSum = "sum" QueryActionAvg = "avg" QueryActionMin = "min" QueryActionMax = "max" QueryActionFind = "find" QueryActionFindAll = "findAll" )
const (
MongoLogSize = 256
)
导入的步长
Variables ¶
var AccessLogDefaultFieldsCodes = []int{ AccessLogFieldHeader, AccessLogFieldSentHeader, AccessLogFieldArg, AccessLogFieldCookie, AccessLogFieldExtend, AccessLogFieldReferer, AccessLogFieldUserAgent, }
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 ¶
func FindStorageFormatName ¶ added in v0.1.6
根据代号查找名称
func FindStorageTypeName ¶ added in v0.1.6
根据类型查找名称
Types ¶
type AccessLog ¶
type AccessLog struct {
Id primitive.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 (*AccessLog) MarshalJSON ¶ added in v0.1.6
MarshalJSON marshal bytes to json - template
func (*AccessLog) MarshalJSONBuf ¶ added in v0.1.6
func (j *AccessLog) MarshalJSONBuf(buf fflib.EncodingBuffer) error
MarshalJSONBuf marshal buff to json - template
func (*AccessLog) SentContentType ¶
func (*AccessLog) SetShouldWrite ¶ added in v0.1.2
设置是否写入
func (*AccessLog) SetWritingFields ¶ added in v0.1.2
设置写入的字段
func (*AccessLog) UnmarshalJSON ¶ added in v0.1.6
UnmarshalJSON umarshall json - template of ffjson
func (*AccessLog) UnmarshalJSONFFLexer ¶ added in v0.1.6
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 ¶ added in v0.1.6
func (j *AccessLogClient) MarshalJSON() ([]byte, error)
MarshalJSON marshal bytes to json - template
func (*AccessLogClient) MarshalJSONBuf ¶ added in v0.1.6
func (j *AccessLogClient) MarshalJSONBuf(buf fflib.EncodingBuffer) error
MarshalJSONBuf marshal buff to json - template
func (*AccessLogClient) UnmarshalJSON ¶ added in v0.1.6
func (j *AccessLogClient) UnmarshalJSON(input []byte) error
UnmarshalJSON umarshall json - template of ffjson
func (*AccessLogClient) UnmarshalJSONFFLexer ¶ added in v0.1.6
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 ¶ added in v0.1.6
func (j *AccessLogClientBrowser) MarshalJSON() ([]byte, error)
MarshalJSON marshal bytes to json - template
func (*AccessLogClientBrowser) MarshalJSONBuf ¶ added in v0.1.6
func (j *AccessLogClientBrowser) MarshalJSONBuf(buf fflib.EncodingBuffer) error
MarshalJSONBuf marshal buff to json - template
func (*AccessLogClientBrowser) UnmarshalJSON ¶ added in v0.1.6
func (j *AccessLogClientBrowser) UnmarshalJSON(input []byte) error
UnmarshalJSON umarshall json - template of ffjson
func (*AccessLogClientBrowser) UnmarshalJSONFFLexer ¶ added in v0.1.6
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 ¶ added in v0.1.6
func (j *AccessLogClientDevice) MarshalJSON() ([]byte, error)
MarshalJSON marshal bytes to json - template
func (*AccessLogClientDevice) MarshalJSONBuf ¶ added in v0.1.6
func (j *AccessLogClientDevice) MarshalJSONBuf(buf fflib.EncodingBuffer) error
MarshalJSONBuf marshal buff to json - template
func (*AccessLogClientDevice) UnmarshalJSON ¶ added in v0.1.6
func (j *AccessLogClientDevice) UnmarshalJSON(input []byte) error
UnmarshalJSON umarshall json - template of ffjson
func (*AccessLogClientDevice) UnmarshalJSONFFLexer ¶ added in v0.1.6
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 ¶ added in v0.1.6
func (j *AccessLogClientOS) MarshalJSON() ([]byte, error)
MarshalJSON marshal bytes to json - template
func (*AccessLogClientOS) MarshalJSONBuf ¶ added in v0.1.6
func (j *AccessLogClientOS) MarshalJSONBuf(buf fflib.EncodingBuffer) error
MarshalJSONBuf marshal buff to json - template
func (*AccessLogClientOS) UnmarshalJSON ¶ added in v0.1.6
func (j *AccessLogClientOS) UnmarshalJSON(input []byte) error
UnmarshalJSON umarshall json - template of ffjson
func (*AccessLogClientOS) UnmarshalJSONFFLexer ¶ added in v0.1.6
func (j *AccessLogClientOS) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
UnmarshalJSONFFLexer fast json unmarshall - template ffjson
type AccessLogExtend ¶ added in v0.1.2
type AccessLogExtend struct {
File AccessLogFile `bson:"file" json:"file"`
Client AccessLogClient `bson:"client" json:"client"`
Geo AccessLogGeo `bson:"geo" json:"geo"`
}
func (*AccessLogExtend) MarshalJSON ¶ added in v0.1.6
func (j *AccessLogExtend) MarshalJSON() ([]byte, error)
MarshalJSON marshal bytes to json - template
func (*AccessLogExtend) MarshalJSONBuf ¶ added in v0.1.6
func (j *AccessLogExtend) MarshalJSONBuf(buf fflib.EncodingBuffer) error
MarshalJSONBuf marshal buff to json - template
func (*AccessLogExtend) UnmarshalJSON ¶ added in v0.1.6
func (j *AccessLogExtend) UnmarshalJSON(input []byte) error
UnmarshalJSON umarshall json - template of ffjson
func (*AccessLogExtend) UnmarshalJSONFFLexer ¶ added in v0.1.6
func (j *AccessLogExtend) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
UnmarshalJSONFFLexer fast json unmarshall - template ffjson
type AccessLogField ¶ added in v0.1.2
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 ¶ added in v0.1.6
func (j *AccessLogFile) MarshalJSON() ([]byte, error)
MarshalJSON marshal bytes to json - template
func (*AccessLogFile) MarshalJSONBuf ¶ added in v0.1.6
func (j *AccessLogFile) MarshalJSONBuf(buf fflib.EncodingBuffer) error
MarshalJSONBuf marshal buff to json - template
func (*AccessLogFile) UnmarshalJSON ¶ added in v0.1.6
func (j *AccessLogFile) UnmarshalJSON(input []byte) error
UnmarshalJSON umarshall json - template of ffjson
func (*AccessLogFile) UnmarshalJSONFFLexer ¶ added in v0.1.6
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 ¶ added in v0.1.6
func (j *AccessLogGeo) MarshalJSON() ([]byte, error)
MarshalJSON marshal bytes to json - template
func (*AccessLogGeo) MarshalJSONBuf ¶ added in v0.1.6
func (j *AccessLogGeo) MarshalJSONBuf(buf fflib.EncodingBuffer) error
MarshalJSONBuf marshal buff to json - template
func (*AccessLogGeo) UnmarshalJSON ¶ added in v0.1.6
func (j *AccessLogGeo) UnmarshalJSON(input []byte) error
UnmarshalJSON umarshall json - template of ffjson
func (*AccessLogGeo) UnmarshalJSONFFLexer ¶ added in v0.1.6
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 ¶ added in v0.1.6
func (j *AccessLogGeoLocation) MarshalJSON() ([]byte, error)
MarshalJSON marshal bytes to json - template
func (*AccessLogGeoLocation) MarshalJSONBuf ¶ added in v0.1.6
func (j *AccessLogGeoLocation) MarshalJSONBuf(buf fflib.EncodingBuffer) error
MarshalJSONBuf marshal buff to json - template
func (*AccessLogGeoLocation) UnmarshalJSON ¶ added in v0.1.6
func (j *AccessLogGeoLocation) UnmarshalJSON(input []byte) error
UnmarshalJSON umarshall json - template of ffjson
func (*AccessLogGeoLocation) UnmarshalJSONFFLexer ¶ added in v0.1.6
func (j *AccessLogGeoLocation) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
UnmarshalJSONFFLexer fast json unmarshall - template ffjson
type AccessLogHook ¶
请求Hook定义
type AccessLogQueue ¶ added in v0.1.6
type AccessLogQueue struct {
// contains filtered or unexported fields
}
访问日志队列
func NewAccessLogQueue ¶ added in v0.1.6
func NewAccessLogQueue(db *leveldb.DB, index int) *AccessLogQueue
创建队列对象
func (*AccessLogQueue) Dump ¶ added in v0.1.6
func (this *AccessLogQueue) Dump(mongoCollFunc func() *teamongo.Collection)
导出日志到别的媒介
func (*AccessLogQueue) Receive ¶ added in v0.1.6
func (this *AccessLogQueue) Receive(ch chan *AccessLog)
从队列中接收日志
type CommandStorage ¶ added in v0.1.6
type CommandStorage struct {
Storage `yaml:", inline"`
Command string `yaml:"command" json:"command"`
Args []string `yaml:"args" json:"args"`
Dir string `yaml:"dir" json:"dir"`
// contains filtered or unexported fields
}
通过命令行存储
func (*CommandStorage) Write ¶ added in v0.1.6
func (this *CommandStorage) Write(accessLogs []*AccessLog) error
写入日志
type ESStorage ¶ added in v0.1.6
type ESStorage struct {
Storage `yaml:", inline"`
Endpoint string `yaml:"endpoint" json:"endpoint"`
Index string `yaml:"index" json:"index"`
MappingType string `yaml:"mappingType" json:"mappingType"`
}
ElasticSearch存储策略
type FileStorage ¶ added in v0.1.6
type FileStorage struct {
Storage `yaml:", inline"`
Path string `yaml:"path" json:"path"` // 文件路径,支持变量:${year|month|week|day|hour|minute|second}
// contains filtered or unexported fields
}
文件存储策略
func (*FileStorage) Write ¶ added in v0.1.6
func (this *FileStorage) Write(accessLogs []*AccessLog) error
写入日志
type MySQLStorage ¶ added in v0.1.6
type MySQLStorage struct {
Storage `yaml:", inline"`
Host string `yaml:"host" json:"host"`
Port int `yaml:"port" json:"port"`
Username string `yaml:"username" json:"username"`
Password string `yaml:"password" json:"password"`
Database string `yaml:"database" json:"database"`
Table string `yaml:"table" json:"table"` // can use variables, such as ${year}
LogField string `yaml:"logField" json:"logField"`
AutoCreateTable bool `yaml:"autoCreateTable" json:"autoCreateTable"`
}
MySQL存储
func (*MySQLStorage) Write ¶ added in v0.1.6
func (this *MySQLStorage) Write(accessLogs []*AccessLog) error
写入日志
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
func (*Query) Action ¶
func (this *Query) Action(action QueryAction) *Query
func (*Query) Duration ¶
func (this *Query) Duration(duration QueryDuration) *Query
type QueryAction ¶
type QueryAction = string
type QueryDuration ¶
type QueryDuration = string
type Storage ¶ added in v0.1.6
type Storage struct {
Format StorageFormat `yaml:"format" json:"format"` // 日志格式
Template string `yaml:"template" json:"template"` // 只有在Format为template时有效
}
基础的Storage
func (*Storage) FormatAccessLogBytes ¶ added in v0.1.6
格式化访问日志成字节
func (*Storage) FormatAccessLogString ¶ added in v0.1.6
格式化访问日志成字符串
func (*Storage) FormatVariables ¶ added in v0.1.6
格式化字符串中的变量
type StorageFormat ¶ added in v0.1.6
type StorageFormat = string
存储日志的格式
const ( StorageFormatJSON StorageFormat = "json" StorageFormatTemplate StorageFormat = "template" )
type StorageInterface ¶ added in v0.1.6
type StorageInterface interface {
// 开启
Start() error
// 写入日志
Write(accessLogs []*AccessLog) error
// 关闭
Close() error
}
日志存储接口
func DecodePolicyStorage ¶ added in v0.1.6
func DecodePolicyStorage(policy *teaconfigs.AccessLogStoragePolicy) StorageInterface
解析策略中的存储对象
func FindPolicyStorage ¶ added in v0.1.6
func FindPolicyStorage(policyId string) StorageInterface
通过策略ID查找存储
type StorageType ¶ added in v0.1.6
type StorageType = string
存储引擎类型
const ( StorageTypeFile StorageType = "file" StorageTypeES StorageType = "es" StorageTypeMySQL StorageType = "mysql" StorageTypeTCP StorageType = "tcp" StorageTypeCommand StorageType = "command" )
type TCPStorage ¶ added in v0.1.6
type TCPStorage struct {
Storage `yaml:", inline"`
Network string `yaml:"network" json:"network"` // tcp, unix
Addr string `yaml:"addr" json:"addr"`
// contains filtered or unexported fields
}
TCP存储策略
func (*TCPStorage) Write ¶ added in v0.1.6
func (this *TCPStorage) Write(accessLogs []*AccessLog) error
写入日志