tealogs

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2019 License: MIT Imports: 41 Imported by: 3

Documentation

Index

Constants

View Source
const (
	AccessLogFieldHeader       = 1
	AccessLogFieldSentHeader   = 2
	AccessLogFieldArg          = 3
	AccessLogFieldCookie       = 4
	AccessLogFieldExtend       = 5
	AccessLogFieldReferer      = 6
	AccessLogFieldUserAgent    = 7
	AccessLogFieldRequestBody  = 8
	AccessLogFieldResponseBody = 9
)
View Source
const (
	QueryDurationYearly   = "yearly"
	QueryDurationMonthly  = "monthly"
	QueryDurationDaily    = "daily"
	QueryDurationHourly   = "hourly"
	QueryDurationMinutely = "minutely"
	QueryDurationSecondly = "secondly"
)
View Source
const (
	QueryActionCount   = "count"
	QueryActionSum     = "sum"
	QueryActionAvg     = "avg"
	QueryActionMin     = "min"
	QueryActionMax     = "max"
	QueryActionFind    = "find"
	QueryActionFindAll = "findAll"
)
View Source
const (
	MongoLogSize = 256
)

导入的步长

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

func AddAccessLogHook

func AddAccessLogHook(hook *AccessLogHook)

添加Hook

func AllStorageFormats added in v0.1.6

func AllStorageFormats() []maps.Map

所有存储的格式

func AllStorages added in v0.1.6

func AllStorages() []maps.Map

所有存储引擎列表

func CallAccessLogHooks

func CallAccessLogHooks(accessLog *AccessLog)

执行Filter

func FindPolicyName added in v0.1.6

func FindPolicyName(policyId string) string

查找策略名称

func FindStorageFormatName added in v0.1.6

func FindStorageFormatName(code string) string

根据代号查找名称

func FindStorageTypeName added in v0.1.6

func FindStorageTypeName(storageType string) string

根据类型查找名称

func ResetPolicyStorage added in v0.1.6

func ResetPolicyStorage(policyId string)

清除策略相关信息

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 NewAccessLog added in v0.1.2

func NewAccessLog() *AccessLog

获取新对象

func (*AccessLog) CleanFields added in v0.1.2

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 added in v0.1.6

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

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) 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 added in v0.1.2

func (this *AccessLog) SetShouldWrite(b bool)

设置是否写入

func (*AccessLog) SetWritingFields added in v0.1.2

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

设置写入的字段

func (*AccessLog) ShouldStat

func (this *AccessLog) ShouldStat() bool

是否支持统计

func (*AccessLog) ShouldWrite added in v0.1.2

func (this *AccessLog) ShouldWrite() bool

是否支持写入

func (*AccessLog) Time

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

获取访问日志的请求时间

func (*AccessLog) UnmarshalJSON added in v0.1.6

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

UnmarshalJSON umarshall json - template of ffjson

func (*AccessLog) UnmarshalJSONFFLexer added in v0.1.6

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 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

type AccessLogHook struct {
	Process func(accessLog *AccessLog) (goNext bool)
}

请求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 AccessLogger

type AccessLogger struct {
	// contains filtered or unexported fields
}

访问日志记录器

func NewAccessLogger

func NewAccessLogger() *AccessLogger

获取新日志对象

func SharedLogger

func SharedLogger() *AccessLogger

获取共享的对象

func (*AccessLogger) Close

func (this *AccessLogger) Close()

关闭MongoDB客户端连接

func (*AccessLogger) Push

func (this *AccessLogger) Push(log *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) Close added in v0.1.6

func (this *CommandStorage) Close() error

关闭

func (*CommandStorage) Start added in v0.1.6

func (this *CommandStorage) Start() error

启动

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存储策略

func (*ESStorage) Close added in v0.1.6

func (this *ESStorage) Close() error

关闭

func (*ESStorage) Start added in v0.1.6

func (this *ESStorage) Start() error

开启

func (*ESStorage) Write added in v0.1.6

func (this *ESStorage) Write(accessLogs []*AccessLog) error

写入日志

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) Close added in v0.1.6

func (this *FileStorage) Close() error

关闭

func (*FileStorage) Start added in v0.1.6

func (this *FileStorage) Start() error

开启

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) Close added in v0.1.6

func (this *MySQLStorage) Close() error

关闭

func (*MySQLStorage) Start added in v0.1.6

func (this *MySQLStorage) Start() error

启动

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 NewQuery

func NewQuery() *Query

func (*Query) Action

func (this *Query) Action(action QueryAction) *Query

func (*Query) Asc

func (this *Query) Asc(field string) *Query

func (*Query) Attr

func (this *Query) Attr(field string, value interface{}) *Query

func (*Query) Debug

func (this *Query) Debug() *Query

func (*Query) Desc

func (this *Query) Desc(field string) *Query

func (*Query) Duration

func (this *Query) Duration(duration QueryDuration) *Query

func (*Query) Execute

func (this *Query) Execute() (interface{}, error)

开始执行

func (*Query) Find

func (this *Query) Find() (*AccessLog, error)

查找单个数据

func (*Query) FindAll

func (this *Query) FindAll() ([]*AccessLog, error)

查找多个数据

func (*Query) For

func (this *Query) For(field string) *Query

func (*Query) From

func (this *Query) From(time time.Time) *Query

func (*Query) Group

func (this *Query) Group(group []string) *Query

func (*Query) Gt

func (this *Query) Gt(field string, value interface{}) *Query

func (*Query) Gte

func (this *Query) Gte(field string, value interface{}) *Query

func (*Query) Id

func (this *Query) Id(idString string) *Query

设置日志ID

func (*Query) Limit

func (this *Query) Limit(size int64) *Query

func (*Query) Lt

func (this *Query) Lt(field string, value interface{}) *Query

func (*Query) Lte

func (this *Query) Lte(field string, value interface{}) *Query

func (*Query) Not

func (this *Query) Not(field string, value interface{}) *Query

func (*Query) Offset

func (this *Query) Offset(offset int64) *Query

func (*Query) Op

func (this *Query) Op(op string, field string, value interface{})

func (*Query) Result added in v0.1.2

func (this *Query) Result(field ...string) *Query

func (*Query) To

func (this *Query) To(time time.Time) *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 (this *Storage) FormatAccessLogBytes(accessLog *AccessLog) ([]byte, error)

格式化访问日志成字节

func (*Storage) FormatAccessLogString added in v0.1.6

func (this *Storage) FormatAccessLogString(accessLog *AccessLog) (string, error)

格式化访问日志成字符串

func (*Storage) FormatVariables added in v0.1.6

func (this *Storage) FormatVariables(s string) string

格式化字符串中的变量

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) Close added in v0.1.6

func (this *TCPStorage) Close() error

关闭

func (*TCPStorage) Start added in v0.1.6

func (this *TCPStorage) Start() error

开启

func (*TCPStorage) Write added in v0.1.6

func (this *TCPStorage) Write(accessLogs []*AccessLog) error

写入日志

Jump to

Keyboard shortcuts

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