Documentation ¶
Index ¶
Constants ¶
const ( File = "file" Stdout = "stdout" Stderr = "stderr" )
Log writers.
const ( JSON = "json" Text = "text" )
Log formatters.
Variables ¶
var ( // ErrInvalidWriterType is returned when a writer has an invalid type. ErrInvalidWriterType = errors.New("log writer has an invalid type") // ErrInvalidWriterLevel is returned when a writer has an invalid // level. ErrInvalidWriterLevel = errors.New("log writer has an invalid level") // ErrInvalidWriterFormatter is returned when a writer has an invalid // formatter. ErrInvalidWriterFormatter = errors.New("log writer has an invalid formatter") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Writers are the writers for the log. Writers []WriterConfig `toml:"writers"` }
Config contains configuration options for the log.
type ConfigHandler ¶
type ConfigHandler struct {
// contains filtered or unexported fields
}
ConfigHandler is the handler of the log configuration.
func (*ConfigHandler) Config ¶
func (h *ConfigHandler) Config() interface{}
Config returns the current service configuration or creates one with good default values.
The default configuration writes to a single file using the JSON formatter and weekly rotations.
func (*ConfigHandler) ID ¶
func (h *ConfigHandler) ID() string
ID returns the unique identifier of the configuration.
func (*ConfigHandler) SetConfig ¶
func (h *ConfigHandler) SetConfig(config interface{}) error
SetConfig configures the service handler.
type WriterConfig ¶
type WriterConfig struct { // Type is the type of the writer. Type string `toml:"type" comment:"The type of writer (file, stdout, stderr)."` // Level is the log level for the writer. Level string `toml:"level" comment:"The log level for the writer (trace, debug, info, warn, error, fatal, panic)."` // File is the log formatter for the writer. Formatter string `toml:"formatter" comment:"The formatter for the writer (json, text)."` // Filename is the file for a file logger. Filename string `toml:"filename" comment:"The file for a file logger."` }
WriterConfig contains configuration for a log writer.
type WriterHook ¶
WriterHook is a hook that writes logs of specified LogLevels to specified Writer
func (*WriterHook) Fire ¶
func (h *WriterHook) Fire(entry *log.Entry) error
Fire will be called when some logging function is called with current hook It will format log entry to string and write it to appropriate writer
func (*WriterHook) Levels ¶
func (h *WriterHook) Levels() []log.Level
Levels define on which log levels this hook would trigger