-
Notifications
You must be signed in to change notification settings - Fork 1
/
funcAddFailMatchFlagToFileLog.go
59 lines (53 loc) · 1.59 KB
/
funcAddFailMatchFlagToFileLog.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package iotmakerdockerbuilder
import (
"github.com/helmutkemper/util"
"path/filepath"
"strings"
)
// AddFailMatchFlagToFileLog
//
// Similar:
//
// AddFailMatchFlag(), AddFailMatchFlagToFileLog(), AddFilterToFail()
//
// English:
//
// Looks for error text in the container's standard output and saves it to a log file on the host
// computer
//
// Input:
// value: Error text
// logDirectoryPath: File path where the container's standard output filed in a `log.N.log` file
// will be saved, where N is an automatically incremented number. e.g.: "./bug/critical/"
//
// Output:
// err: Default error object
//
// Português:
//
// Procura por um texto indicativo de erro na saída padrão do container e o salva em um arquivo de
// log no computador hospedeiro
//
// Entrada:
// value: Texto indicativo de erro
// logDirectoryPath: Caminho do arquivo onde será salva a saída padrão do container arquivada em
// um arquivo `log.N.log`, onde N é um número incrementado automaticamente.
// Ex.: "./bug/critical/"
//
// Output:
// err: Objeto de erro padrão
func (e *ContainerBuilder) AddFailMatchFlagToFileLog(value, logDirectoryPath string) (err error) {
if e.chaos.filterFail == nil {
e.chaos.filterFail = make([]LogFilter, 0)
}
if strings.HasPrefix(logDirectoryPath, string(filepath.Separator)) == false {
logDirectoryPath += string(filepath.Separator)
}
err = util.DirMake(logDirectoryPath)
if err != nil {
util.TraceToLog()
return
}
e.chaos.filterFail = append(e.chaos.filterFail, LogFilter{Match: value, LogPath: logDirectoryPath})
return
}