forked from thecubed/gogstash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutputstdout.go
More file actions
50 lines (41 loc) · 1.04 KB
/
outputstdout.go
File metadata and controls
50 lines (41 loc) · 1.04 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
package outputstdout
import (
"context"
"fmt"
"github.com/tsaikd/gogstash/config"
"github.com/tsaikd/gogstash/config/logevent"
)
// ModuleName is the name used in config file
const ModuleName = "stdout"
// OutputConfig holds the configuration json fields and internal objects
type OutputConfig struct {
config.OutputConfig
}
// DefaultOutputConfig returns an OutputConfig struct with default values
func DefaultOutputConfig() OutputConfig {
return OutputConfig{
OutputConfig: config.OutputConfig{
CommonConfig: config.CommonConfig{
Type: ModuleName,
},
},
}
}
// InitHandler initialize the output plugin
func InitHandler(ctx context.Context, raw *config.ConfigRaw) (config.TypeOutputConfig, error) {
conf := DefaultOutputConfig()
err := config.ReflectConfig(raw, &conf)
if err != nil {
return nil, err
}
return &conf, nil
}
// Output event
func (t *OutputConfig) Output(ctx context.Context, event logevent.LogEvent) (err error) {
raw, err := event.MarshalIndent()
if err != nil {
return
}
fmt.Println(string(raw))
return
}