当前位置: 首页>>代码示例>>Golang>>正文


Golang Logger.Info方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry/hm9000/helpers/logger.Logger.Info方法的典型用法代码示例。如果您正苦于以下问题:Golang Logger.Info方法的具体用法?Golang Logger.Info怎么用?Golang Logger.Info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry/hm9000/helpers/logger.Logger的用法示例。


在下文中一共展示了Logger.Info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: ServeMetrics

func ServeMetrics(steno *gosteno.Logger, l logger.Logger, conf *config.Config) {
	store := connectToStore(l, conf)
	messageBus := connectToMessageBus(l, conf)

	acquireLock(l, conf, "metrics-server")

	collectorRegistrar := collectorregistrar.NewCollectorRegistrar(messageBus, steno)

	metricsServer := metricsserver.New(
		collectorRegistrar,
		steno,
		metricsaccountant.New(store),
		l,
		store,
		buildTimeProvider(l),
		conf,
	)

	err := metricsServer.Start()
	if err != nil {
		l.Error("Failed to serve metrics", err)
	}
	l.Info("Serving Metrics")
	select {}
}
开发者ID:cgrotz,项目名称:hm9000,代码行数:25,代码来源:serve_metrics.go

示例2: Analyze

func Analyze(l logger.Logger, conf *config.Config, poll bool) {
	store := connectToStore(l, conf)

	if poll {
		l.Info("Starting Analyze Daemon...")

		adapter := connectToStoreAdapter(l, conf, nil)
		err := Daemonize("Analyzer", func() error {
			return analyze(l, conf, store)
		}, conf.AnalyzerPollingInterval(), conf.AnalyzerTimeout(), l, adapter)

		if err != nil {
			l.Error("Analyze Daemon Errored", err)
		}
		l.Info("Analyze Daemon is Down")
		os.Exit(1)
	} else {
		err := analyze(l, conf, store)
		if err != nil {
			os.Exit(1)
		} else {
			os.Exit(0)
		}
	}
}
开发者ID:cgrotz,项目名称:hm9000,代码行数:25,代码来源:analyze.go

示例3: connectToMessageBus

func connectToMessageBus(l logger.Logger, conf *config.Config) yagnats.NATSConn {
	members := make([]string, len(conf.NATS))

	for _, natsConf := range conf.NATS {
		uri := url.URL{
			Scheme: "nats",
			User:   url.UserPassword(natsConf.User, natsConf.Password),
			Host:   fmt.Sprintf("%s:%d", natsConf.Host, natsConf.Port),
		}
		members = append(members, uri.String())
	}

	natsClient, err := yagnats.Connect(members)
	if err != nil {
		l.Error("Failed to connect to the message bus", err)
		os.Exit(1)
	}

	natsClient.AddReconnectedCB(func(conn *nats.Conn) {
		l.Info(fmt.Sprintf("NATS Client Reconnected. Server URL: %s", conn.Opts.Url))
	})

	natsClient.AddClosedCB(func(conn *nats.Conn) {
		err := errors.New(fmt.Sprintf("NATS Client Closed. nats.Conn: %+v", conn))
		l.Error("NATS Closed", err)
		os.Exit(1)
	})

	return natsClient
}
开发者ID:nagyistge,项目名称:hm9000,代码行数:30,代码来源:common.go

示例4: FetchDesiredState

func FetchDesiredState(l logger.Logger, conf *config.Config, poll bool) {
	store, _ := connectToStore(l, conf)

	if poll {
		l.Info("Starting Desired State Daemon...")

		adapter, _ := connectToStoreAdapter(l, conf)

		err := Daemonize("Fetcher", func() error {
			return fetchDesiredState(l, conf, store)
		}, conf.FetcherPollingInterval(), conf.FetcherTimeout(), l, adapter)
		if err != nil {
			l.Error("Desired State Daemon Errored", err)
		}
		l.Info("Desired State Daemon is Down")
		os.Exit(1)
	} else {
		err := fetchDesiredState(l, conf, store)
		if err != nil {
			os.Exit(1)
		} else {
			os.Exit(0)
		}
	}
}
开发者ID:nkts,项目名称:golang-devops-stuff,代码行数:25,代码来源:fetch_desired_state.go

示例5: Send

