cubefs

Форк
0
72 строки · 2.1 Кб
1
// Copyright 2022 The CubeFS Authors.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12
// implied. See the License for the specific language governing
13
// permissions and limitations under the License.
14

15
package auditlog
16

17
import "net/http"
18

19
const (
20
	LogFormatText = "text"
21
	LogFormatJSON = "json"
22
)
23

24
type Config struct {
25
	// LogDir audit log whether to enable depend on whether config log dir
26
	LogDir string `json:"logdir"`
27
	// ChunkBits means one audit log file size
28
	// eg: chunkbits=20 means one log file will hold 1<<10 size
29
	ChunkBits uint `json:"chunkbits"`
30
	// BodyLimit negative means no body-cache, 0 means default buffer size.
31
	BodyLimit int `json:"bodylimit"`
32
	// No2xxBody means that the response body of 2xx will not be logged.
33
	No2xxBody bool `json:"no_2xx_body"`
34
	// rotate new audit log file every start time
35
	RotateNew     bool   `json:"rotate_new"`
36
	LogFileSuffix string `json:"log_file_suffix"`
37
	// 0 means no backup limit
38
	Backup       int              `json:"backup"`
39
	MetricConfig PrometheusConfig `json:"metric_config"`
40

41
	// Filters are or relations
42
	Filters []FilterConfig `json:"filters"`
43

44
	// LogFormat valid value is "text" or "json", default is "text"
45
	LogFormat string `json:"log_format"`
46
}
47

48
// LogCloser a implemented audit logger should implements ProgressHandler
49
// and LogCloser interface to replace qn audit log
50
type LogCloser interface {
51
	Close() error
52
	Log([]byte) error
53
}
54

55
type noopLogCloser struct{}
56

57
var _ LogCloser = noopLogCloser{}
58

59
func (noopLogCloser) Close() error     { return nil }
60
func (noopLogCloser) Log([]byte) error { return nil }
61

62
type MetricSender interface {
63
	Send(raw []byte) error
64
}
65

66
type Decoder interface {
67
	DecodeReq(req *http.Request) *DecodedReq
68
}
69

70
type ResponseExtraHeader interface {
71
	ExtraHeader() http.Header
72
}
73

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.