Documentation
¶
Overview ¶
Pretty(ish) print configuration output on application startup! Make it easy to see what those env vars actually told your app to do!
The most basic usage is:
rubberneck.Print(myConfigStruct)
Which will print out an output something like:
Settings ----------------------------------------- * AdvertiseIP: 192.168.168.168 * ClusterIPs: [10.3.18.204 123.123.123.123] * ConfigFile: sidecar.toml * ClusterName: default * CpuProfile: false * Discover: [docker static] * HAproxyDisable: false * LoggingLevel: * Sidecar: * ExcludeIPs: [192.168.168.168] * StatsAddr: * PushPullInterval: * Duration: 20s * GossipMessages: 20 * LoggingFormat: standard * LoggingLevel: debug * DefaultCheckEndpoint: * DockerDiscovery: * DockerURL: unix:///var/run/docker.sock --------------------------------------------------
You may configure a Printer for your specific needs if the default usage is not suited to your purposes.
Index ¶
Constants ¶
const ( AddLineFeed = iota NoAddLineFeed = iota )
AddLineFeed will direct the Printer to add line feeds at the end of each output. NoAddLineFeed will not. This is useful for controlling the display of output when functions exhibit different behavior. For example, fmt.Printf wants line feeds added, whereas logrus.Infof does not.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MaskFunc ¶ added in v1.1.0
MaskFunc takes a config argument and returns a string that is used to mask config values. This is useful to redact passwords etc.
type MaskWithValueFunc ¶ added in v1.3.0
MaskWithValueFunc is the same as MaskFunc but provides the original value to the masking function, which is expected to identify the type itself.
type Printer ¶
type Printer struct { Show PrinterFunc Mask MaskFunc MaskWithValue MaskWithValueFunc }
Printer defines the signature of a function that can be used to display the configuration. This signature is used by fmt.Printf, log.Printf, various logging output levels from the logrus package, and others.
func NewDefaultPrinter ¶
func NewDefaultPrinter() *Printer
NewDefaultPrinter returns a Printer configured to write to stdout.
func NewPrinter ¶
func NewPrinter(fn PrinterFunc, lineFeed int) *Printer
NewPrinter returns a Printer configured to use the supplied function to output to the supplied function.
func NewPrinterWithKeyMasking ¶ added in v1.1.0
func NewPrinterWithKeyMasking(fn PrinterFunc, mk MaskFunc, lineFeed int) *Printer
NewPrinterWithKeyMasking returns a Printer configured to use printer function `fn` for output and the masking function `mk` for redacting certain keys.
func NewPrinterWithKeyValueMasking ¶ added in v1.3.0
func NewPrinterWithKeyValueMasking(fn PrinterFunc, mk MaskWithValueFunc, lineFeed int) *Printer
NewPrinterWithKeyValueMasking returns a Printer configured to use printer function `fn` for output and the value masking function `mk` for redacting certain keys.
func (*Printer) Print ¶
func (p *Printer) Print(objs ...interface{})
Print attempts to pretty print the contents of each obj in a format suitable for displaying the configuration of an application on startup. It uses a default label of 'Settings' for the output.
func (*Printer) PrintWithLabel ¶
PrintWithLabel attempts to pretty print the contents of each obj in a format suitable for displaying the configuration of an application on startup. It takes a label argument which is a string to be printed into the title bar in the output.
type PrinterFunc ¶
type PrinterFunc func(format string, v ...interface{})
Conforms to the signature used by fmt.Printf and log.Printf among many functions available in other packages.