1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

MAINT: Unify provider outputs to pkg/printer (#1546)

* Unify provider outputs to pkg/printer

Signed-off-by: Jan-Philipp Benecke <jan-philipp@bnck.me>

* No need for custom Errorf

Signed-off-by: Jan-Philipp Benecke <jan-philipp@bnck.me>

* Add missing import for activedir

Signed-off-by: Jan-Philipp Benecke <jan-philipp@bnck.me>

* Add missing fmt import for activedir

Signed-off-by: Jan-Philipp Benecke <jan-philipp@bnck.me>
This commit is contained in:
Jan-Philipp Benecke
2022-06-18 15:01:02 +02:00
committed by GitHub
parent ba2c7f9c0e
commit bcb968411a
39 changed files with 167 additions and 136 deletions

View File

@@ -27,7 +27,9 @@ type CLI interface {
type Printer interface {
Debugf(fmt string, args ...interface{})
Printf(fmt string, args ...interface{})
Println(lines ...string)
Warnf(fmt string, args ...interface{})
Errorf(fmt string, args ...interface{})
}
// Debugf is called to print/format debug information.
@@ -40,11 +42,21 @@ func Printf(fmt string, args ...interface{}) {
DefaultPrinter.Printf(fmt, args...)
}
// Println is called to print/format information.
func Println(lines ...string) {
DefaultPrinter.Println(lines...)
}
// Warnf is called to print/format a warning.
func Warnf(fmt string, args ...interface{}) {
DefaultPrinter.Warnf(fmt, args...)
}
// Errorf is called to print/format an error.
func Errorf(fmt string, args ...interface{}) {
DefaultPrinter.Errorf(fmt, args...)
}
var (
// DefaultPrinter is the default Printer, used by Debugf, Printf, and Warnf.
DefaultPrinter = &ConsolePrinter{
@@ -143,7 +155,17 @@ func (c ConsolePrinter) Printf(format string, args ...interface{}) {
fmt.Fprintf(c.Writer, format, args...)
}
// Println is called to print/format information.
func (c ConsolePrinter) Println(lines ...string) {
fmt.Fprintln(c.Writer, lines)
}
// Warnf is called to print/format a warning.
func (c ConsolePrinter) Warnf(format string, args ...interface{}) {
fmt.Fprintf(c.Writer, "WARNING: "+format, args...)
}
// Errorf is called to print/format an error.
func (c ConsolePrinter) Errorf(format string, args ...interface{}) {
fmt.Fprintf(c.Writer, "ERROR: "+format, args...)
}