Xe Ln Save Abandoned

The natural log function

Project README

ln: The Natural Logger for Go

License GoDoc Build Status Go Report Card

ln provides a simple interface to contextually aware structured logging. The design of ln centers around the idea of key-value pairs, which can be interpreted on the fly, but "Filters" to do things such as aggregated metrics, and report said metrics to, say Librato, or statsd.

"Filters" are like WSGI, or Rack Middleware. They are run "top down" and can abort an emitted log's output at any time, or continue to let it through the chain. However, the interface is slightly different than that. Rather than encapsulating the chain with partial function application, we utilize a simpler method, namely, each plugin defines an Apply function, which takes as an argument the log event, and performs the work of the plugin, only if the Plugin "Applies" to this log event.

If Apply returns false, the iteration through the rest of the filters is aborted, and the log is dropped from further processing.

Examples

type User struct {
	ID       int
	Username string
}

func (u User) F() ln.F {
	return ln.F{
		"user_id":       u.ID,
		"user_username": u.Username,
	}
}

// in some function
u, err := CreateUser(ctx, "Foobar")
if err != nil {
  ln.Error(ctx, err) // errors can also be Fers
  return
}

ln.Log(ctx, ln.Info("created new user"), u) // -> user_id=123 user_username=Foobar msg="created new user"

Current Status: Known Stable

(c) 2015-2019, Andrew Gwozdziewycz, Christine Dodrill, BSD Licensed. See LICENSE for more info.

This library was forked from apg's ln. This library is not the official ln (though it is mostly compatible with it), but it is at least what I think a logger should be.

Open Source Agenda is not affiliated with "Xe Ln" Project. README Source: Xe/ln
Stars
40
Open Issues
0
Last Commit
8 months ago
License

Open Source Agenda Badge

Open Source Agenda Rating