當前位置: 首頁>>代碼示例>>Golang>>正文


Golang lager.Logger類代碼示例

本文整理匯總了Golang中github.com/pivotal-golang/lager.Logger的典型用法代碼示例。如果您正苦於以下問題:Golang Logger類的具體用法?Golang Logger怎麽用?Golang Logger使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Logger類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Emit

func (event HTTPReponseTime) Emit(logger lager.Logger) {
	state := "ok"

	if event.Duration > 100*time.Millisecond {
		state = "warning"
	}

	if event.Duration > 1*time.Second {
		state = "critical"
	}

	emit(
		logger.Session("http-response-time", lager.Data{
			"route":    event.Route,
			"path":     event.Path,
			"duration": event.Duration.String(),
		}),
		goryman.Event{
			Service: "http response time",
			Metric:  ms(event.Duration),
			State:   state,
			Attributes: map[string]string{
				"route": event.Route,
				"path":  event.Path,
			},
		},
	)
}
開發者ID:ACPK,項目名稱:atc,代碼行數:28,代碼來源:metrics.go

示例2: LookupBuild

func (engine *execEngine) LookupBuild(logger lager.Logger, model db.Build) (Build, error) {
	var metadata execMetadata
	err := json.Unmarshal([]byte(model.EngineMetadata), &metadata)
	if err != nil {
		logger.Error("invalid-metadata", err)
		return nil, err
	}

	err = atc.NewPlanTraversal(engine.convertPipelineNameToID).Traverse(&metadata.Plan)
	if err != nil {
		return nil, err
	}

	return &execBuild{
		buildID:      model.ID,
		stepMetadata: buildMetadata(model, engine.externalURL),

		db:       engine.db,
		factory:  engine.factory,
		delegate: engine.delegateFactory.Delegate(model.ID, model.PipelineID),
		metadata: metadata,

		signals: make(chan os.Signal, 1),
	}, nil
}
開發者ID:xoebus,項目名稱:checkin,代碼行數:25,代碼來源:exec_engine.go

示例3: configure

func configure(logger lager.Logger) (*ssh.ServerConfig, error) {
	errorStrings := []string{}
	sshConfig := &ssh.ServerConfig{}

	key, err := acquireHostKey(logger)
	if err != nil {
		logger.Error("failed-to-acquire-host-key", err)
		errorStrings = append(errorStrings, err.Error())
	}

	sshConfig.AddHostKey(key)
	sshConfig.NoClientAuth = *allowUnauthenticatedClients

	if *authorizedKey == "" && !*allowUnauthenticatedClients {
		logger.Error("authorized-key-required", nil)
		errorStrings = append(errorStrings, "Public user key is required")
	}

	if *authorizedKey != "" {
		decodedPublicKey, err := decodeAuthorizedKey(logger)
		if err == nil {
			authenticator := authenticators.NewPublicKeyAuthenticator(decodedPublicKey)
			sshConfig.PublicKeyCallback = authenticator.Authenticate
		} else {
			errorStrings = append(errorStrings, err.Error())
		}
	}

	err = nil
	if len(errorStrings) > 0 {
		err = errors.New(strings.Join(errorStrings, ", "))
	}

	return sshConfig, err
}
開發者ID:benjaminharnett,項目名稱:diego-ssh,代碼行數:35,代碼來源:main.go

示例4: batchDeleteTasks

func (db *ETCDDB) batchDeleteTasks(taskGuids []string, logger lager.Logger) {
	if len(taskGuids) == 0 {
		return
	}

	works := []func(){}

	for _, taskGuid := range taskGuids {
		taskGuid := taskGuid
		works = append(works, func() {
			_, err := db.client.Delete(taskGuid, true)
			if err != nil {
				logger.Error("failed-to-delete", err, lager.Data{
					"task-guid": taskGuid,
				})
			}
		})
	}

	throttler, err := workpool.NewThrottler(db.convergenceWorkersSize, works)
	if err != nil {
		logger.Error("failed-to-create-throttler", err)
	}

	throttler.Work()
	return
}
開發者ID:emc-xchallenge,項目名稱:bbs,代碼行數:27,代碼來源:task_convergence.go

示例5: countTasksByState

