Unify logging process

This commit is contained in:
2019-12-03 23:51:03 +01:00
parent a368f18915
commit e9ec8ad46c
11 changed files with 124 additions and 72 deletions

View File

@@ -16,15 +16,20 @@ func AppendIfUnique(appendee string, array []string) []string {
return append(array, appendee)
}
// Prints each element, along with a small ASCII tree
func PrintTree(strarr []string) {
// Generates a small ASCII tree for the given string array
func GenerateTree(strarr []string) string {
tmpstr := ""
// iterate over each element
for iter, elem := range strarr {
// check if we got the last element
if iter < len(strarr) - 1 {
fmt.Printf("|- %s\n", elem)
tmpstr = fmt.Sprintf("%s|- %s\n", tmpstr, elem)
} else {
fmt.Printf("'- %s\n\n", elem)
tmpstr = fmt.Sprintf( "%s'- %s\n", tmpstr, elem)
}
}
// Return constructed (grown?) tree
return tmpstr
}