Documentation
¶
Overview ¶
Package conf is a component that defines the log configuration.
Component is initialized from follow file when load at first time. Config file name should be "log.yaml" or "log.yml" at config directory like follows.
One of follows:
- config/log.yaml
- config/log.yml
Index ¶
Constants ¶
View Source
const ( DefaultTimeFormat = time.RFC3339 DefaultServiceName = "logger" DefaultServiceVersion = "0.0.0" DefaultOpentracingTraceId = "X-B3-TraceId" DefaultOpentracingSpanId = "X-B3-SpanId" DefaultOpentracingSpanPosition = "X-B3-Version" )
View Source
const ( DefaultElasticLoggerAddresses = "http://127.0.0.1:9200" DefaultElasticLoggerIndex = "log-2006.01.02" DefaultElasticLoggerIndexType = "_doc" DefaultElasticLoggerTimeout = 5 )
View Source
const ( DefaultFileLoggerName = "2006-01-02.log" DefaultFileLoggerPath = "./logs" DefaultFileLoggerSeparator = "2006-01" )
View Source
const ( DefaultKafkaLoggerAddresses = "127.0.0.1:9092" DefaultKafkaLoggerTopic = "go-logs" DefaultKafkaLoggerDialTimeout = 5 DefaultKafkaLoggerReadTimeout = 5 DefaultKafkaLoggerWriteTimeout = 5 )
View Source
const ( DefaultJaegerTracerEndpoint = "http://127.0.0.1:14268/api/traces" DefaultJaegerTracerTimeout = 3 )
View Source
const ( DefaultZipkinTracerEndpoint = "http://localhost:9411/api/v2/spans" DefaultZipkinTracerTimeout = 3 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Level // logging filter name like follows. // // - debug // - info (default) // - warn // - error // - fatal Level base.Level `yaml:"level"` // TimeFormat // logger time format. TimeFormat string `yaml:"time-format"` // OpentracingTraceId // trace id for opentracing. OpentracingTraceId string `yaml:"opentracing-trace-id"` // OpentracingSpanId // span id for opentracing. OpentracingSpanId string `yaml:"opentracing-span-id"` // OpentracingSpanPosition // Package tracing for items offset position. OpentracingSpanPosition string `yaml:"opentracing-span-position"` // Adapter // configured for logging like follows. // // - elastic // - file // - kafka // - term (default) Adapter base.Adapter `yaml:"adapter"` // ElasticAdapter // is a component that defines the Elasticsearch adapter configuration. ElasticAdapter *ElasticAdapterConfig `yaml:"elastic-adapter"` // FileAdapter // is a component that defines the file adapter configuration. FileAdapter *FileAdapterConfig `yaml:"file-adapter"` // KafkaAdapter // is a component that defines the Kafka adapter configuration. KafkaAdapter *KafkaAdapterConfig `yaml:"kafka-adapter"` // TermAdapter // is a component that defines the terminal adapter configuration. TermAdapter *TermAdapterConfig `yaml:"term-adapter"` // Tracer // is a tracer for follows. // // - jaeger // - zipkin Tracer base.Tracer `yaml:"tracer"` // JaegerTracer // is a component that defines the Jaeger configuration. JaegerTracer *JaegerTracerConfig `yaml:"jaeger-tracer"` // ZipkinTracer // is a component that defines the Zipkin configuration. ZipkinTracer *ZipkinTracerConfig `yaml:"zipkin-tracer"` Pid int `yaml:"-"` ServiceAddr string `yaml:"-"` ServicePort int `yaml:"-"` ServiceName string `yaml:"-"` ServiceVersion string `yaml:"-"` // contains filtered or unexported fields }
Config is a component that defines the log configuration.
func (*Config) SetAdapter ¶
SetAdapter sets the log adapter.
type ConfigAdapterConfigured ¶
type ElasticAdapterConfig ¶
type ElasticAdapterConfig struct { // Addresses // is elasticsearch clusters address. // // Example: // - http://127.0.0.1:9200 Addresses []string `yaml:"addresses"` // Index // name of elasticsearch indices. // // Default: log-2006.01.02 Index string `yaml:"index"` // IndexType // type of elasticsearch indices if supported. // // Default: _doc IndexType string `yaml:"index-type"` // Timeout // durations of elasticsearch request. // // Default: 5 // Unit: Second Timeout int `yaml:"timeout"` Username string `yaml:"username"` Password string `yaml:"password"` }
ElasticAdapterConfig is a component for elasticsearch.
type FileAdapterConfig ¶
type FileAdapterConfig struct { // Json // converts as json string or not. // // Default: false Json bool `yaml:"json"` // FileName // saved log file name. // // Example: 2024-01-10.log FileName string `yaml:"name"` // FilePath // log file saved path. // // Default: ./logs FilePath string `yaml:"path"` // FileSeparator // log files separated by month. // // Default: 2006-01 (Month) FileSeparator string `yaml:"separator"` }
FileAdapterConfig is a component for file.
- /var/logs/sketch/2024-01/2024-01-10.log
type JaegerTracerConfig ¶
type JaegerTracerConfig struct { Endpoint string `yaml:"endpoint"` Timeout int `yaml:"timeout"` Username string `yaml:"username"` Password string `yaml:"password"` }
JaegerTracerConfig is the configuration of the Jaeger tracer.
type KafkaAdapterConfig ¶
type KafkaAdapterConfig struct { // Addresses // is kafka clusters address. Addresses []string `yaml:"addresses"` // Topic // log published to. // // Default: go-logs Topic string `yaml:"topic"` DialTimeout int `yaml:"dial-timeout"` ReadTimeout int `yaml:"read-timeout"` WriteTimeout int `yaml:"write-timeout"` ClientVersion string `yaml:"client-version"` }
KafkaAdapterConfig is a component for kafka.
type TermAdapterConfig ¶
type TermAdapterConfig struct { // Color // render with color around the log content or not. // // Default: false Color bool }
TermAdapterConfig is a component for terminal.
Click to show internal directories.
Click to hide internal directories.