Documentation ¶
Index ¶
- Constants
- type JSONPrinter
- type OutputPrinter
- type TablePrinter
- func (t *TablePrinter) AddColumn(name string, getter interface{})
- func (t *TablePrinter) LogObj(log logger.Logger, msgFmt string, obj interface{}) error
- func (t *TablePrinter) PrintObj(obj interface{}, writer io.Writer) error
- func (t *TablePrinter) PrintObjWithKind(kind string, obj interface{}, writer io.Writer) error
- type Type
- type YAMLPrinter
Constants ¶
const ( // YAMLType represents a printer of YAML type. YAMLType = Type("yaml") // JSONType represents a printer of JSON type. JSONType = Type("json") // TableType represents a printer of Table type. TableType = Type("table") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSONPrinter ¶
type JSONPrinter struct {
// contains filtered or unexported fields
}
JSONPrinter is a printer that outputs an object formatted as JSON
func (*JSONPrinter) LogObj ¶
func (j *JSONPrinter) LogObj(log logger.Logger, msgFmt string, obj interface{}) error
LogObj will print the passed object formatted as JSON to the logger.
func (*JSONPrinter) PrintObj ¶
func (j *JSONPrinter) PrintObj(obj interface{}, writer io.Writer) error
PrintObj will print the passed object formatted as JSON to the supplied writer.
func (*JSONPrinter) PrintObjWithKind ¶
func (j *JSONPrinter) PrintObjWithKind(kind string, obj interface{}, writer io.Writer) error
PrintObjWithKind will print the passed object formatted as YAML to the supplied writer. This printer ignores kind argument.
type OutputPrinter ¶
type OutputPrinter interface { PrintObjWithKind(kind string, obj interface{}, writer io.Writer) error PrintObj(obj interface{}, writer io.Writer) error LogObj(log logger.Logger, msgFmt string, obj interface{}) error }
OutputPrinter is the interface that printer must implement. This allows new printers to be added in the future.
func NewJSONPrinter ¶
func NewJSONPrinter() OutputPrinter
NewJSONPrinter creates a new JsonPrinter with defaults for level of indentation.
func NewPrinter ¶
func NewPrinter(printerType Type) (OutputPrinter, error)
NewPrinter creates a new printer based in the printer type requested.
func NewTablePrinter ¶
func NewTablePrinter() OutputPrinter
NewTablePrinter creates a new TablePrinter with defaults.
type TablePrinter ¶
type TablePrinter struct {
// contains filtered or unexported fields
}
TablePrinter is a printer that outputs an object formatted as table
func (*TablePrinter) AddColumn ¶
func (t *TablePrinter) AddColumn(name string, getter interface{})
AddColumn adds a column to the table that will be printed
func (*TablePrinter) LogObj ¶
func (t *TablePrinter) LogObj(log logger.Logger, msgFmt string, obj interface{}) error
LogObj will print the passed object formatted as a table to the logger.
func (*TablePrinter) PrintObj ¶
func (t *TablePrinter) PrintObj(obj interface{}, writer io.Writer) error
PrintObj will print the passed object formatted as textual table to the supplied writer.
func (*TablePrinter) PrintObjWithKind ¶
func (t *TablePrinter) PrintObjWithKind(kind string, obj interface{}, writer io.Writer) error
PrintObjWithKind will print the passed object formatted as textual table to the supplied writer.
type YAMLPrinter ¶
type YAMLPrinter struct {
// contains filtered or unexported fields
}
YAMLPrinter is a printer that outputs an object formatted as YAML
func (*YAMLPrinter) LogObj ¶
func (y *YAMLPrinter) LogObj(log logger.Logger, msgFmt string, obj interface{}) error
LogObj will print the passed object formatted as YAML to the logger.
func (*YAMLPrinter) PrintObj ¶
func (y *YAMLPrinter) PrintObj(obj interface{}, writer io.Writer) error
PrintObj will print the passed object formatted as YAML to the supplied writer.
func (*YAMLPrinter) PrintObjWithKind ¶
func (y *YAMLPrinter) PrintObjWithKind(kind string, obj interface{}, writer io.Writer) error
PrintObjWithKind will print the passed object formatted as YAML to the supplied writer. This printer ignores kind argument.