func Send(l logger.Logger, conf *config.Config, poll bool) {
	messageBus := connectToMessageBus(l, conf)
	store, _ := connectToStore(l, conf)

	if poll {
		l.Info("Starting Sender Daemon...")

		adapter, _ := connectToStoreAdapter(l, conf)

		err := Daemonize("Sender", func() error {
			return send(l, conf, messageBus, store)
		}, conf.SenderPollingInterval(), conf.SenderTimeout(), l, adapter)
		if err != nil {
			l.Error("Sender Daemon Errored", err)
		}
		l.Info("Sender Daemon is Down")
		os.Exit(1)
	} else {
		err := send(l, conf, messageBus, store)
		if err != nil {
			os.Exit(1)
		} else {
			os.Exit(0)
		}
	}
}
开发者ID:nkts,项目名称:golang-devops-stuff,代码行数:26,代码来源:send.go

示例6: acquireLock

func acquireLock(l logger.Logger, conf *config.Config, lockName string) {
	adapter, _ := connectToStoreAdapter(l, conf)
	l.Info("Acquiring lock for " + lockName)

	lock := storeadapter.StoreNode{
		Key: "/hm/locks/" + lockName,
		TTL: 10,
	}

	status, _, err := adapter.MaintainNode(lock)
	if err != nil {
		l.Error("Failed to talk to lock store", err)
		os.Exit(1)
	}

	lockAcquired := make(chan bool)

	go func() {
		for {
			if <-status {
				if lockAcquired != nil {
					close(lockAcquired)
					lockAcquired = nil
				}
			} else {
				l.Error("Lost the lock", errors.New("Lost the lock"))
				os.Exit(197)
			}
		}
	}()

	<-lockAcquired
	l.Info("Acquired lock for " + lockName)
}
开发者ID:tomzhang,项目名称:golang-devops-stuff,代码行数:34,代码来源:common.go

示例7: Daemonize

func Daemonize(
	component string,
	callback func() error,
	period time.Duration,
	timeout time.Duration,
	logger logger.Logger,
	adapter storeadapter.StoreAdapter,
) error {
	logger.Info("Acquiring lock for " + component)

	lostLockChannel, releaseLockChannel, err := adapter.GetAndMaintainLock(component, 10)
	if err != nil {
		logger.Info(fmt.Sprintf("Failed to acquire lock: %s", err))
		return err
	}

	go func() {
		<-lostLockChannel
		logger.Error("Lost the lock", errors.New("Lock the lock"))
		os.Exit(197)
	}()

	logger.Info("Acquired lock for " + component)

	logger.Info(fmt.Sprintf("Running Daemon every %d seconds with a timeout of %d", int(period.Seconds()), int(timeout.Seconds())))

	for {
		afterChan := time.After(period)
		timeoutChan := time.After(timeout)
		errorChan := make(chan error, 1)

		t := time.Now()

		go func() {
			errorChan <- callback()
		}()

		select {
		case err := <-errorChan:
			logger.Info("Daemonize Time", map[string]string{
				"Component": component,
				"Duration":  fmt.Sprintf("%.4f", time.Since(t).Seconds()),
			})
			if err != nil {
				logger.Error("Daemon returned an error. Continuining...", err)
			}
		case <-timeoutChan:
			releaseLockChannel <- true
			return errors.New("Daemon timed out. Aborting!")
		}

		<-afterChan
	}

	return nil
}
开发者ID:johntdyer,项目名称:golang-devops-stuff,代码行数:56,代码来源:daemon.go

示例8: StartEvacuator

func StartEvacuator(l logger.Logger, conf *config.Config) {
	messageBus := connectToMessageBus(l, conf)
	store, _ := connectToStore(l, conf)

	acquireLock(l, conf, "evacuator")

	evacuator := evacuatorpackage.New(messageBus, store, buildTimeProvider(l), conf, l)

	evacuator.Listen()
	l.Info("Listening for DEA Evacuations")
	select {}
}
开发者ID:KeyOfSpectator,项目名称:hm9000,代码行数:12,代码来源:start_evacuator.go

示例9: send

func send(l logger.Logger, conf *config.Config, messageBus yagnats.NATSClient, store store.Store) error {
	l.Info("Sending...")

	sender := sender.New(store, metricsaccountant.New(store), conf, messageBus, buildTimeProvider(l), l)
	err := sender.Send()

	if err != nil {
		l.Error("Sender failed with error", err)
		return err
	} else {
		l.Info("Sender completed succesfully")
		return nil
	}
}
开发者ID:nkts,项目名称:golang-devops-stuff,代码行数:14,代码来源:send.go

