1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2025-10-09 14:08:23 +00:00

cli.test: colorize the success/failure

updating and adding vendored source to do it

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2018-08-19 18:34:53 -04:00
parent 03270d3d9e
commit 37d776ac40
Signed by: vbatts
GPG key ID: 10937E57733F1362
408 changed files with 170562 additions and 132 deletions

View file

@ -15,7 +15,7 @@ type Hook struct {
// Entries is an array of all entries that have been received by this hook.
// For safe access, use the AllEntries() method, rather than reading this
// value directly.
Entries []*logrus.Entry
Entries []logrus.Entry
mu sync.RWMutex
}
@ -52,7 +52,7 @@ func NewNullLogger() (*logrus.Logger, *Hook) {
func (t *Hook) Fire(e *logrus.Entry) error {
t.mu.Lock()
defer t.mu.Unlock()
t.Entries = append(t.Entries, e)
t.Entries = append(t.Entries, *e)
return nil
}
@ -68,9 +68,7 @@ func (t *Hook) LastEntry() *logrus.Entry {
if i < 0 {
return nil
}
// Make a copy, for safety
e := *t.Entries[i]
return &e
return &t.Entries[i]
}
// AllEntries returns all entries that were logged.
@ -79,10 +77,9 @@ func (t *Hook) AllEntries() []*logrus.Entry {
defer t.mu.RUnlock()
// Make a copy so the returned value won't race with future log requests
entries := make([]*logrus.Entry, len(t.Entries))
for i, entry := range t.Entries {
for i := 0; i < len(t.Entries); i++ {
// Make a copy, for safety
e := *entry
entries[i] = &e
entries[i] = &t.Entries[i]
}
return entries
}
@ -91,5 +88,5 @@ func (t *Hook) AllEntries() []*logrus.Entry {
func (t *Hook) Reset() {
t.mu.Lock()
defer t.mu.Unlock()
t.Entries = make([]*logrus.Entry, 0)
t.Entries = make([]logrus.Entry, 0)
}