本文整理汇总了Golang中github.com/pivotal-golang/lager.Logger.Fatal方法的典型用法代码示例。如果您正苦于以下问题:Golang Logger.Fatal方法的具体用法?Golang Logger.Fatal怎么用?Golang Logger.Fatal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pivotal-golang/lager.Logger
的用法示例。
在下文中一共展示了Logger.Fatal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: generateGuid
func generateGuid(logger lager.Logger) string {
uuid, err := uuid.NewV4()
if err != nil {
logger.Fatal("Couldn't generate uuid", err)
}
return uuid.String()
}
示例2: newUaaClient
func newUaaClient(logger lager.Logger, clock clock.Clock, c *config.Config) uaa_client.Client {
if c.RoutingApi.AuthDisabled {
logger.Info("using-noop-token-fetcher")
return uaa_client.NewNoOpUaaClient()
}
if c.OAuth.Port == -1 {
logger.Fatal("tls-not-enabled", errors.New("GoRouter requires TLS enabled to get OAuth token"), lager.Data{"token-endpoint": c.OAuth.TokenEndpoint, "port": c.OAuth.Port})
}
tokenURL := fmt.Sprintf("https://%s:%d", c.OAuth.TokenEndpoint, c.OAuth.Port)
cfg := &uaa_config.Config{
UaaEndpoint: tokenURL,
SkipVerification: c.OAuth.SkipSSLValidation,
ClientName: c.OAuth.ClientName,
ClientSecret: c.OAuth.ClientSecret,
CACerts: c.OAuth.CACerts,
MaxNumberOfRetries: c.TokenFetcherMaxRetries,
RetryInterval: c.TokenFetcherRetryInterval,
ExpirationBufferInSec: c.TokenFetcherExpirationBufferTimeInSeconds,
}
uaaClient, err := uaa_client.NewClient(logger, cfg, clock)
if err != nil {
logger.Fatal("initialize-token-fetcher-error", err)
}
return uaaClient
}
示例3: initializeServer
func initializeServer(
bbsClient bbs.Client,
executorClient executor.Client,
evacuatable evacuation_context.Evacuatable,
evacuationReporter evacuation_context.EvacuationReporter,
logger lager.Logger,
stackMap rep.StackPathMap,
supportedProviders []string,
) (ifrit.Runner, string) {
lrpStopper := initializeLRPStopper(*cellID, executorClient, logger)
auctionCellRep := auction_cell_rep.New(*cellID, stackMap, supportedProviders, *zone, generateGuid, executorClient, evacuationReporter, logger)
handlers := handlers.New(auctionCellRep, lrpStopper, executorClient, evacuatable, logger)
router, err := rata.NewRouter(rep.Routes, handlers)
if err != nil {
logger.Fatal("failed-to-construct-router", err)
}
ip, err := localip.LocalIP()
if err != nil {
logger.Fatal("failed-to-fetch-ip", err)
}
port := strings.Split(*listenAddr, ":")[1]
address := fmt.Sprintf("http://%s:%s", ip, port)
return http_server.New(*listenAddr, router), address
}
示例4: NewHandler
func NewHandler(
logger lager.Logger,
webcamHost string,
) Handler {
director := func(req *http.Request) {
req.URL.Scheme = "http"
req.URL.Host = webcamHost
req.URL.Path = "/"
req.URL.RawQuery = "action=stream"
}
flushInterval, err := time.ParseDuration("10ms")
if err != nil {
logger.Fatal("golang broke", err)
}
proxy := httputil.ReverseProxy{
Director: director,
FlushInterval: flushInterval,
ErrorLog: log.New(ioutil.Discard, "", 0),
}
return &handler{
logger: logger,
proxy: proxy,
}
}
示例5: connectToNatsServer
func connectToNatsServer(logger lager.Logger, c *config.Config) yagnats.NATSConn {
var natsClient yagnats.NATSConn
var err error
natsServers := c.NatsServers()
attempts := 3
for attempts > 0 {
natsClient, err = yagnats.Connect(natsServers)
if err == nil {
break
} else {
attempts--
time.Sleep(100 * time.Millisecond)
}
}
if err != nil {
logger.Fatal("nats-connection-error", err)
}
natsClient.AddClosedCB(func(conn *nats.Conn) {
logger.Fatal("nats-connection-closed", errors.New("unexpected close"), lager.Data{"connection": *conn})
})
return natsClient
}
示例6: appendSSLConnectionStringParam
func appendSSLConnectionStringParam(logger lager.Logger, driverName, databaseConnectionString, sqlCACertFile string) string {
switch driverName {
case "mysql":
if sqlCACertFile != "" {
certBytes, err := ioutil.ReadFile(sqlCACertFile)
if err != nil {
logger.Fatal("failed-to-read-sql-ca-file", err)
}
caCertPool := x509.NewCertPool()
if ok := caCertPool.AppendCertsFromPEM(certBytes); !ok {
logger.Fatal("failed-to-parse-sql-ca", err)
}
tlsConfig := &tls.Config{
InsecureSkipVerify: false,
RootCAs: caCertPool,
}
mysql.RegisterTLSConfig("bbs-tls", tlsConfig)
databaseConnectionString = fmt.Sprintf("%s?tls=bbs-tls", databaseConnectionString)
}
case "postgres":
if sqlCACertFile == "" {
databaseConnectionString = fmt.Sprintf("%s?sslmode=disable", databaseConnectionString)
} else {
databaseConnectionString = fmt.Sprintf("%s?sslmode=verify-ca&sslrootcert=%s", databaseConnectionString, sqlCACertFile)
}
}
return databaseConnectionString
}
示例7: initializeServer
func initializeServer(logger lager.Logger) ifrit.Runner {
if *staticDirectory == "" {
logger.Fatal("static-directory-missing", nil)
}
transport := &http.Transport{
Proxy: http.ProxyFromEnvironment,
Dial: (&net.Dialer{
Timeout: ccUploadDialTimeout,
KeepAlive: ccUploadKeepAlive,
}).Dial,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: *skipCertVerify,
},
TLSHandshakeTimeout: ccUploadTLSHandshakeTimeout,
}
pollerHttpClient := cf_http.NewClient()
pollerHttpClient.Transport = transport
fileServerHandler, err := handlers.New(*staticDirectory, logger)
if err != nil {
logger.Error("router-building-failed", err)
os.Exit(1)
}
return http_server.New(*serverAddress, fileServerHandler)
}
示例8: connectToNatsServer
func connectToNatsServer(logger lager.Logger, c *config.Config) *nats.Conn {
var natsClient *nats.Conn
var err error
natsServers := c.NatsServers()
attempts := 3
for attempts > 0 {
options := nats.DefaultOptions
options.Servers = natsServers
options.PingInterval = c.NatsClientPingInterval
options.ClosedCB = func(conn *nats.Conn) {
logger.Fatal("nats-connection-closed", errors.New("unexpected close"), lager.Data{"last_error": conn.LastError()})
}
natsClient, err = options.Connect()
if err == nil {
break
} else {
attempts--
time.Sleep(100 * time.Millisecond)
}
}
if err != nil {
logger.Fatal("nats-connection-error", err)
}
return natsClient
}
示例9: Guid
func (*generator) Guid(logger lager.Logger) string {
guid, err := uuid.NewV4()
if err != nil {
logger.Fatal("failed-to-generate-guid", err)
}
return guid.String()
}
示例10: initializeNatsEmitter
func initializeNatsEmitter(natsClient diegonats.NATSClient, logger lager.Logger) nats_emitter.NATSEmitter {
workPool, err := workpool.NewWorkPool(*routeEmittingWorkers)
if err != nil {
logger.Fatal("failed-to-construct-nats-emitter-workpool", err, lager.Data{"num-workers": *routeEmittingWorkers}) // should never happen
}
return nats_emitter.New(natsClient, workPool, logger)
}
示例11: initializeServiceClient
func initializeServiceClient(logger lager.Logger, clock clock.Clock, consulClient *api.Client, sessionManager consuladapter.SessionManager) bbs.ServiceClient {
consulDBSession, err := consuladapter.NewSessionNoChecks("consul-db", *lockTTL, consulClient, sessionManager)
if err != nil {
logger.Fatal("consul-session-failed", err)
}
return bbs.NewServiceClient(consulDBSession, clock)
}
示例12: initializeServiceClient
func initializeServiceClient(logger lager.Logger) nsync.ServiceClient {
consulClient, err := consuladapter.NewClientFromUrl(*consulCluster)
if err != nil {
logger.Fatal("new-client-failed", err)
}
return nsync.NewServiceClient(consulClient, clock.NewClock())
}
示例13: initializeHandler
func initializeHandler(logger lager.Logger, noaaClient *noaa.Consumer, maxInFlight int, apiClient bbs.Client) http.Handler {
apiHandler, err := handler.New(apiClient, noaaClient, maxInFlight, *bulkLRPStatusWorkers, logger)
if err != nil {
logger.Fatal("initialize-handler.failed", err)
}
return apiHandler
}
示例14: createCrypto
func createCrypto(logger lager.Logger, secret string) *secure.AesGCM {
// generate secure encryption key using key derivation function (pbkdf2)
secretPbkdf2 := secure.NewPbkdf2([]byte(secret), 16)
crypto, err := secure.NewAesGCM(secretPbkdf2)
if err != nil {
logger.Fatal("error-creating-route-service-crypto", err)
}
return crypto
}
示例15: wireNetworker
func wireNetworker(
log lager.Logger,
tag string,
networkPoolCIDR *net.IPNet,
externalIP net.IP,
iptablesMgr kawasaki.IPTablesConfigurer,
interfacePrefix string,
chainPrefix string,
propManager *properties.Manager,
networkModulePath string) gardener.Networker {
runner := &logging.Runner{CommandRunner: linux_command_runner.New(), Logger: log.Session("network-runner")}
hostConfigurer := &configure.Host{
Veth: &devices.VethCreator{},
Link: &devices.Link{Name: "guardian"},
Bridge: &devices.Bridge{},
Logger: log.Session("network-host-configurer"),
}
containerCfgApplier := &configure.Container{
Logger: log.Session("network-container-configurer"),
Link: &devices.Link{Name: "guardian"},
}
idGenerator := kawasaki.NewSequentialIDGenerator(time.Now().UnixNano())
portPool, err := ports.NewPool(uint32(*portPoolStart), uint32(*portPoolSize), ports.State{})
if err != nil {
log.Fatal("invalid pool range", err)
}
switch networkModulePath {
case "":
return kawasaki.New(
kawasaki.NewManager(runner, "/var/run/netns"),
kawasaki.SpecParserFunc(kawasaki.ParseSpec),
subnets.NewPool(networkPoolCIDR),
kawasaki.NewConfigCreator(idGenerator, interfacePrefix, chainPrefix, externalIP),
kawasaki.NewConfigurer(
hostConfigurer,
containerCfgApplier,
iptablesMgr,
&netns.Execer{},
),
propManager,
iptables.NewPortForwarder(runner),
portPool,
)
default:
if _, err := os.Stat(networkModulePath); err != nil {
log.Fatal("failed-to-stat-network-module", err)
return nil
}
return gardener.ForeignNetworkAdaptor{
ForeignNetworker: genclient.New(networkModulePath),
}
}
}