Documentation ¶
Index ¶
- Constants
- func AddAccessLogHook(hook *AccessLogHook)
- func AllStorageFormats() []maps.Map
- func AllStorages() []maps.Map
- func CallAccessLogHooks(accessLog *accesslogs.AccessLog)
- func FindPolicyName(policyId string) string
- func FindStorageFormatName(code string) string
- func FindStorageTypeName(storageType string) string
- func ResetPolicyStorage(policyId string)
- type AccessLogHook
- type AccessLogQueue
- type AccessLogger
- type CommandStorage
- type ESStorage
- type FileStorage
- type MySQLStorage
- type Storage
- type StorageFormat
- type StorageInterface
- type StorageType
- type TCPStorage
Constants ¶
View Source
const (
DBBatchLogSize = 256
)
导入数据库的访问日志的步长
Variables ¶
This section is empty.
Functions ¶
func FindStorageFormatName ¶ added in v0.1.6
根据代号查找名称
func FindStorageTypeName ¶ added in v0.1.6
根据类型查找名称
Types ¶
type AccessLogHook ¶
type AccessLogHook struct {
Process func(accessLog *accesslogs.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) Receive ¶ added in v0.1.6
func (this *AccessLogQueue) Receive(ch chan *accesslogs.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 []*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 []*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 []*accesslogs.AccessLog) error
写入日志
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 *accesslogs.AccessLog) ([]byte, error)
格式化访问日志成字节
func (*Storage) FormatAccessLogString ¶ added in v0.1.6
func (this *Storage) FormatAccessLogString(accessLog *accesslogs.AccessLog) (string, error)
格式化访问日志成字符串
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 []*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 []*accesslogs.AccessLog) error
写入日志
Source Files ¶
Click to show internal directories.
Click to hide internal directories.