-
Notifications
You must be signed in to change notification settings - Fork 184
/
config.go
42 lines (38 loc) · 1.31 KB
/
config.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
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT
package logs
import "github.com/aws/amazon-cloudwatch-agent/tool/runtime"
type Config struct {
FilePath string `file_path`
LogGroup string `log_group_name`
LogStream string `log_stream_name`
TimestampFormat string `timestamp_format`
Timezone string `timezone`
MultiLineStartPattern string `multi_line_start_pattern`
Encoding string `encoding`
Retention int `retention_in_days`
}
func (config *Config) ToMap(ctx *runtime.Context) (string, map[string]interface{}) {
resultMap := make(map[string]interface{})
resultMap["file_path"] = config.FilePath
resultMap["log_group_name"] = config.LogGroup
if config.TimestampFormat != "" {
resultMap["timestamp_format"] = config.TimestampFormat
}
if config.Timezone != "" {
resultMap["timezone"] = config.Timezone
}
if config.MultiLineStartPattern != "" {
resultMap["multi_line_start_pattern"] = config.MultiLineStartPattern
}
if config.LogStream != "" {
resultMap["log_stream_name"] = config.LogStream
}
if config.Encoding != "" {
resultMap["encoding"] = config.Encoding
}
if config.Retention != 0 {
resultMap["retention_in_days"] = config.Retention
}
return "", resultMap
}