tealogs

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: 29 Imported by: 3

Documentation

Index

Constants

View Source
const (
	DBBatchLogSize = 256
)

导入数据库的访问日志的步长

Variables

This section is empty.

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 *accesslogs.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 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) Dump added in v0.1.6

func (this *AccessLogQueue) Dump()

导出日志到别的媒介

func (*AccessLogQueue) Receive added in v0.1.6

func (this *AccessLogQueue) Receive(ch chan *accesslogs.AccessLog)

从队列中接收日志

type AccessLogger

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

访问日志记录器

func NewAccessLogger

func NewAccessLogger() *AccessLogger

获取新日志对象

func SharedLogger

func SharedLogger() *AccessLogger

获取共享的对象

func (*AccessLogger) Push

func (this *AccessLogger) Push(log *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) 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 []*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 []*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 []*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 []*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

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 []*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 []*accesslogs.AccessLog) error

写入日志

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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