Documentation ¶
Index ¶
- Constants
- Variables
- func GetConfig(v *viper.Viper, logger *syslog.Writer) (*Config, chan *Config, OutputWriter, error)
- func RegisterNewWriter(name string, factory OutputFactory)
- type ByModTime
- type Config
- type ConfigValueError
- type Consumer
- type FileOutput
- type LineProcessor
- type NoProcessor
- type OutputFactory
- type OutputWriter
- type SimpleLineProcessor
- type TemplateLineProcessor
- type UnregisteredOutputError
Constants ¶
const ( // config keys LoggingDirectory = "logging.directory" LoggingActiveFileName = "logging.active_file_name" RotationMaxLines = "rotation.max_lines" RotationMaxFileSizeBytes = "rotation.max_file_size_bytes" FlushingTimeIntervalSecs = "flushing.time_interval_secs" PrependValue = "misc.prepend_value" FileRenamePolicy = "rollup.file_rename_policy" MaxAge = "rollup.max_age" MaxCount = "rollup.max_count" Gzip = "rollup.gzip" Target = "target.name" )
XXX: Move it to constants.go if needed
Variables ¶
var ( // ErrInvalidFileRenamePolicy is raised for invalid values to file rename policy ErrInvalidFileRenamePolicy = errors.New(FileRenamePolicy + " can only be timestamp or serial") // ErrInvalidMaxAge is raised for invalid value in max age - life bad suffixes or no integer value at all ErrInvalidMaxAge = errors.New(MaxAge + " must end with either d or h and start with a number") )
Functions ¶
func RegisterNewWriter ¶ added in v0.1.0
func RegisterNewWriter(name string, factory OutputFactory)
RegisterNewWriter is called by the init function from every output Adds the constructor to the registry
Types ¶
type Config ¶
type Config struct { DirName string ActiveFileName string RotationMaxLines int RotationMaxBytes uint64 FlushingTimeIntervalSecs int PrependValue string FileRenamePolicy string MaxAge int64 MaxCount int Gzip bool Target string }
Config holds all the config settings
type ConfigValueError ¶
type ConfigValueError struct {
Key string
}
ConfigValueError holds the error value if a config key contains an invalid value
func (*ConfigValueError) Error ¶
func (e *ConfigValueError) Error() string
type Consumer ¶
type Consumer struct { Config *Config LineProcessor LineProcessor Logger *syslog.Writer Writer OutputWriter ReloadChan chan *Config // contains filtered or unexported fields }
Consumer is the main struct which holds all the stuff necessary to run the code
type FileOutput ¶ added in v0.1.0
FileOutput is just an embed type which adds the Close method to buffered writer to satisfy the OutputWriter interface XXX: Might need to implement this in a better way
func (*FileOutput) Close ¶ added in v0.1.0
func (f *FileOutput) Close() error
Close function is just a no-op. Its never called.
type LineProcessor ¶
LineProcessor interface is passed down to the consumer which just calls the write function
func GetLineProcessor ¶
func GetLineProcessor(cfg *Config) LineProcessor
GetLineProcessor function returns the particular processor depending on the config.
type NoProcessor ¶
type NoProcessor struct { }
NoProcessor is used when there is no prepend value. It just prints the line without any other action
type OutputFactory ¶ added in v0.1.0
OutputFactory is a function type which holds the output registry
type OutputWriter ¶ added in v0.1.0
OutputWriter interface is to be implemented by all remote target writers It embeds the io.Writer and has basic function calls which should be needed by all writers Can be modified later if needed
func GetOutputWriter ¶ added in v0.1.0
GetOutputWriter gets the constructor by extracting the target. Then returns the corresponding output writer by calling the constructor
type SimpleLineProcessor ¶
type SimpleLineProcessor struct {
// contains filtered or unexported fields
}
SimpleLineProcessor is used when the prependValue is only a simple string It just concatenates the string with the line and prints it
type TemplateLineProcessor ¶
type TemplateLineProcessor struct {
// contains filtered or unexported fields
}
TemplateLineProcessor is used when there is a template action in the prependValue It parses the prependValue and store the template. Then for every write call, it executes the template and writes it
type UnregisteredOutputError ¶ added in v0.1.0
type UnregisteredOutputError struct {
// contains filtered or unexported fields
}
UnregisteredOutputError holds the error if some target was passed from the config which was not registered
func (*UnregisteredOutputError) Error ¶ added in v0.1.0
func (e *UnregisteredOutputError) Error() string