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


Golang FieldLogger.Errorf方法代碼示例

本文整理匯總了Golang中github.com/Sirupsen/logrus.FieldLogger.Errorf方法的典型用法代碼示例。如果您正苦於以下問題:Golang FieldLogger.Errorf方法的具體用法?Golang FieldLogger.Errorf怎麽用?Golang FieldLogger.Errorf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/Sirupsen/logrus.FieldLogger的用法示例。


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

示例1: open

// open returns a client with no garbage collection.
func (c *Config) open(logger logrus.FieldLogger) (*client, error) {
	if c.InCluster && (c.KubeConfigFile != "") {
		return nil, errors.New("cannot specify both 'inCluster' and 'kubeConfigFile'")
	}
	if !c.InCluster && (c.KubeConfigFile == "") {
		return nil, errors.New("must specify either 'inCluster' or 'kubeConfigFile'")
	}

	var (
		cluster   k8sapi.Cluster
		user      k8sapi.AuthInfo
		namespace string
		err       error
	)
	if c.InCluster {
		cluster, user, namespace, err = inClusterConfig()
	} else {
		cluster, user, namespace, err = loadKubeConfig(c.KubeConfigFile)
	}
	if err != nil {
		return nil, err
	}

	cli, err := newClient(cluster, user, namespace, logger)
	if err != nil {
		return nil, fmt.Errorf("create client: %v", err)
	}

	ctx, cancel := context.WithCancel(context.Background())

	// Try to synchronously create the third party resources once. This doesn't mean
	// they'll immediately be available, but ensures that the client will actually try
	// once.
	if err := cli.createThirdPartyResources(); err != nil {
		logger.Errorf("failed creating third party resources: %v", err)
		go func() {
			for {
				if err := cli.createThirdPartyResources(); err != nil {
					logger.Errorf("failed creating third party resources: %v", err)
				} else {
					return
				}

				select {
				case <-ctx.Done():
					return
				case <-time.After(30 * time.Second):
				}
			}
		}()
	}

	// If the client is closed, stop trying to create third party resources.
	cli.cancel = cancel
	return cli, nil
}
開發者ID:jwmaag,項目名稱:dex,代碼行數:57,代碼來源:storage.go


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