示例10: analyze

func analyze(l logger.Logger, conf *config.Config, store store.Store) error {
	l.Info("Analyzing...")

	analyzer := analyzer.New(store, buildTimeProvider(l), l, conf)
	err := analyzer.Analyze()

	if err != nil {
		l.Error("Analyzer failed with error", err)
		return err
	} else {
		l.Info("Analyzer completed succesfully")
		return nil
	}
}
开发者ID:cgrotz,项目名称:hm9000,代码行数:14,代码来源:analyze.go

示例11: StartListeningForActual

func StartListeningForActual(l logger.Logger, c *cli.Context) {
	conf := loadConfig(l, c)
	messageBus := connectToMessageBus(l, conf)
	store := connectToStore(l, conf)

	listener := actualstatelistener.New(conf,
		messageBus,
		store,
		timeprovider.NewTimeProvider(),
		l)

	listener.Start()
	l.Info("Listening for Actual State", nil)
	select {}
}
开发者ID:Zhann,项目名称:hm9000,代码行数:15,代码来源:start_listening_for_actual.go

示例12: acquireLock

func acquireLock(l logger.Logger, conf *config.Config, lockName string) {
	adapter, _ := connectToStoreAdapter(l, conf)
	l.Info("Acquiring lock for " + lockName)
	lostLockChannel, _, err := adapter.GetAndMaintainLock(lockName, 10)
	if err != nil {
		l.Error("Failed to talk to lock store", err)
		os.Exit(1)
	}

	go func() {
		<-lostLockChannel
		l.Error("Lost the lock", errors.New("Lock the lock"))
		os.Exit(197)
	}()

	l.Info("Acquired lock for " + lockName)
}
开发者ID:karlpilkington,项目名称:golang-devops-stuff,代码行数:17,代码来源:common.go

示例13: StartListeningForActual

func StartListeningForActual(l logger.Logger, conf *config.Config) {
	messageBus := connectToMessageBus(l, conf)
	store, usageTracker := connectToStoreAndTrack(l, conf)

	acquireLock(l, conf, "listener")

	listener := actualstatelistener.New(conf,
		messageBus,
		store,
		usageTracker,
		metricsaccountant.New(store),
		buildClock(l),
		l,
	)

	listener.Start()
	l.Info("Listening for Actual State")
	select {}
}
开发者ID:nagyistge,项目名称:hm9000,代码行数:19,代码来源:start_listening_for_actual.go

示例14: ServeAPI

func ServeAPI(l logger.Logger, conf *config.Config) {
	store, _ := connectToStore(l, conf)
	messageBus := connectToMessageBus(l, conf)

	//no locking necessary for the api server.  it's ok to have multiples of these running.
	//NATS will distribute the requests and ensure that only one api-server handles a given request
	//because we use a NATS queue.

	apiServer := apiserver.New(
		messageBus,
		store,
		buildTimeProvider(l),
		l,
	)

	apiServer.Listen()
	l.Info(fmt.Sprintf("Serving API over NATS (subject: app.state)"))
	select {}
}
开发者ID:nkts,项目名称:golang-devops-stuff,代码行数:19,代码来源:serve_api.go

示例15: FetchDesiredState

func FetchDesiredState(l logger.Logger, c *cli.Context) {
	conf := loadConfig(l, c)
	messageBus := connectToMessageBus(l, conf)
	store := connectToStore(l, conf)

	fetcher := desiredstatefetcher.New(conf,
		messageBus,
		store,
		httpclient.NewHttpClient(),
		timeprovider.NewTimeProvider(),
	)

	resultChan := make(chan desiredstatefetcher.DesiredStateFetcherResult, 1)
	fetcher.Fetch(resultChan)

	select {
	case result := <-resultChan:
		if result.Success {
			l.Info("Success", map[string]string{"Number of Desired Apps Fetched": strconv.Itoa(result.NumResults)})
			os.Exit(0)
		} else {
			l.Info(result.Message, map[string]string{"Error": result.Error.Error(), "Message": result.Message})
			os.Exit(1)
		}
	case <-time.After(600 * time.Second):
		l.Info("Timed out when fetching desired state", nil)
		os.Exit(1)
	}
}
开发者ID:Zhann,项目名称:hm9000,代码行数:29,代码来源:fetch_desired_state.go


注:本文中的github.com/cloudfoundry/hm9000/helpers/logger.Logger.Info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。