diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-02-06 13:42:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-06 13:42:47 +0100 |
commit | d321c5d942f85b56852532edfd225dcdd591f817 (patch) | |
tree | 30ad98bcc2c2dd1136f46a48cbc44d422adfa184 /vendor/github.com/hpcloud/tail/util/util.go | |
parent | 314e1a9c5a2041d2263bb74f1d21aa2798154d76 (diff) | |
parent | 9ac0ebb0791851aea81ecc847802db5a39bfb6e7 (diff) | |
download | podman-d321c5d942f85b56852532edfd225dcdd591f817.tar.gz podman-d321c5d942f85b56852532edfd225dcdd591f817.tar.bz2 podman-d321c5d942f85b56852532edfd225dcdd591f817.zip |
Merge pull request #2259 from vrothberg/vendor-check
Vendor check
Diffstat (limited to 'vendor/github.com/hpcloud/tail/util/util.go')
-rw-r--r-- | vendor/github.com/hpcloud/tail/util/util.go | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/vendor/github.com/hpcloud/tail/util/util.go b/vendor/github.com/hpcloud/tail/util/util.go new file mode 100644 index 000000000..54151fe39 --- /dev/null +++ b/vendor/github.com/hpcloud/tail/util/util.go @@ -0,0 +1,48 @@ +// Copyright (c) 2015 HPE Software Inc. All rights reserved. +// Copyright (c) 2013 ActiveState Software Inc. All rights reserved. + +package util + +import ( + "fmt" + "log" + "os" + "runtime/debug" +) + +type Logger struct { + *log.Logger +} + +var LOGGER = &Logger{log.New(os.Stderr, "", log.LstdFlags)} + +// fatal is like panic except it displays only the current goroutine's stack. +func Fatal(format string, v ...interface{}) { + // https://github.com/hpcloud/log/blob/master/log.go#L45 + LOGGER.Output(2, fmt.Sprintf("FATAL -- "+format, v...)+"\n"+string(debug.Stack())) + os.Exit(1) +} + +// partitionString partitions the string into chunks of given size, +// with the last chunk of variable size. +func PartitionString(s string, chunkSize int) []string { + if chunkSize <= 0 { + panic("invalid chunkSize") + } + length := len(s) + chunks := 1 + length/chunkSize + start := 0 + end := chunkSize + parts := make([]string, 0, chunks) + for { + if end > length { + end = length + } + parts = append(parts, s[start:end]) + if end == length { + break + } + start, end = end, end+chunkSize + } + return parts +} |