Documentation ¶
Overview ¶
Level identifies the severity of an event to be logged. As higher ans more important is the event. Trace is the less severe and Fatal the most severe.
Customization ¶
Different implementations of Provider could introduce more Levels. All ordinals are unique over all instances of Level. Info = 3000 will be always Info = 3000. Another Level which uses the ordinal 3000 can be just assumed as an alias to Info. Customization only means added new instances of Level. Standard levels always remains available.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrIllegalLevel = errors.New("illegal level")
ErrIllegalLevel represents that an illegal level.Level value/name was provided.
Functions ¶
This section is empty.
Types ¶
type Aware ¶ added in v0.7.1
type Aware interface { // GetLevel returns the current level. GetLevel() Level }
Aware describes an object that is aware of a Level and exports its current state.
type Level ¶
type Level uint16
const ( // Trace defines the lowest possible level. This is usually only used // in cases where really detailed logs are required. For example to document // the whole communication with a server, including each request with its // headers and so on. Trace Level = 1000 // Debug is used to document information which is used to debug // problems. This information are in regular operation mode are not // required; but could help once enabled to track down common issues. Debug Level = 2000 // Info is the regular level where everything is logged which is of // interest for everybody and should be always visible and imply regular // operations of the system. Usually this shows that one operation succeeded // successfully; like a user was created. Info Level = 3000 // Warn implies that something happened which failed but could be // recovered gracefully. In best case the user does not notice anything. // But personal should investigate as soon as possible to prevent something // like this happening again. Warn Level = 4000 // Error implies that something happened which failed and cannot be // recovered gracefully, but it only affects one or a small amount of users // and the rest of the system can continue to work. Personal should // investigate right now to prevent such stuff happening again and recover // broken users. Error Level = 5000 // Fatal implies that something happened which failed and cannot be // recovered gracefully, which might affect every user of the system. This // implies that the whole system is no longer operable and should/will be // shutdown (if possible gracefully) right now. Personal is required to // investigate right now to prevent such stuff happening again, bring the // the system back to operations and recover broken users. Fatal Level = 6000 )
type Levels ¶
type Levels []Level
Levels represents a slice of 0...n Level.
Additionally, it implements the sort.Interface to enable to call sort.Sort to order the contents of this slice by its severity.
func (Levels) ToProvider ¶ added in v0.10.0
ToProvider transforms the current Levels into a Provider instance with the given name.
type LineExtractor ¶ added in v0.7.1
LineExtractor checks a given line for the contained Level and will return it. The implementation can decide to also return another level.
func FixedLevelExtractor ¶ added in v0.7.1
func FixedLevelExtractor(in Level) LineExtractor
FixedLevelExtractor is an implementation of LineExtractor which always returns the same Level value regardless what was in the line.
type LineExtractorFunc ¶ added in v0.7.1
LineExtractorFunc like LineExtractor but as a func.
func (LineExtractorFunc) ExtractLevelFromLine ¶ added in v0.7.1
func (instance LineExtractorFunc) ExtractLevelFromLine(in []byte) (Level, error)
type MutableAware ¶ added in v0.7.1
type MutableAware interface { Aware // SetLevel modifies the current level to the given one. SetLevel(Level) }
MutableAware is similar to Aware but additionally is able to modify the Level by calling SetLevel(Level).
type Names ¶ added in v1.3.0
type Names interface { // ToName converts a given level.Level to a human-readable name. If this // level is unknown by this instance an error is returned. Most likely // ErrIllegalLevel. ToName(Level) (string, error) // ToLevel converts a given human-readable name to a level.Level. If this // name is unknown by this instance an error is returned. Most likely // ErrIllegalLevel. ToLevel(string) (Level, error) }
Names is used to make readable names out of level.Level or the other way around.
func NewNamesFacade ¶ added in v1.3.0
NewNamesFacade creates a facade of Names using the given provider.
type NamesAware ¶ added in v1.3.0
type NamesAware interface { // GetLevelNames returns an instance of level.Names that support by // formatting levels in a human-readable format. GetLevelNames() Names }
NamesAware represents an object that is aware of Names.
type Provider ¶
Provider provides all available Levels.
func GetAllProviders ¶
func GetAllProviders() []Provider
GetAllProviders returns all knows providers registered with RegisterProvider().
func GetProvider ¶
func GetProvider() Provider
GetProvider returns the actual Provider.
The Provider returned by this method is guarded by a facade (see NewProviderFacade()) which ensures that usages of this Provider will always call the global configured Provider depending on whether the Provider was configured before calling this method or afterwards.
func NewProviderFacade ¶
NewProviderFacade creates a new facade of Provider with the given function that provides the actual Provider to use.
func RegisterProvider ¶
RegisterProvider registers the given provider as a usable one. If GetProvider() is called each Provider which was registered with this method will be then taken into consideration to be returned.
It is not possible to register more than one instance of a Provider with the same name.
func SetProvider ¶
SetProvider forces the given Provider as the actual one which will be returned when calling GetProvider(). This will lead to that each Provider registered with RegisterProvider() will be ignored.
This methods accepts also <nil>. In this case regular discovery mechanism will be enabled again when calling GetProvider().
This methods always returns the previous set value (which can be <nil>, too).
func UnregisterProvider ¶
UnregisterProvider is doing the exact opposite of RegisterProvider().