Refactor logging in more Go idiomatic style (#6816)

This refactor brings a change which allows
targets to be added in a cleaner way and also
audit is now moved out.

This PR also simplifies logger dependency for auditing
This commit is contained in:
Harshavardhana
2018-11-19 14:47:03 -08:00
committed by Dee Koder
parent d732b1ff9d
commit bfb505aa8e
28 changed files with 618 additions and 481 deletions

View File

@@ -33,25 +33,25 @@ var (
return isatty.IsTerminal(os.Stdout.Fd()) && isatty.IsTerminal(os.Stderr.Fd())
}
colorBold = func() func(a ...interface{}) string {
ColorBold = func() func(a ...interface{}) string {
if isTerminal() {
return color.New(color.Bold).SprintFunc()
}
return fmt.Sprint
}()
colorFgRed = func() func(format string, a ...interface{}) string {
ColorFgRed = func() func(format string, a ...interface{}) string {
if isTerminal() {
return color.New(color.FgRed).SprintfFunc()
}
return fmt.Sprintf
}()
colorBgRed = func() func(format string, a ...interface{}) string {
ColorBgRed = func() func(format string, a ...interface{}) string {
if isTerminal() {
return color.New(color.BgRed).SprintfFunc()
}
return fmt.Sprintf
}()
colorFgWhite = func() func(format string, a ...interface{}) string {
ColorFgWhite = func() func(format string, a ...interface{}) string {
if isTerminal() {
return color.New(color.FgWhite).SprintfFunc()
}
@@ -83,17 +83,5 @@ func ansiRestoreAttributes() {
if isTerminal() {
ansiEscape("8")
}
}
func uniqueEntries(paths []string) []string {
found := map[string]bool{}
unqiue := []string{}
for v := range paths {
if _, ok := found[paths[v]]; !ok {
found[paths[v]] = true
unqiue = append(unqiue, paths[v])
}
}
return unqiue
}