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


Golang logrus.FieldLogger类代码示例

本文整理汇总了Golang中github.com/Sirupsen/logrus.FieldLogger的典型用法代码示例。如果您正苦于以下问题:Golang FieldLogger类的具体用法?Golang FieldLogger怎么用?Golang FieldLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Debug

func (logger *Logger) Debug(message interface{}, fields ...Fields) {
	var log logrus.FieldLogger = logger.Logger
	if len(fields) > 0 {
		log = log.WithFields(logrus.Fields(fields[0]))
	}

	log.Debug(message)
}
开发者ID:crob1140,项目名称:CodeWiz,代码行数:8,代码来源:log.go

示例2: 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

示例3: openDB

func openDB(dbType string, dbArgs string, logger logrus.FieldLogger) *sqlx.DB {
	logger.Infof("db: opening database %s:%s", dbType, dbArgs)
	// Error only returns from this if it is an unknown driver.
	d, err := sqlx.Connect(dbType, dbArgs)
	if err != nil {
		panic(fmt.Sprintf("Error connecting to %s database %s: %v", dbType, dbArgs, err))
	}
	// Actually test that we have a working connection
	err = d.Ping()
	if err != nil {
		panic(fmt.Sprintf("db: error connecting to database: %v", err))
	}
	return d
}
开发者ID:hobeone,项目名称:rss2go,代码行数:14,代码来源:db.go


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