Skip to content

Commit

Permalink
CWA customer change: make func needed in CWA public
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhenyuTan-amz committed Mar 23, 2022
1 parent 289c5ce commit 908f02f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ process.yml
/*.conf
resource.syso
versioninfo.json
*.iml
2 changes: 1 addition & 1 deletion logger/event_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ func RegisterEventLogger(name string) error {
return err
}

registerLogger(LogTargetEventlog, &eventLoggerCreator{logger: eventLog})
RegisterLogger(LogTargetEventlog, &eventLoggerCreator{logger: eventLog})
return nil
}
2 changes: 1 addition & 1 deletion logger/event_logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,5 @@ func prepareLogger(t *testing.T) {
eventLog, err := eventlog.Open("telegraf")
require.NoError(t, err)
require.NotNil(t, eventLog)
registerLogger(LogTargetEventlog, &eventLoggerCreator{logger: eventLog})
RegisterLogger(LogTargetEventlog, &eventLoggerCreator{logger: eventLog})
}
12 changes: 7 additions & 5 deletions logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ type LoggerCreator interface {

var loggerRegistry map[string]LoggerCreator

func registerLogger(name string, loggerCreator LoggerCreator) {
// RegisterLogger Make func public for CloudWatch Agent to consume
func RegisterLogger(name string, loggerCreator LoggerCreator) {
if loggerRegistry == nil {
loggerRegistry = make(map[string]LoggerCreator)
}
Expand Down Expand Up @@ -89,7 +90,8 @@ func (t *telegrafLog) Close() error {
return closer.Close()
}

// newTelegrafWriter returns a logging-wrapped writer.
// NewTelegrafWriter returns a logging-wrapped writer.
// Make func public for CloudWatch Agent to consume
func newTelegrafWriter(w io.Writer, c LogConfig) (io.Writer, error) {
timezoneName := c.LogWithTimezone

Expand Down Expand Up @@ -176,7 +178,7 @@ func newLogWriter(cfg LogConfig) io.Writer {

func init() {
tlc := &telegrafLogCreator{}
registerLogger("", tlc)
registerLogger(LogTargetStderr, tlc)
registerLogger(LogTargetFile, tlc)
RegisterLogger("", tlc)
RegisterLogger(LogTargetStderr, tlc)
RegisterLogger(LogTargetFile, tlc)
}

0 comments on commit 908f02f

Please sign in to comment.