Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArgsToMap ¶
ArgsToMap turn args []interface{} to map dictionary and strings array index. Return: map[string]interface{}, []string, error
func ArgsToString ¶
func ArgsToString(arg0 interface{}, args ...interface{}) (s string)
ArgsToString builds a format string by the arguments Return a format string which depends on the first argument:
- arg[0] is a string When given a string as the first argument, this behaves like fmt.Sprintf the first argument is interpreted as a format for the latter arguments.
- arg[0] is a func()string When given a closure of type func()string, this logs the string returned by the closure if it will be logged. The closure runs at most one time.
- arg[0] is interface{} When given anything else, the return message will be each of the arguments formatted with %v and separated by spaces (ala Sprint).
Types ¶
type Appender ¶
type Appender interface { // Open opens and creates the appender. Open(dsn string, args ...interface{}) (Appender, error) // Set sets name-value option. Checkable Set(name string, value interface{}) error // Enabled returns true if the given recorder should be encoded // and written bytes after. // // Enabled can write the recorder directly with owner format, // and then return false. Enabled(*Recorder) bool // Write will be called to write the log bytes. Write([]byte) (int, error) // Close should clean up anything lingering about the Appender, as it is called before // the Appender is removed. Write should not be called after Close. Close() }
Appender is an interface for anything that should be able to write logs
type Enabler ¶
Enabler interface implemented to provide customized logging recorder filtering.
func AcceptAll ¶
func AcceptAll() Enabler
AcceptAll return Enabler which accepts all logging recorder.
func AtAbove ¶
AtAbove return a very simple Enabler which accepts logging recorder's level at or above the value of the n level.
func MatchLevel ¶
MatchLevel return a very simple Enabler which accepts logging recorder's level equals the value of the n level.
func RangeLevel ¶
RangeLevel return a very simple Enabler which accepts logging recorder's level match the range.
type Filter ¶
Filter contains:
- Enabler, the Enabler interface for filter log Recorder
- Layout, the Layout interface for encoding log Recorder
- Apps, the slice of the Appender interface
func (*Filter) Close ¶
func (f *Filter) Close()
Close closes all log appenders in preparation for exiting the program. Calling this is not really imperative, unless you want to guarantee that all log messages are written.
Notice: Close() removes all appenders from the filter.
func (*Filter) Dispatch ¶
Dispatch filters, encodes a log recorder to bytes, and writes it to all appenders.
- Enabler.Enabled, filter log Recorder.
- Layout.Encode, encode log Recorder to bytes.Buffer.
- Apps[i].Enabled, filter log recorder by appender.
- Apps[i].Write, append with log recorder encoded bytes.
type Layout ¶
type Layout interface { // Set sets name-value option. Checkable. Set(name string, v interface{}) error // Encode encodes a log Recorder to bytes. Encode(out *bytes.Buffer, r *Recorder) int }
Layout is is an interface for formatting log record
type Recorder ¶
type Recorder struct { Prefix string // The message prefix Source string // The message source Line int // The source line Level int // The log level Message string // The log message Created time.Time // The time at which the log message was created (nanoseconds) Data map[string]interface{} // Contains all the fields set by the user. Index []string }
Recorder contains all of the pertinent information for each message It is the final or intermediate logging entry also. It contains all the fields passed with With(key, value, ...). It's finally logged when Trace, Debug, Info, Warn, Error, Fatal or Panic is called on it.