func (db *SQLDB) countTasksByState(logger lager.Logger, q Queryable) (pendingCount, runningCount, completedCount, resolvingCount int) {
	var query string
	switch db.flavor {
	case Postgres:
		query = `
			SELECT
				COUNT(*) FILTER (WHERE state = $1) AS pending_tasks,
				COUNT(*) FILTER (WHERE state = $2) AS running_tasks,
				COUNT(*) FILTER (WHERE state = $3) AS completed_tasks,
				COUNT(*) FILTER (WHERE state = $4) AS resolving_tasks
			FROM tasks
		`
	case MySQL:
		query = `
			SELECT
				COUNT(IF(state = ?, 1, NULL)) AS pending_tasks,
				COUNT(IF(state = ?, 1, NULL)) AS running_tasks,
				COUNT(IF(state = ?, 1, NULL)) AS completed_tasks,
				COUNT(IF(state = ?, 1, NULL)) AS resolving_tasks
			FROM tasks
		`
	default:
		// totally shouldn't happen
		panic("database flavor not implemented: " + db.flavor)
	}

	row := db.db.QueryRow(query, models.Task_Pending, models.Task_Running, models.Task_Completed, models.Task_Resolving)
	err := row.Scan(&pendingCount, &runningCount, &completedCount, &resolvingCount)
	if err != nil {
		logger.Error("failed-counting-tasks", err)
	}
	return
}
開發者ID:timani,項目名稱:bbs,代碼行數:33,代碼來源:queries.go

示例6: FailTask

func (tc *CCTaskClient) FailTask(logger lager.Logger, taskState *cc_messages.CCTaskState, httpClient *http.Client) error {
	taskGuid := taskState.TaskGuid
	payload, err := json.Marshal(cc_messages.TaskFailResponseForCC{
		TaskGuid:      taskGuid,
		Failed:        true,
		FailureReason: "Unable to determine completion status",
	})
	if err != nil {
		logger.Error("failed-to-marshal", err, lager.Data{"task_guid": taskGuid})
		return err
	}

	req, err := http.NewRequest("POST", taskState.CompletionCallbackUrl, bytes.NewReader(payload))
	if err != nil {
		return err
	}

	req.Header.Set("Content-Type", "application/json")
	resp, err := httpClient.Do(req)
	if err != nil {
		return err
	}
	defer resp.Body.Close()

	if resp.StatusCode != http.StatusOK {
		logger.Error("bad-response-from-cc", err, lager.Data{"task_guid": taskGuid})
		return errors.New("received bad response from CC ")
	}

	return nil
}
開發者ID:cfibmers,項目名稱:nsync,代碼行數:31,代碼來源:task_client.go

示例7: NewActualLRPHandler

func NewActualLRPHandler(bbs bbs.Client, legacyBBS Bbs.ReceptorBBS, logger lager.Logger) *ActualLRPHandler {
	return &ActualLRPHandler{
		bbs:       bbs,
		legacyBBS: legacyBBS,
		logger:    logger.Session("actual-lrp-handler"),
	}
}
開發者ID:rowhit,項目名稱:lattice,代碼行數:7,代碼來源:actual_lrp_handlers.go

示例8: New

func New(timeout time.Duration, skipSSLVerification bool, logger lager.Logger) Uploader {
	transport := &http.Transport{
		Proxy: http.ProxyFromEnvironment,
		Dial: (&net.Dialer{
			Timeout:   10 * time.Second,
			KeepAlive: 30 * time.Second,
		}).Dial,
		TLSHandshakeTimeout: 10 * time.Second,
		TLSClientConfig: &tls.Config{
			InsecureSkipVerify: skipSSLVerification,
			MinVersion:         tls.VersionTLS10,
		},
	}

	httpClient := &http.Client{
		Transport: transport,
		Timeout:   timeout,
	}

	return &URLUploader{
		httpClient: httpClient,
		transport:  transport,
		logger:     logger.Session("URLUploader"),
	}
}
開發者ID:snowsnail,項目名稱:executor,代碼行數:25,代碼來源:uploader.go

示例9: NewPoller

func NewPoller(logger lager.Logger, httpClient *http.Client, pollInterval time.Duration) Poller {
	return &poller{
		client:       httpClient,
		pollInterval: pollInterval,
		logger:       logger.Session("poller"),
	}
}
開發者ID:emc-xchallenge,項目名稱:cc-uploader,代碼行數:7,代碼來源:poller.go

