Documentation
¶
Index ¶
Constants ¶
const ( // FormatJSON defines the value to be used to declare a JSON // logger formatter format. FormatJSON = "json" // FileStreamType defines the value to be used to declare a file // logger stream type. FileStreamType = "file" // ContainerID defines the id to be used as the default of a // logger instance in the application container. ContainerID = "gapp.log" // ContainerFormatterStrategyJSONID defines the id to be used as // the default of a logger json formatter factory strategy instance in the // application container. ContainerFormatterStrategyJSONID = ContainerID + ".formatter.strategy.json" // ContainerFormatterFactoryID defines the id to be used as the // default of a logger formatter factory instance in the application // container. ContainerFormatterFactoryID = ContainerID + ".formatter.factory" // ContainerStreamStrategyFileID defines the id to be used as the // default of a logger file stream factory strategy instance in the // application container. ContainerStreamStrategyFileID = ContainerID + ".stream.strategy.file" // ContainerStreamFactoryID defines the id to be used as the default // of a logger stream factory instance in the application container. ContainerStreamFactoryID = ContainerID + ".stream.factory" // ContainerLoaderID defines the id to be used as the default of a // logger loader instance in the application container. ContainerLoaderID = ContainerID + ".loader" // EnvLoaderActive defines the name of the environment variable // to be checked for a overriding value for the log loader activation. EnvLoaderActive = "GAPP_LOG_LOADER_ACTIVE" // EnvLoaderPath defines the name of the environment variable // to be checked for a overriding value for the log loader source // config path. EnvLoaderPath = "GAPP_LOG_LOADER_PATH" )
Variables ¶
var ( // LoaderActive defines the entry config source active flag // used to signal the config loader to load the streams or not LoaderActive = true // LoaderPath defines the entry config source path // to be used as the loader entry. LoaderPath = "logger.streams" )
var LevelMap = map[string]Level{ "fatal": FATAL, "error": ERROR, "warning": WARNING, "notice": NOTICE, "info": INFO, "debug": DEBUG, }
LevelMap defines a relation between a human-readable string and a code level identifier of a logging level.
var LevelMapName = map[Level]string{ FATAL: "fatal", ERROR: "error", WARNING: "warning", NOTICE: "notice", INFO: "info", DEBUG: "debug", }
LevelMapName defines a relation between a code level identifier of a logging level and human-readable string representation of that level.
Functions ¶
func NewProvider ¶
NewProvider will create a new logger provider instance.
Types ¶
type Formatter ¶
Formatter interface defines the methods of a logging formatter instance responsible to parse a logging request into the output string.
func NewFormatterJSON ¶
func NewFormatterJSON() Formatter
NewFormatterJSON will instantiate a new JSON formatter that will take the logging entry request and create the output JSON string.
type FormatterFactory ¶
type FormatterFactory interface {
Register(strategy FormatterStrategy) error
Create(format string, args ...interface{}) (Formatter, error)
}
FormatterFactory defines the logger formatter factory structure used to instantiate logger formatters, based on registered instantiation strategies.
func NewFormatterFactory ¶
func NewFormatterFactory() FormatterFactory
NewFormatterFactory instantiate a new formatter factory.
type FormatterStrategy ¶
type FormatterStrategy interface {
Accept(format string, args ...interface{}) bool
Create(args ...interface{}) (Formatter, error)
}
FormatterStrategy interface defines the methods of the formatter factory strategy that can validate creation requests and instantiation of particular decoder.
func NewFormatterStrategyJSON ¶
func NewFormatterStrategyJSON() FormatterStrategy
NewFormatterStrategyJSON instantiate a new json logging output formatter factory strategy that will enable the formatter factory to instantiate a new content to json formatter.
type Level ¶
type Level int
Level identifies a value type that describes a logging level.
const ( // FATAL defines a fatal logging level. FATAL Level = 1 + iota // ERROR defines a error logging level. ERROR // WARNING defines a warning logging level. WARNING // NOTICE defines a notice logging level. NOTICE // INFO defines a info logging level. INFO // DEBUG defines a debug logging level. DEBUG )
type Loader ¶
type Loader interface {
Load(entries []config.Partial) error
}
Loader defines the logger instantiation and initialization of a new logger proxy.
type Logger ¶
type Logger interface {
Close() error
Signal(channel string, level Level, msg string, ctx map[string]interface{}) error
Broadcast(level Level, msg string, ctx map[string]interface{}) error
HasStream(id string) bool
AddStream(id string, stream Stream) error
RemoveStream(id string)
Stream(id string) Stream
}
Logger defines a logging proxy for all the registered logging streams.
type Stream ¶
type Stream interface {
Close() error
Signal(channel string, level Level, message string, ctx map[string]interface{}) error
Broadcast(level Level, message string, ctx map[string]interface{}) error
HasChannel(channel string) bool
ListChannels() []string
AddChannel(channel string)
RemoveChannel(channel string)
Level() Level
}
Stream interface defines the interaction methods with a logging stream.
type StreamFactory ¶
type StreamFactory interface {
Register(strategy StreamStrategy) error
Create(sourceType string, args ...interface{}) (Stream, error)
CreateFromConfig(cfg config.Partial) (Stream, error)
}
StreamFactory defines a logger stream factory instance used to instantiate logger stream based in the registered logger stream instantiation strategies.
func NewStreamFactory ¶
func NewStreamFactory() StreamFactory
NewStreamFactory instantiate a new stream factory.
type StreamStrategy ¶
type StreamStrategy interface {
Accept(sourceType string, args ...interface{}) bool
AcceptFromConfig(cfg config.Partial) bool
Create(args ...interface{}) (Stream, error)
CreateFromConfig(cfg config.Partial) (Stream, error)
}
StreamStrategy interface defines the methods of the stream factory strategy that can validate creation requests and instantiation of particular type of stream.
func NewFileStreamStrategy ¶
func NewFileStreamStrategy(fs afero.Fs, factory FormatterFactory) (StreamStrategy, error)
NewFileStreamStrategy instantiate a new file stream factory strategy that will enable the stream factory to instantiate a new file stream.