feat: allow to export logs

Signed-off-by: huanggze <loganhuang@yunify.com>
This commit is contained in:
huanggze
2019-09-19 23:25:18 +08:00
parent 49dacd3e70
commit a71b35db9c
11 changed files with 346 additions and 257 deletions

View File

@@ -14,12 +14,17 @@ limitations under the License.
package stringutils
import (
"regexp"
"strings"
"unicode/utf8"
"github.com/asaskevich/govalidator"
)
const ansi = "[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
var re = regexp.MustCompile(ansi)
// Creates an slice of slice values not included in the other given slice.
func Diff(base, exclude []string) (result []string) {
excludeMap := make(map[string]bool)
@@ -83,3 +88,7 @@ func Split(str string, sep string) []string {
}
return strings.Split(str, sep)
}
func StripAnsi(str string) string {
return re.ReplaceAllString(str, "")
}