Documentation ¶
Index ¶
- Constants
- Variables
- func AddAccessLogHook(hook *AccessLogHook)
- func AllStorageFormats() []maps.Map
- func AllStorages() []maps.Map
- func CallAccessLogHooks(accessLog *accesslogs.AccessLog)
- func FindPolicy(policyId string) *teaconfigs.AccessLogStoragePolicy
- func FindPolicyName(policyId string) string
- func FindStorageFormatName(code string) string
- func FindStorageTypeName(storageType string) string
- func ResetAllPolicies()
- 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 SyslogStorage
- type SyslogStoragePriority
- type SyslogStorageProtocol
- type TCPStorage
Constants ¶
View Source
const (
DBBatchLogSize = 256
)
导入数据库的访问日志的步长
Variables ¶
View Source
var SyslogStoragePriorities = []maps.Map{ { "name": "[无]", "value": -1, }, { "name": "EMERG", "value": SyslogStoragePriorityEmerg, }, { "name": "ALERT", "value": SyslogStoragePriorityAlert, }, { "name": "CRIT", "value": SyslogStoragePriorityCrit, }, { "name": "ERR", "value": SyslogStoragePriorityErr, }, { "name": "WARNING", "value": SyslogStoragePriorityWarning, }, { "name": "NOTICE", "value": SyslogStoragePriorityNotice, }, { "name": "INFO", "value": SyslogStoragePriorityInfo, }, { "name": "DEBUG", "value": SyslogStoragePriorityDebug, }, }
Functions ¶
Types ¶
type AccessLogHook ¶
type AccessLogHook struct {
Process func(accessLog *accesslogs.AccessLog) (goNext bool)
}
请求Hook定义
type AccessLogQueue ¶
type AccessLogQueue struct {
// contains filtered or unexported fields
}
访问日志队列
func NewAccessLogQueue ¶
func NewAccessLogQueue(buffer *logbuffer.Buffer, index int) *AccessLogQueue
创建队列对象
func (*AccessLogQueue) Receive ¶
func (this *AccessLogQueue) Receive(ch chan *accesslogs.AccessLog)
从队列中接收日志
type CommandStorage ¶
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 ¶
func (this *CommandStorage) Write(accessLogs []*accesslogs.AccessLog) error
写入日志
type ESStorage ¶
type ESStorage struct { Storage `yaml:", inline"` Endpoint string `yaml:"endpoint" json:"endpoint"` Index string `yaml:"index" json:"index"` MappingType string `yaml:"mappingType" json:"mappingType"` Username string `yaml:"username" json:"username"` Password string `yaml:"password" json:"password"` }
ElasticSearch存储策略
type FileStorage ¶
type FileStorage struct { Storage `yaml:", inline"` Path string `yaml:"path" json:"path"` // 文件路径,支持变量:${year|month|week|day|hour|minute|second} AutoCreate bool `yaml:"autoCreate" json:"autoCreate"` // 是否自动创建目录 // contains filtered or unexported fields }
文件存储策略
func (*FileStorage) Write ¶
func (this *FileStorage) Write(accessLogs []*accesslogs.AccessLog) error
写入日志
type MySQLStorage ¶
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 ¶
func (this *MySQLStorage) Write(accessLogs []*accesslogs.AccessLog) error
写入日志
type Storage ¶
type Storage struct { Format StorageFormat `yaml:"format" json:"format"` // 日志格式 Template string `yaml:"template" json:"template"` // 只有在Format为template时有效 }
基础的Storage
func (*Storage) FormatAccessLogBytes ¶
func (this *Storage) FormatAccessLogBytes(accessLog *accesslogs.AccessLog) ([]byte, error)
格式化访问日志成字节
func (*Storage) FormatAccessLogString ¶
func (this *Storage) FormatAccessLogString(accessLog *accesslogs.AccessLog) (string, error)
格式化访问日志成字符串
type StorageFormat ¶
type StorageFormat = string
存储日志的格式
const ( StorageFormatJSON StorageFormat = "json" StorageFormatTemplate StorageFormat = "template" )
type StorageInterface ¶
type StorageInterface interface { // 开启 Start() error // 写入日志 Write(accessLogs []*accesslogs.AccessLog) error // 关闭 Close() error }
日志存储接口
func DecodePolicyStorage ¶
func DecodePolicyStorage(policy *teaconfigs.AccessLogStoragePolicy) StorageInterface
解析策略中的存储对象
type StorageType ¶
type StorageType = string
存储引擎类型
const ( StorageTypeFile StorageType = "file" StorageTypeES StorageType = "es" StorageTypeMySQL StorageType = "mysql" StorageTypeTCP StorageType = "tcp" StorageTypeSyslog StorageType = "syslog" StorageTypeCommand StorageType = "command" )
type SyslogStorage ¶
type SyslogStorage struct { Storage `yaml:", inline"` Protocol string `yaml:"protocol" json:"protocol"` // SysLogStorageProtocol* ServerAddr string `yaml:"serverAddr" json:"serverAddr"` ServerPort int `yaml:"serverPort" json:"serverPort"` Socket string `yaml:"socket" json:"socket"` // sock file Tag string `yaml:"tag" json:"tag"` Priority SyslogStoragePriority `yaml:"priority" json:"priority"` // contains filtered or unexported fields }
syslog存储策略
func (*SyslogStorage) Write ¶
func (this *SyslogStorage) Write(accessLogs []*accesslogs.AccessLog) error
写入日志
type SyslogStoragePriority ¶
type SyslogStoragePriority = int
const ( SyslogStoragePriorityEmerg SyslogStoragePriority = iota SyslogStoragePriorityAlert SyslogStoragePriorityCrit SyslogStoragePriorityErr SyslogStoragePriorityWarning SyslogStoragePriorityNotice SyslogStoragePriorityInfo SyslogStoragePriorityDebug )
type SyslogStorageProtocol ¶
type SyslogStorageProtocol = string
const ( SyslogStorageProtocolTCP SyslogStorageProtocol = "tcp" SyslogStorageProtocolUDP SyslogStorageProtocol = "udp" SyslogStorageProtocolNone SyslogStorageProtocol = "none" SyslogStorageProtocolSocket SyslogStorageProtocol = "socket" )
type TCPStorage ¶
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 ¶
func (this *TCPStorage) Write(accessLogs []*accesslogs.AccessLog) error
写入日志
Source Files ¶
Click to show internal directories.
Click to hide internal directories.