Versions in this module Expand all Collapse all v1 v1.0.1 May 3, 2022 v1.0.0 May 2, 2022 Changes in this version + const FormatJSON + const FormatUnknown + const StreamConsole + const StreamFile + const StreamRotatingFile + const StreamUnknown + var ErrConversion = fmt.Errorf("invalid type conversion") + var ErrDuplicateStream = fmt.Errorf("stream already registered") + var ErrInvalidFormat = fmt.Errorf("invalid output format") + var ErrInvalidLevel = fmt.Errorf("invalid logger level") + var ErrInvalidStreamConfig = fmt.Errorf("invalid log stream config") + var ErrInvalidStreamType = fmt.Errorf("invalid stream type") + var ErrNilPointer = fmt.Errorf("invalid nil pointer") + var LevelMap = map[string]Level + var LevelMapName = map[Level]string + var LoaderConfigPath = genv.String("GLOG_LOADER_CONFIG_PATH", "log.streams") + var LoaderErrorChannel = genv.String("GLOG_LOADER_ERROR_CHANNEL", "exec") + var LoaderObserveConfig = genv.Bool("GLOG_LOADER_OBSERVE_CONFIG", true) + func NewStreamRotatingFileWriter(fs afero.Fs, file string) (io.Writer, error) + type Formatter interface + Format func(level Level, message string, ctx map[string]interface{}) string + type FormatterFactory []FormatterStrategy + func (f *FormatterFactory) Register(strategy FormatterStrategy) error + func (f FormatterFactory) Create(format string, args ...interface{}) (Formatter, error) + type FormatterJSON struct + func (f FormatterJSON) Format(level Level, message string, ctx map[string]interface{}) string + type FormatterStrategy interface + Accept func(format string) bool + Create func(args ...interface{}) (Formatter, error) + type FormatterStrategyJSON struct + func (FormatterStrategyJSON) Accept(format string) bool + func (FormatterStrategyJSON) Create(_ ...interface{}) (Formatter, error) + type Level int + const DEBUG + const ERROR + const FATAL + const INFO + const NOTICE + const WARNING + type Loader struct + func NewLoader(config gconfig.Manager, logger *Logger, factory *StreamFactory) (*Loader, error) + func (l Loader) Load() error + type Logger struct + func NewLogger() *Logger + func (l *Logger) AddStream(id string, stream Stream) error + func (l *Logger) Close() error + func (l *Logger) RemoveAllStreams() + func (l *Logger) RemoveStream(id string) + func (l Logger) Broadcast(level Level, msg string, ctx map[string]interface{}) error + func (l Logger) HasStream(id string) bool + func (l Logger) ListStreams() []string + func (l Logger) Signal(channel string, level Level, msg string, ctx map[string]interface{}) error + func (l Logger) Stream(id string) Stream + type Stream interface + AddChannel func(channel string) + Broadcast func(level Level, message string, ctx map[string]interface{}) error + HasChannel func(channel string) bool + Level func() Level + ListChannels func() []string + RemoveChannel func(channel string) + Signal func(channel string, level Level, message string, ctx map[string]interface{}) error + func NewStreamConsole(formatter Formatter, channels []string, level Level) (Stream, error) + func NewStreamFile(writer io.Writer, formatter Formatter, channels []string, level Level) (Stream, error) + type StreamFactory []StreamStrategy + func (f *StreamFactory) Register(strategy StreamStrategy) error + func (f StreamFactory) Create(streamType string, args ...interface{}) (Stream, error) + func (f StreamFactory) CreateFromConfig(cfg gconfig.Config) (Stream, error) + type StreamStrategy interface + Accept func(sourceType string) bool + AcceptFromConfig func(cfg gconfig.Config) bool + Create func(args ...interface{}) (Stream, error) + CreateFromConfig func(cfg gconfig.Config) (Stream, error) + func NewStreamStrategyConsole(factory *FormatterFactory) (StreamStrategy, error) + func NewStreamStrategyFile(fs afero.Fs, factory *FormatterFactory) (StreamStrategy, error) + func NewStreamStrategyRotatingFile(fs afero.Fs, factory *FormatterFactory) (StreamStrategy, error)