Functional Options - pd93/plog GitHub Wiki

PLog uses the functional options design pattern when creating new objects. If you are not familiar with this design pattern, I highly recommend reading Dave Cheney's blog post which does an excellent job of explaining and justifying their use.

In summary, functional options allow the user of a package to call a single constructor and to pass as many configuration options as required. This is - in my opinion - far easier to understand than multiple constructors to cover all permutations.

The following PLog functions all take functional options as arguments:

func NewLogger()
func NewFile()
func New