访问日志默认关闭

This commit is contained in:
GoEdgeLab
2021-05-06 19:47:37 +08:00
parent 3580558dcd
commit 8f1b8bb7d5

View File

@@ -1,9 +1,9 @@
package serverconfigs package serverconfigs
// 默认的访问日志配置 // DefaultHTTPAccessLogRef 默认的访问日志配置
var DefaultHTTPAccessLogRef = NewHTTPAccessLogRef() var DefaultHTTPAccessLogRef = NewHTTPAccessLogRef()
// 代理访问日志配置 // HTTPAccessLogRef 代理访问日志配置
type HTTPAccessLogRef struct { type HTTPAccessLogRef struct {
IsPrior bool `yaml:"isPrior" json:"isPrior"` // 是否覆盖 IsPrior bool `yaml:"isPrior" json:"isPrior"` // 是否覆盖
IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用 IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用
@@ -22,10 +22,10 @@ type HTTPAccessLogRef struct {
FirewallOnly bool `yaml:"firewallOnly" json:"firewallOnly"` // 是否只记录防火墙相关日志 FirewallOnly bool `yaml:"firewallOnly" json:"firewallOnly"` // 是否只记录防火墙相关日志
} }
// 获取新对象 // NewHTTPAccessLogRef 获取新对象
func NewHTTPAccessLogRef() *HTTPAccessLogRef { func NewHTTPAccessLogRef() *HTTPAccessLogRef {
return &HTTPAccessLogRef{ return &HTTPAccessLogRef{
IsOn: true, IsOn: false,
Fields: []int{}, Fields: []int{},
Status1: true, Status1: true,
Status2: true, Status2: true,
@@ -35,12 +35,12 @@ func NewHTTPAccessLogRef() *HTTPAccessLogRef {
} }
} }
// 校验 // Init 校验
func (this *HTTPAccessLogRef) Init() error { func (this *HTTPAccessLogRef) Init() error {
return nil return nil
} }
// 判断是否应该记录 // Match 判断是否应该记录
func (this *HTTPAccessLogRef) Match(status int) bool { func (this *HTTPAccessLogRef) Match(status int) bool {
s := status / 100 s := status / 100
switch s { switch s {
@@ -69,7 +69,7 @@ func (this *HTTPAccessLogRef) Match(status int) bool {
return true return true
} }
// 是否包含某个存储策略 // ContainsStoragePolicy 是否包含某个存储策略
func (this *HTTPAccessLogRef) ContainsStoragePolicy(storagePolicyId int64) bool { func (this *HTTPAccessLogRef) ContainsStoragePolicy(storagePolicyId int64) bool {
for _, s := range this.StoragePolicies { for _, s := range this.StoragePolicies {
if s == storagePolicyId { if s == storagePolicyId {
@@ -79,7 +79,7 @@ func (this *HTTPAccessLogRef) ContainsStoragePolicy(storagePolicyId int64) bool
return false return false
} }
// 检查是否包含某个Field // ContainsField 检查是否包含某个Field
func (this *HTTPAccessLogRef) ContainsField(field int) bool { func (this *HTTPAccessLogRef) ContainsField(field int) bool {
for _, f := range this.Fields { for _, f := range this.Fields {
if f == field { if f == field {