Skip to content

Commit 1d19170

Browse files
committed
rename references to AppLogEmitter
1 parent 01db5de commit 1d19170

8 files changed

Lines changed: 28 additions & 28 deletions

File tree

src/cmd/syslog-agent/app/syslog_agent.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ func NewSyslogAgent(
8484
WriteTimeout: 10 * time.Second,
8585
},
8686
m,
87-
syslog.NewLoggregatorEmitter(logClient, "syslog_agent"),
87+
syslog.NewAppLogEmitter(logClient, "syslog_agent"),
8888
)
8989

9090
connector := syslog.NewSyslogConnector(
9191
cfg.DrainSkipCertVerify,
9292
timeoutwaitgroup.New(time.Minute),
9393
writerFactory,
9494
m,
95-
syslog.WithLoggregatorEmitter(syslog.NewLoggregatorEmitter(logClient, "syslog_agent")),
95+
syslog.WithAppLogEmitter(syslog.NewAppLogEmitter(logClient, "syslog_agent")),
9696
)
9797

9898
var cacheClient *cache.CacheClient
@@ -113,7 +113,7 @@ func NewSyslogAgent(
113113
m,
114114
cfg.WarnOnInvalidDrains,
115115
l,
116-
syslog.NewLoggregatorEmitter(logClient, "syslog_agent"),
116+
syslog.NewAppLogEmitter(logClient, "syslog_agent"),
117117
)
118118
cupsFetcher = bindings.NewDrainParamParser(cupsFetcher, cfg.DefaultDrainMetadata)
119119
}

src/pkg/egress/syslog/app_log_emitter.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ type AppLogEmitter struct {
1414
sourceIndex string
1515
}
1616

