forked from projectdiscovery/nuclei
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulti_writer.go
More file actions
77 lines (65 loc) · 1.66 KB
/
multi_writer.go
File metadata and controls
77 lines (65 loc) · 1.66 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package output
import (
"github.com/logrusorgru/aurora"
)
type MultiWriter struct {
writers []Writer
}
var _ Writer = &MultiWriter{}
// NewMultiWriter creates a new MultiWriter instance
func NewMultiWriter(writers ...Writer) *MultiWriter {
return &MultiWriter{writers: writers}
}
func (mw *MultiWriter) Close() {
for _, writer := range mw.writers {
writer.Close()
}
}
func (mw *MultiWriter) Colorizer() aurora.Aurora {
// Return the colorizer of the first writer
if len(mw.writers) > 0 {
return mw.writers[0].Colorizer()
}
// Default to a no-op colorizer
return aurora.NewAurora(false)
}
func (mw *MultiWriter) Write(event *ResultEvent) error {
for _, writer := range mw.writers {
if err := writer.Write(event); err != nil {
return err
}
}
return nil
}
func (mw *MultiWriter) WriteFailure(event *InternalWrappedEvent) error {
for _, writer := range mw.writers {
if err := writer.WriteFailure(event); err != nil {
return err
}
}
return nil
}
func (mw *MultiWriter) Request(templateID, url, requestType string, err error) {
for _, writer := range mw.writers {
writer.Request(templateID, url, requestType, err)
}
}
func (mw *MultiWriter) WriteStoreDebugData(host, templateID, eventType string, data string) {
for _, writer := range mw.writers {
writer.WriteStoreDebugData(host, templateID, eventType, data)
}
}
func (mw *MultiWriter) RequestStatsLog(statusCode, response string) {
for _, writer := range mw.writers {
writer.RequestStatsLog(statusCode, response)
}
}
func (mw *MultiWriter) ResultCount() int {
count := 0
for _, writer := range mw.writers {
if count := writer.ResultCount(); count > 0 {
return count
}
}
return count
}