forked from helmutkemper/iotmaker.docker.builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuncAddStartChaosMatchFlagToFileLog.go
More file actions
60 lines (54 loc) · 1.64 KB
/
Copy pathfuncAddStartChaosMatchFlagToFileLog.go
File metadata and controls
60 lines (54 loc) · 1.64 KB
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
60
package iotmakerdockerbuilder
import (
"github.com/helmutkemper/util"
"path/filepath"
"strings"
)
// AddStartChaosMatchFlagToFileLog
//
// Similar:
//
// AddStartChaosMatchFlag(), AddStartChaosMatchFlagToFileLog(), AddFilterToStartChaos()
//
// English:
//
// Adds a filter to the container's standard output to look for a textual value releasing the start
// of the chaos test.
//
// 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:
//
// Adiciona um filtro na saída padrão do container para procurar um valor textual liberando o início
// do teste de caos.
//
// 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) AddStartChaosMatchFlagToFileLog(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
}