示例10: 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()
}
開發者ID:snowsnail,項目名稱:executor,代碼行數:7,代碼來源:generator.go

示例11: 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,
	}
}
開發者ID:robdimsdale,項目名稱:garagepi,代碼行數:27,代碼來源:handler.go

示例12: resolveRestartableCrashedActualLRPS

func (db *ETCDDB) resolveRestartableCrashedActualLRPS(logger lager.Logger, actualLRP *models.ActualLRP, starts *startRequests) func() {
	return func() {
		actualKey := actualLRP.ActualLRPKey

		logger = logger.Session("restart-crash", lager.Data{
			"process_guid": actualKey.ProcessGuid,
			"index":        actualKey.Index,
		})

		if actualLRP.State != models.ActualLRPStateCrashed {
			logger.Error("failed-actual-lrp-state-is-not-crashed", nil)
			return
		}

		logger.Debug("unclaiming-actual-lrp", lager.Data{"process_guid": actualLRP.ActualLRPKey.ProcessGuid, "index": actualLRP.ActualLRPKey.Index})
		_, err := db.unclaimActualLRP(logger, &actualLRP.ActualLRPKey, &actualLRP.ActualLRPInstanceKey)
		if err != nil {
			logger.Error("failed-unclaiming-crash", err)
			return
		}
		logger.Debug("succeeded-unclaiming-actual-lrp")

		starts.Add(logger, &actualKey)
	}
}
開發者ID:timani,項目名稱:bbs,代碼行數:25,代碼來源:lrp_convergence.go

示例13: TryNextPendingBuild

func (s *Scheduler) TryNextPendingBuild(logger lager.Logger, job atc.JobConfig, resources atc.ResourceConfigs) Waiter {
	logger = logger.Session("try-next-pending")

	wg := new(sync.WaitGroup)

	wg.Add(1)
	go func() {
		defer wg.Done()

		build, err := s.PipelineDB.GetNextPendingBuild(job.Name)
		if err != nil {
			if err == db.ErrNoBuild {
				return
			}

			logger.Error("failed-to-get-next-pending-build", err)

			return
		}

		s.scheduleAndResumePendingBuild(logger, build, job, resources)
	}()

	return wg
}
開發者ID:utako,項目名稱:atc,代碼行數:25,代碼來源:scheduler.go

示例14: Cells

func (db *serviceClient) Cells(logger lager.Logger) (models.CellSet, error) {
	kvPairs, _, err := db.consulClient.KV().List(CellSchemaRoot(), nil)
	if err != nil {
		bbsErr := models.ConvertError(convertConsulError(err))
		if bbsErr.Type != models.Error_ResourceNotFound {
			return nil, bbsErr
		}
	}

	if kvPairs == nil {
		err = consuladapter.NewPrefixNotFoundError(CellSchemaRoot())
		bbsErr := models.ConvertError(convertConsulError(err))
		if bbsErr.Type != models.Error_ResourceNotFound {
			return nil, bbsErr
		}
	}

	cellPresences := models.NewCellSet()
	for _, kvPair := range kvPairs {
		if kvPair.Session == "" {
			continue
		}

		cell := kvPair.Value
		presence := new(models.CellPresence)
		err := models.FromJSON(cell, presence)
		if err != nil {
			logger.Error("failed-to-unmarshal-cells-json", err)
			continue
		}
		cellPresences.Add(presence)
	}

	return cellPresences, nil
}
開發者ID:timani,項目名稱:bbs,代碼行數:35,代碼來源:service_client.go

示例15: sync

func (b *Bulker) sync(logger lager.Logger) {
	logger = logger.Session("sync")

	logger.Info("starting")
	defer logger.Info("finished")

	startTime := b.clock.Now()

	ops, batchError := b.generator.BatchOperations(logger)

	endTime := b.clock.Now()

	sendError := repBulkSyncDuration.Send(endTime.Sub(startTime))
	if sendError != nil {
		logger.Error("failed-to-send-rep-bulk-sync-duration-metric", sendError)
	}

	if batchError != nil {
		logger.Error("failed-to-generate-operations", batchError)
		return
	}

	for _, operation := range ops {
		b.queue.Push(operation)
	}
}
開發者ID:jiangytcn,項目名稱:rep,代碼行數:26,代碼來源:bulker.go


注:本文中的github.com/pivotal-golang/lager.Logger類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。