本文整理匯總了Golang中github.com/cloudfoundry/gosteno.Logger.Infof方法的典型用法代碼示例。如果您正苦於以下問題:Golang Logger.Infof方法的具體用法?Golang Logger.Infof怎麽用?Golang Logger.Infof使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/gosteno.Logger
的用法示例。
在下文中一共展示了Logger.Infof方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: New
func New(address string, name string, writer writers.ByteArrayWriter, logger *gosteno.Logger) (*NetworkReader, error) {
connection, err := net.ListenPacket("udp4", address)
if err != nil {
return nil, err
}
logger.Infof("Listening on %s", address)
return &NetworkReader{
connection: connection,
contextName: name,
writer: writer,
logger: logger,
}, nil
}
示例2: New
func New(apiEndpoint string, sinkManager *sinkmanager.SinkManager, keepAliveInterval time.Duration, messageDrainBufferSize uint, dropsondeOrigin string, logger *gosteno.Logger) (*WebsocketServer, error) {
logger.Infof("WebsocketServer: Listening for sinks at %s", apiEndpoint)
listener, e := net.Listen("tcp", apiEndpoint)
if e != nil {
return nil, e
}
return &WebsocketServer{
listener: listener,
sinkManager: sinkManager,
keepAliveInterval: keepAliveInterval,
bufferSize: messageDrainBufferSize,
logger: logger,
dropsondeOrigin: dropsondeOrigin,
done: make(chan struct{}),
}, nil
}
示例3: initializeDopplerPool
func initializeDopplerPool(conf *config.Config, logger *gosteno.Logger) (*eventmarshaller.EventMarshaller, error) {
adapter, err := storeAdapterProvider(conf.EtcdUrls, conf.EtcdMaxConcurrentRequests)
if err != nil {
return nil, err
}
err = adapter.Connect()
if err != nil {
logger.Warnd(map[string]interface{}{
"error": err.Error(),
}, "Failed to connect to etcd")
}
var protocols []string
clientPool := make(map[string]clientreader.ClientPool)
writers := make(map[string]eventmarshaller.ByteWriter)
for _, protocol := range conf.Protocols {
proto := string(protocol)
protocols = append(protocols, proto)
switch proto {
case "udp":
udpCreator := clientpool.NewUDPClientCreator(logger)
udpWrapper := dopplerforwarder.NewUDPWrapper([]byte(conf.SharedSecret), logger)
udpPool := clientpool.NewDopplerPool(logger, udpCreator)
udpForwarder := dopplerforwarder.New(udpWrapper, udpPool, logger)
clientPool[proto] = udpPool
writers[proto] = udpForwarder
case "tcp":
tcpCreator := clientpool.NewTCPClientCreator(logger, nil)
tcpWrapper := dopplerforwarder.NewWrapper(logger, proto)
tcpPool := clientpool.NewDopplerPool(logger, tcpCreator)
tcpForwarder := dopplerforwarder.New(tcpWrapper, tcpPool, logger)
tcpBatchInterval := time.Duration(conf.TCPBatchIntervalMilliseconds) * time.Millisecond
batchWriter, err := batch.NewWriter(tcpForwarder, conf.TCPBatchSizeBytes, tcpBatchInterval, logger)
if err != nil {
return nil, err
}
clientPool[proto] = tcpPool
writers[proto] = batchWriter
case "tls":
c := conf.TLSConfig
tlsConfig, err := listeners.NewTLSConfig(c.CertFile, c.KeyFile, c.CAFile)
if err != nil {
return nil, err
}
tlsConfig.ServerName = "doppler"
tlsCreator := clientpool.NewTCPClientCreator(logger, tlsConfig)
tlsWrapper := dopplerforwarder.NewWrapper(logger, proto)
tlsPool := clientpool.NewDopplerPool(logger, tlsCreator)
tlsForwarder := dopplerforwarder.New(tlsWrapper, tlsPool, logger)
tcpBatchInterval := time.Duration(conf.TCPBatchIntervalMilliseconds) * time.Millisecond
batchWriter, err := batch.NewWriter(tlsForwarder, conf.TCPBatchSizeBytes, tcpBatchInterval, logger)
if err != nil {
return nil, err
}
clientPool[proto] = tlsPool
writers[proto] = batchWriter
}
}
finder := dopplerservice.NewFinder(adapter, conf.LoggregatorDropsondePort, protocols, conf.Zone, logger)
marshaller := eventmarshaller.New(logger)
finder.Start()
go func() {
for {
protocol := clientreader.Read(clientPool, protocols, finder.Next())
logger.Infof("Chose protocol %s from last etcd event, updating writer...", protocol)
marshaller.SetWriter(writers[protocol])
}
}()
return marshaller, nil
}
示例4: initializeDopplerPool
func initializeDopplerPool(conf *config.Config, batcher *metricbatcher.MetricBatcher, logger *gosteno.Logger) (*eventmarshaller.EventMarshaller, error) {
adapter, err := storeAdapterProvider(conf)
if err != nil {
return nil, err
}
backoffStrategy := retrystrategy.Exponential()
err = backoff.Connect(adapter, backoffStrategy, logger, connectionRetries)
if err != nil {
return nil, err
}
var protocols []string
clientPool := make(map[string]clientreader.ClientPool)
writers := make(map[string]eventmarshaller.BatchChainByteWriter)
ip, err := localip.LocalIP()
if err != nil {
return nil, err
}
for protocol := range conf.Protocols {
proto := string(protocol)
protocols = append(protocols, proto)
switch proto {
case "udp":
udpCreator := clientpool.NewUDPClientCreator(logger)
udpWrapper := dopplerforwarder.NewUDPWrapper([]byte(conf.SharedSecret), logger)
udpPool := clientpool.NewDopplerPool(logger, udpCreator)
udpForwarder := dopplerforwarder.New(udpWrapper, udpPool, logger)
clientPool[proto] = udpPool
writers[proto] = udpForwarder
case "tcp":
tcpCreator := clientpool.NewTCPClientCreator(logger, nil)
tcpWrapper := dopplerforwarder.NewWrapper(logger, proto)
tcpPool := clientpool.NewDopplerPool(logger, tcpCreator)
tcpForwarder := dopplerforwarder.New(tcpWrapper, tcpPool, logger)
tcpBatchInterval := time.Duration(conf.TCPBatchIntervalMilliseconds) * time.Millisecond
dropCounter := batch.NewDroppedCounter(tcpForwarder, batcher, origin, ip, conf)
batchWriter, err := batch.NewWriter(
"tcp",
tcpForwarder,
dropCounter,
conf.TCPBatchSizeBytes,
tcpBatchInterval,
logger,
)
if err != nil {
return nil, err
}
clientPool[proto] = tcpPool
writers[proto] = batchWriter
case "tls":
c := conf.TLSConfig
tlsConfig, err := listeners.NewTLSConfig(c.CertFile, c.KeyFile, c.CAFile)
if err != nil {
return nil, err
}
tlsConfig.ServerName = "doppler"
tlsCreator := clientpool.NewTCPClientCreator(logger, tlsConfig)
tlsWrapper := dopplerforwarder.NewWrapper(logger, proto)
tlsPool := clientpool.NewDopplerPool(logger, tlsCreator)
tlsForwarder := dopplerforwarder.New(tlsWrapper, tlsPool, logger)
tcpBatchInterval := time.Duration(conf.TCPBatchIntervalMilliseconds) * time.Millisecond
dropCounter := batch.NewDroppedCounter(tlsForwarder, batcher, origin, ip, conf)
batchWriter, err := batch.NewWriter(
"tls",
tlsForwarder,
dropCounter,
conf.TCPBatchSizeBytes,
tcpBatchInterval,
logger,
)
if err != nil {
return nil, err
}
clientPool[proto] = tlsPool
writers[proto] = batchWriter
}
}
finder := dopplerservice.NewFinder(adapter, conf.LoggregatorDropsondePort, conf.Protocols.Strings(), conf.Zone, logger)
finder.Start()
marshaller := eventmarshaller.New(batcher, logger)
go func() {
for {
protocol := clientreader.Read(clientPool, conf.Protocols.Strings(), finder.Next())
logger.Infof("Chose protocol %s from last etcd event, updating writer...", protocol)
marshaller.SetWriter(writers[protocol])
}
}()
return marshaller, nil
}