17-
// WriteLog writes a message in the application log stream using a LogClient.
18-
func (appLogEmitter *AppLogEmitter) WriteLog(appID string, message string) {
17+
// EmitLog writes a message in the application log stream using a LogClient.
18+
func (appLogEmitter *AppLogEmitter) EmitLog(appID string, message string) {
1919
if appLogEmitter.logClient == nil || appID == "" {
2020
return
2121
}
@@ -31,8 +31,8 @@ func (appLogEmitter *AppLogEmitter) WriteLog(appID string, message string) {
3131
appLogEmitter.logClient.EmitLog(message, option)
3232
}
3333

34-
// NewLoggregatorEmitter creates a new AppLogEmitter.
35-
func NewLoggregatorEmitter(logClient LogClient, sourceIndex string) AppLogEmitter {
34+
// NewAppLogEmitter creates a new AppLogEmitter.
35+
func NewAppLogEmitter(logClient LogClient, sourceIndex string) AppLogEmitter {
3636
return AppLogEmitter{
3737
logClient: logClient,
3838
sourceIndex: sourceIndex,

src/pkg/egress/syslog/app_log_emitter_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import (
77
)
88

99
var _ = Describe("Loggregator Emitter", func() {
10-
Describe("WriteLog()", func() {
10+
Describe("EmitLog()", func() {
1111
It("emits a log message", func() {
1212
logClient := NewSpyLogClient()
13-
emitter := syslog.NewLoggregatorEmitter(logClient, "0")
13+
emitter := syslog.NewAppLogEmitter(logClient, "0")
1414

15-
emitter.WriteLog("app-id", "some-message")
15+
emitter.EmitLog("app-id", "some-message")
1616

1717
messages := logClient.message()
1818
appIDs := logClient.appID()
@@ -28,9 +28,9 @@ var _ = Describe("Loggregator Emitter", func() {
2828

2929
It("does not emit a log message if the appID is empty", func() {
3030
logClient := NewSpyLogClient()
31-
emitter := syslog.NewLoggregatorEmitter(logClient, "0")
31+
emitter := syslog.NewAppLogEmitter(logClient, "0")
3232

33-
emitter.WriteLog("", "some-message")
33+
emitter.EmitLog("", "some-message")
3434

3535
messages := logClient.message()
3636
appIDs := logClient.appID()

src/pkg/egress/syslog/retry_writer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (r *RetryWriter) Write(e *loggregator_v2.Envelope) error {
5959

6060
sleepDuration := r.retryDuration(i)
6161
log.Printf(logTemplate, r.binding.URL.Host, sleepDuration, err)
62-
r.emitter.WriteLog(e.SourceId, fmt.Sprintf(logTemplate, r.binding.URL.Host, sleepDuration, err))
62+
r.emitter.EmitLog(e.SourceId, fmt.Sprintf(logTemplate, r.binding.URL.Host, sleepDuration, err))
6363

6464
time.Sleep(sleepDuration)
6565
}

src/pkg/egress/syslog/syslog_connector.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type SyslogConnector struct {
4444

4545
droppedMetric metrics.Counter
4646

47-
loggregatorEmitter AppLogEmitter
47+
appLogEmitter AppLogEmitter
4848
}
4949

5050
// NewSyslogConnector configures and returns a new SyslogConnector.
@@ -78,11 +78,11 @@ func NewSyslogConnector(
7878
// ConnectorOption allows a syslog connector to be customized.
7979
type ConnectorOption func(*SyslogConnector)
8080

81-
// WithLoggregatorEmitter returns a ConnectorOption that will set up logging for any
81+
// WithAppLogEmitter returns a ConnectorOption that will set up logging for any
8282
// information about a binding.
83-
func WithLoggregatorEmitter(emitter AppLogEmitter) ConnectorOption {
83+
func WithAppLogEmitter(emitter AppLogEmitter) ConnectorOption {
8484
return func(sc *SyslogConnector) {
85-
sc.loggregatorEmitter = emitter
85+
sc.appLogEmitter = emitter
8686
}
8787
}
8888

@@ -94,7 +94,7 @@ func (w *SyslogConnector) Connect(ctx context.Context, b Binding) (egress.Writer
9494
return nil, err
9595
}
9696

97-
writer, err := w.writerFactory.NewWriter(urlBinding, w.loggregatorEmitter)
97+
writer, err := w.writerFactory.NewWriter(urlBinding, w.appLogEmitter)
9898
if err != nil {
9999
return nil, err
100100
}
@@ -122,7 +122,7 @@ func (w *SyslogConnector) Connect(ctx context.Context, b Binding) (egress.Writer
122122
w.droppedMetric.Add(float64(missed))
123123
drainDroppedMetric.Add(float64(missed))
124124

125-
w.loggregatorEmitter.WriteLog(b.AppId, fmt.Sprintf("%d messages lost for application %s in user provided syslog drain with url %s", missed, b.AppId, anonymousUrl.String()))
125+
w.appLogEmitter.EmitLog(b.AppId, fmt.Sprintf("%d messages lost for application %s in user provided syslog drain with url %s", missed, b.AppId, anonymousUrl.String()))
126126
w.emitStandardOutErrorLog(b.AppId, urlBinding.Scheme(), anonymousUrl.String(), missed)
127127
}), w.wg)
128128

src/pkg/egress/syslog/syslog_connector_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ var _ = Describe("SyslogConnector", func() {
178178
spyWaitGroup,
179179
writerFactory,
180180
sm,
181-
syslog.WithLoggregatorEmitter(syslog.NewLoggregatorEmitter(logClient, "3")),
181+
syslog.WithAppLogEmitter(syslog.NewAppLogEmitter(logClient, "3")),
182182
)
183183

184184
binding := syslog.Binding{AppId: "app-id",
@@ -220,7 +220,7 @@ var _ = Describe("SyslogConnector", func() {
220220
spyWaitGroup,
221221
writerFactory,
222222
sm,
223-
syslog.WithLoggregatorEmitter(syslog.NewLoggregatorEmitter(logClient, "3")),
223+
syslog.WithAppLogEmitter(syslog.NewAppLogEmitter(logClient, "3")),
224224
)
225225

226226
binding := syslog.Binding{Drain: syslog.Drain{Url: "dropping://"}}

src/pkg/egress/syslog/writer_factory.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (f WriterFactory) NewWriter(ub *URLBinding, emitter AppLogEmitter) (egress.
6464
if err != nil {
6565
errorMessage := err.Error()
6666
err = NewWriterFactoryErrorf(ub.URL, "failed to load certificate: %s", errorMessage)
67-
f.emitter.WriteLog(ub.AppID, fmt.Sprintf("failed to load certificate: %s", errorMessage))
67+
f.emitter.EmitLog(ub.AppID, fmt.Sprintf("failed to load certificate: %s", errorMessage))
6868
return nil, err
6969
}
7070
tlsCfg.Certificates = []tls.Certificate{cert}
@@ -73,7 +73,7 @@ func (f WriterFactory) NewWriter(ub *URLBinding, emitter AppLogEmitter) (egress.
7373
ok := tlsCfg.RootCAs.AppendCertsFromPEM(ub.CA)
7474
if !ok {
7575
err := NewWriterFactoryErrorf(ub.URL, "failed to load root CA")
76-
f.emitter.WriteLog(ub.AppID, "failed to load root CA")
76+
f.emitter.EmitLog(ub.AppID, "failed to load root CA")
7777
return nil, err
7878
}
7979
}

src/pkg/ingress/bindings/filtered_binding_fetcher.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,22 @@ func (f *FilteredBindingFetcher) FetchBindings() ([]syslog.Binding, error) {
9090

9191
if invalidScheme(u.Scheme) {
9292
f.printWarning("Invalid scheme %s in syslog drain url %s for application %s", u.Scheme, anonymousUrl.String(), b.AppId)
93-
f.emitter.WriteLog(b.AppId, fmt.Sprintf("Invalid scheme %s in syslog drain url %s", u.Scheme, anonymousUrl.String()))
93+
f.emitter.EmitLog(b.AppId, fmt.Sprintf("Invalid scheme %s in syslog drain url %s", u.Scheme, anonymousUrl.String()))
9494
continue
9595
}
9696

9797
if len(u.Host) == 0 {
9898
invalidDrains += 1
9999
f.printWarning("No hostname found in syslog drain url %s for application %s", anonymousUrl.String(), b.AppId)
100-
f.emitter.WriteLog(b.AppId, fmt.Sprintf("No hostname found in syslog drain url %s", anonymousUrl.String()))
100+
f.emitter.EmitLog(b.AppId, fmt.Sprintf("No hostname found in syslog drain url %s", anonymousUrl.String()))
101101
continue
102102
}
103103

104104
_, exists := f.failedHostsCache.Get(u.Host)
105105
if exists {
106106
invalidDrains += 1
107107
f.printWarning("Skipped resolve ip address for syslog drain with url %s for application %s due to prior failure", anonymousUrl.String(), b.AppId)
108-
f.emitter.WriteLog(b.AppId, fmt.Sprintf("Skipped resolve ip address for syslog drain with url %s due to prior failure", anonymousUrl.String()))
108+
f.emitter.EmitLog(b.AppId, fmt.Sprintf("Skipped resolve ip address for syslog drain with url %s due to prior failure", anonymousUrl.String()))
109109
continue
110110
}
111111

@@ -114,7 +114,7 @@ func (f *FilteredBindingFetcher) FetchBindings() ([]syslog.Binding, error) {
114114
invalidDrains += 1
115115
f.failedHostsCache.Set(u.Host, true)
116116
f.printWarning("Cannot resolve ip address for syslog drain with url %s for application %s", anonymousUrl.String(), b.AppId)
117-
f.emitter.WriteLog(b.AppId, fmt.Sprintf("Cannot resolve ip address for syslog drain with url %s", anonymousUrl.String()))
117+
f.emitter.EmitLog(b.AppId, fmt.Sprintf("Cannot resolve ip address for syslog drain with url %s", anonymousUrl.String()))
118118
continue
119119
}
120120

@@ -123,7 +123,7 @@ func (f *FilteredBindingFetcher) FetchBindings() ([]syslog.Binding, error) {
123123
invalidDrains += 1
124124
blacklistedDrains += 1
125125
f.printWarning("Resolved ip address for syslog drain with url %s for application %s is blacklisted", anonymousUrl.String(), b.AppId)
126-
f.emitter.WriteLog(b.AppId, fmt.Sprintf("Resolved ip address for syslog drain with url %s is blacklisted", anonymousUrl.String()))
126+
f.emitter.EmitLog(b.AppId, fmt.Sprintf("Resolved ip address for syslog drain with url %s is blacklisted", anonymousUrl.String()))
127127
continue
128128
}
129129

0 commit comments

Comments
 (0)