本文整理匯總了Golang中github.com/jrperritt/rack/internal/github.com/Sirupsen/logrus.Logger.Infoln方法的典型用法代碼示例。如果您正苦於以下問題:Golang Logger.Infoln方法的具體用法?Golang Logger.Infoln怎麽用?Golang Logger.Infoln使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/jrperritt/rack/internal/github.com/Sirupsen/logrus.Logger
的用法示例。
在下文中一共展示了Logger.Infoln方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewClient
// NewClient creates and returns a Rackspace client for the given service.
func NewClient(c *cli.Context, serviceType string, logger *logrus.Logger, noCache bool, useServiceNet bool) (*gophercloud.ServiceClient, error) {
// get the user's authentication credentials
credsResult, err := Credentials(c, logger)
if err != nil {
return nil, err
}
logMsg := "Using public endpoint"
urlType := gophercloud.AvailabilityPublic
if useServiceNet {
logMsg = "Using service net endpoint"
urlType = gophercloud.AvailabilityInternal
}
logger.Infoln(logMsg)
if noCache {
return authFromScratch(credsResult, serviceType, urlType, logger)
}
ao := credsResult.AuthOpts
region := credsResult.Region
// form the cache key
cacheKey := CacheKey(*ao, region, serviceType, urlType)
// initialize cache
cache := &Cache{}
logger.Infof("Looking in the cache for cache key: %s\n", cacheKey)
// get the value from the cache
creds, err := cache.Value(cacheKey)
// if there was an error accessing the cache or there was nothing in the cache,
// authenticate from scratch
if err == nil && creds != nil {
// we successfully retrieved a value from the cache
logger.Infof("Using token from cache: %s\n", creds.TokenID)
pc, err := rackspace.NewClient(ao.IdentityEndpoint)
if err == nil {
pc.TokenID = creds.TokenID
pc.ReauthFunc = reauthFunc(pc, *ao)
pc.UserAgent.Prepend(util.UserAgent)
pc.HTTPClient = newHTTPClient()
return &gophercloud.ServiceClient{
ProviderClient: pc,
Endpoint: creds.ServiceEndpoint,
}, nil
}
} else {
return authFromScratch(credsResult, serviceType, urlType, logger)
}
return nil, nil
}