Documentation
¶
Overview ¶
Package cls is tencent cloud cls log plugin for trpc-go
Index ¶
Constants ¶
This section is empty.
Variables ¶
var GetReportCLSField = func(sourceField string, cfg *Config) (reportField string, needReport bool) { if cfg == nil || len(cfg.FieldMap) == 0 { return sourceField, true } reportField, exist := cfg.FieldMap[sourceField] if !exist { reportField = sourceField } return reportField, true }
GetReportCLSField is used to override the logging fields reported to CLS. For example: log.WithFields("field1", "value1").Info("message1"). In this case, the field reported to CLS is "field1," and you can override it using the GetReportCLSField function. The default implementation supports field mapping through framework configuration, as detailed in the README.md. Parameter sourceField represents the original field, such as "field1" in the example above, cfg is the configuration information for CLS framework. The returned reportField is the field after remapping for reporting to CLS. If needReport is false, it means that this field will be ignored and not reported to CLS.
Functions ¶
This section is empty.
Types ¶
type Callback ¶
type Callback struct { }
Callback provides callback function.
type Config ¶
type Config struct { // TopicID is the log reporting topic ID. TopicID string `yaml:"topic_id"` // Host is the log reporting host. Host string `yaml:"host"` // SecretID is the log reporting secret ID used when calling Tencent Cloud APIs. SecretID string `yaml:"secret_id"` // SecretKey is the log reporting secret key used when calling Tencent Cloud APIs. SecretKey string `yaml:"secret_key"` // TotalSizeLnBytes is the maximum log size limit that an instance can cache, default is 100MB. TotalSizeLnBytes int64 `yaml:"total_size_ln_bytes"` // MaxSendWorkerCount is the maximum number of goroutines that the client can use concurrently, default is 50. MaxSendWorkerCount int64 `yaml:"max_send_worker_count"` // MaxBlockSec is the maximum blocking time on the send method if available buffer space is insufficient, default is non-blocking. MaxBlockSec int `yaml:"max_block_sec"` // MaxBatchSize is the size at which a batch of cached logs will be sent when greater than or equal to MaxBatchSize, default is 512KB, with a maximum of 5MB. MaxBatchSize int64 `yaml:"max_batch_size"` // MaxBatchCount is the number of logs in a batch that triggers sending when greater than or equal to MaxBatchCount, default is 4096, with a maximum of 40960. MaxBatchCount int `yaml:"max_batch_count"` // LingerMs is the time a batch stays in an available state before being sent, default is 2 seconds, with a minimum of 100 milliseconds. LingerMs int64 `yaml:"linger_ms"` // Retries is the number of retries allowed if a batch fails to send on the first attempt, default is 10 times. Retries int `yaml:"retries"` // MaxReservedAttempts is the number of attempts retained for each batch, each send attempt corresponds to an attempt, this parameter controls the number of attempts returned to the user, default is to keep only the latest 11 attempt records. MaxReservedAttempts int `yaml:"max_reserved_attempts"` // BaseRetryBackoffMs is the initial backoff time for the first retry, default is 100 milliseconds. The client uses an exponential backoff algorithm, where the planned wait time for the Nth retry is baseRetryBackoffMs * 2^(N-1). BaseRetryBackoffMs int64 `yaml:"base_retry_backoff_ms"` // MaxRetryBackoffMs is the maximum backoff time for retries, default is 50 seconds. MaxRetryBackoffMs int64 `yaml:"max_retry_backoff_ms"` // FieldMap is the mapping of log reporting fields. FieldMap map[string]string `yaml:"field_map"` // Source is the log source, typically the machine's IP address. Source string `yaml:"source"` }
Config is the configuration for the cls log plugin.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is cls logger.
type LoggerPlugin ¶
type LoggerPlugin struct { }
LoggerPlugin is CLS logger plugin.
func (*LoggerPlugin) Setup ¶
func (lp *LoggerPlugin) Setup(name string, configDec plugin.Decoder) error
Setup setups the plugin.
func (*LoggerPlugin) SetupCls ¶
func (lp *LoggerPlugin) SetupCls(conf *log.OutputConfig) (*Logger, error)
SetupCls setups cls logger.
func (*LoggerPlugin) Type ¶
func (lp *LoggerPlugin) Type() string
Type returns the type of logger plugin.