本文整理汇总了Golang中code/cloudfoundry/org/lager.Logger.Info方法的典型用法代码示例。如果您正苦于以下问题:Golang Logger.Info方法的具体用法?Golang Logger.Info怎么用?Golang Logger.Info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类code/cloudfoundry/org/lager.Logger
的用法示例。
在下文中一共展示了Logger.Info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: newUaaClient
func newUaaClient(logger lager.Logger, clock clock.Clock, c *config.Config) uaa_client.Client {
if c.RoutingApi.AuthDisabled {
logger.Info("using-noop-token-fetcher")
return uaa_client.NewNoOpUaaClient()
}
if c.OAuth.Port == -1 {
logger.Fatal("tls-not-enabled", errors.New("GoRouter requires TLS enabled to get OAuth token"), lager.Data{"token-endpoint": c.OAuth.TokenEndpoint, "port": c.OAuth.Port})
}
tokenURL := fmt.Sprintf("https://%s:%d", c.OAuth.TokenEndpoint, c.OAuth.Port)
cfg := &uaa_config.Config{
UaaEndpoint: tokenURL,
SkipVerification: c.OAuth.SkipSSLValidation,
ClientName: c.OAuth.ClientName,
ClientSecret: c.OAuth.ClientSecret,
CACerts: c.OAuth.CACerts,
MaxNumberOfRetries: c.TokenFetcherMaxRetries,
RetryInterval: c.TokenFetcherRetryInterval,
ExpirationBufferInSec: c.TokenFetcherExpirationBufferTimeInSeconds,
}
uaaClient, err := uaa_client.NewClient(logger, cfg, clock)
if err != nil {
logger.Fatal("initialize-token-fetcher-error", err)
}
return uaaClient
}
示例2: RemoveDesiredLRP
// RemoveDesiredLRP deletes the DesiredLRPSchedulingInfo and the DesiredLRPRunInfo
// from the database. We delete DesiredLRPSchedulingInfo first because the system
// uses it to determine wheter the lrp is present. In the event that only the
// RunInfo fails to delete, the orphaned DesiredLRPRunInfo will be garbage
// collected later by convergence.
func (db *ETCDDB) RemoveDesiredLRP(logger lager.Logger, processGuid string) error {
logger = logger.WithData(lager.Data{"process_guid": processGuid})
logger.Info("starting")
defer logger.Info("complete")
_, schedulingInfoErr := db.client.Delete(DesiredLRPSchedulingInfoSchemaPath(processGuid), true)
schedulingInfoErr = ErrorFromEtcdError(logger, schedulingInfoErr)
if schedulingInfoErr != nil && schedulingInfoErr != models.ErrResourceNotFound {
logger.Error("failed-deleting-scheduling-info", schedulingInfoErr)
return schedulingInfoErr
}
_, runInfoErr := db.client.Delete(DesiredLRPRunInfoSchemaPath(processGuid), true)
runInfoErr = ErrorFromEtcdError(logger, runInfoErr)
if runInfoErr != nil && runInfoErr != models.ErrResourceNotFound {
logger.Error("failed-deleting-run-info", runInfoErr)
return runInfoErr
}
if schedulingInfoErr == models.ErrResourceNotFound && runInfoErr == models.ErrResourceNotFound {
// If neither component of the desired LRP exists, don't bother trying to delete running instances
return models.ErrResourceNotFound
}
return nil
}
示例3: CellEvents
func (db *serviceClient) CellEvents(logger lager.Logger) <-chan models.CellEvent {
logger = logger.Session("cell-events")
disappearanceWatcher, disappeared := locket.NewDisappearanceWatcher(logger, db.consulClient, CellSchemaRoot(), db.clock)
process := ifrit.Invoke(disappearanceWatcher)
events := make(chan models.CellEvent)
go func() {
for {
select {
case keys, ok := <-disappeared:
if !ok {
process.Signal(os.Interrupt)
return
}
cellIDs := make([]string, len(keys))
for i, key := range keys {
cellIDs[i] = path.Base(key)
}
logger.Info("cell-disappeared", lager.Data{"cell_ids": cellIDs})
events <- models.NewCellDisappearedEvent(cellIDs)
}
}
}()
return events
}
示例4: Discover
func (r *driverSyncer) Discover(logger lager.Logger) (map[string]voldriver.Driver, error) {
logger = logger.Session("discover")
logger.Debug("start")
logger.Info(fmt.Sprintf("Discovering drivers in %s", r.driverPaths))
defer logger.Debug("end")
endpoints := make(map[string]voldriver.Driver)
for _, driverPath := range r.driverPaths {
//precedence order: sock -> spec -> json
spec_types := [3]string{"sock", "spec", "json"}
for _, spec_type := range spec_types {
matchingDriverSpecs, err := r.getMatchingDriverSpecs(logger, driverPath, spec_type)
if err != nil {
// untestable on linux, does glob work differently on windows???
return map[string]voldriver.Driver{}, fmt.Errorf("Volman configured with an invalid driver path '%s', error occured list files (%s)", driverPath, err.Error())
}
if len(matchingDriverSpecs) > 0 {
logger.Debug("driver-specs", lager.Data{"drivers": matchingDriverSpecs})
endpoints = r.insertIfAliveAndNotFound(logger, endpoints, driverPath, matchingDriverSpecs)
}
}
}
return endpoints, nil
}
示例5: Prepare
func (r *execPreparer) Prepare(log lager.Logger, bundlePath string, spec garden.ProcessSpec) (*PreparedSpec, error) {
log = log.Session("prepare")
log.Info("start")
defer log.Info("finished")
bndl, err := r.bundleLoader.Load(bundlePath)
if err != nil {
log.Error("load-bundle-failed", err)
return nil, err
}
pidBytes, err := ioutil.ReadFile(filepath.Join(bundlePath, "pidfile"))
if err != nil {
log.Error("read-pidfile-failed", err)
return nil, err
}
pid := string(pidBytes)
rootFsPath := filepath.Join("/proc", pid, "root")
u, err := r.lookupUser(bndl, rootFsPath, spec.User)
if err != nil {
log.Error("lookup-user-failed", err)
return nil, err
}
cwd := u.home
if spec.Dir != "" {
cwd = spec.Dir
}
if err := r.ensureDirExists(rootFsPath, cwd, u.hostUid, u.hostGid); err != nil {
log.Error("ensure-dir-failed", err)
return nil, err
}
caps := bndl.Capabilities()
if u.containerUid != 0 {
caps = intersect(caps, r.nonRootMaxCaps)
}
return &PreparedSpec{
HostUID: u.hostUid,
HostGID: u.hostGid,
Process: specs.Process{
Args: append([]string{spec.Path}, spec.Args...),
Env: envFor(u.containerUid, bndl, spec),
User: specs.User{
UID: uint32(u.containerUid),
GID: uint32(u.containerGid),
AdditionalGids: []uint32{},
},
Cwd: cwd,
Capabilities: caps,
Rlimits: toRlimits(spec.Limits),
Terminal: spec.TTY != nil,
ApparmorProfile: bndl.Process().ApparmorProfile,
},
}, nil
}
示例6: Create
func (c *Creator) Create(log lager.Logger, bundlePath, id string, _ garden.ProcessIO) (theErr error) {
log = log.Session("create", lager.Data{"bundle": bundlePath})
defer log.Info("finished")
logFilePath := filepath.Join(bundlePath, "create.log")
pidFilePath := filepath.Join(bundlePath, "pidfile")
cmd := exec.Command(c.runcPath, "--debug", "--log", logFilePath, "create", "--no-new-keyring", "--bundle", bundlePath, "--pid-file", pidFilePath, id)
log.Info("creating", lager.Data{
"runc": c.runcPath,
"bundlePath": bundlePath,
"id": id,
"logPath": logFilePath,
"pidFilePath": pidFilePath,
})
err := c.commandRunner.Run(cmd)
defer func() {
theErr = processLogs(log, logFilePath, err)
}()
return
}
示例7: connectToNatsServer
func connectToNatsServer(logger lager.Logger, c *config.Config, startMsg chan<- struct{}) *nats.Conn {
var natsClient *nats.Conn
var natsHost atomic.Value
var err error
options := natsOptions(logger, c, &natsHost, startMsg)
attempts := 3
for attempts > 0 {
natsClient, err = options.Connect()
if err == nil {
break
} else {
attempts--
time.Sleep(100 * time.Millisecond)
}
}
if err != nil {
logger.Fatal("nats-connection-error", err)
}
var natsHostStr string
natsUrl, err := url.Parse(natsClient.ConnectedUrl())
if err == nil {
natsHostStr = natsUrl.Host
}
logger.Info("Successfully-connected-to-nats", lager.Data{"host": natsHostStr})
natsHost.Store(natsHostStr)
return natsClient
}
示例8: Up
func (e *IncreaseRunInfoColumnSize) Up(logger lager.Logger) error {
logger = logger.Session("increase-run-info-column")
logger.Info("starting")
defer logger.Info("completed")
return alterTables(logger, e.rawSQLDB, e.dbFlavor)
}
示例9: HandleCompletedTask
func HandleCompletedTask(logger lager.Logger, httpClient *http.Client, taskDB db.TaskDB, task *models.Task) {
logger = logger.Session("handle-completed-task", lager.Data{"task_guid": task.TaskGuid})
if task.CompletionCallbackUrl != "" {
modelErr := taskDB.ResolvingTask(logger, task.TaskGuid)
if modelErr != nil {
logger.Error("marking-task-as-resolving-failed", modelErr)
return
}
logger = logger.WithData(lager.Data{"callback_url": task.CompletionCallbackUrl})
json, err := json.Marshal(&models.TaskCallbackResponse{
TaskGuid: task.TaskGuid,
Failed: task.Failed,
FailureReason: task.FailureReason,
Result: task.Result,
Annotation: task.Annotation,
CreatedAt: task.CreatedAt,
})
if err != nil {
logger.Error("marshalling-task-failed", err)
return
}
var statusCode int
for i := 0; i < MAX_CB_RETRIES; i++ {
request, err := http.NewRequest("POST", task.CompletionCallbackUrl, bytes.NewReader(json))
if err != nil {
logger.Error("building-request-failed", err)
return
}
request.Header.Set("Content-Type", "application/json")
response, err := httpClient.Do(request)
if err != nil {
matched, _ := regexp.MatchString("Client.Timeout|use of closed network connection", err.Error())
if matched {
continue
}
logger.Error("doing-request-failed", err)
return
}
defer response.Body.Close()
statusCode = response.StatusCode
if shouldResolve(statusCode) {
modelErr := taskDB.DeleteTask(logger, task.TaskGuid)
if modelErr != nil {
logger.Error("delete-task-failed", modelErr)
}
return
}
}
logger.Info("callback-failed", lager.Data{"status_code": statusCode})
}
return
}
示例10: CompleteTask
func (db *SQLDB) CompleteTask(logger lager.Logger, taskGuid, cellID string, failed bool, failureReason, taskResult string) (*models.Task, error) {
logger = logger.Session("complete-task", lager.Data{"task_guid": taskGuid, "cell_id": cellID})
logger.Info("starting")
defer logger.Info("complete")
var task *models.Task
err := db.transact(logger, func(logger lager.Logger, tx *sql.Tx) error {
var err error
task, err = db.fetchTaskForUpdate(logger, taskGuid, tx)
if err != nil {
logger.Error("failed-locking-task", err)
return err
}
if task.CellId != cellID && task.State == models.Task_Running {
logger.Error("failed-task-already-running-on-different-cell", err)
return models.NewRunningOnDifferentCellError(cellID, task.CellId)
}
if err = task.ValidateTransitionTo(models.Task_Completed); err != nil {
logger.Error("failed-to-transition-task-to-completed", err)
return err
}
return db.completeTask(logger, task, failed, failureReason, taskResult, tx)
})
return task, err
}
示例11: Unmount
func (r *remoteClient) Unmount(logger lager.Logger, driverId string, volumeId string) error {
logger = logger.Session("mount")
logger.Info("start")
defer logger.Info("end")
unmountRequest := volman.UnmountRequest{driverId, volumeId}
payload, err := json.Marshal(unmountRequest)
if err != nil {
return r.clientError(logger, err, fmt.Sprintf("Error marshalling JSON request %#v", unmountRequest))
}
request, err := r.reqGen.CreateRequest(volman.UnmountRoute, nil, bytes.NewReader(payload))
if err != nil {
return r.clientError(logger, err, fmt.Sprintf("Error creating request to %s", volman.UnmountRoute))
}
response, err := r.HttpClient.Do(request)
if err != nil {
return r.clientError(logger, err, fmt.Sprintf("Error unmounting volume %s", volumeId))
}
if response.StatusCode == 500 {
var remoteError volman.Error
if err := unmarshallJSON(logger, response.Body, &remoteError); err != nil {
return r.clientError(logger, err, fmt.Sprintf("Error parsing 500 response from %s", volman.UnmountRoute))
}
return remoteError
}
return nil
}
示例12: DesireTask
func (db *SQLDB) DesireTask(logger lager.Logger, taskDef *models.TaskDefinition, taskGuid, domain string) error {
logger = logger.Session("desire-task", lager.Data{"task_guid": taskGuid})
logger.Info("starting")
defer logger.Info("complete")
taskDefData, err := db.serializeModel(logger, taskDef)
if err != nil {
logger.Error("failed-serializing-task-definition", err)
return err
}
return db.transact(logger, func(logger lager.Logger, tx *sql.Tx) error {
now := db.clock.Now().UnixNano()
_, err = db.insert(logger, tx, tasksTable,
SQLAttributes{
"guid": taskGuid,
"domain": domain,
"created_at": now,
"updated_at": now,
"first_completed_at": 0,
"state": models.Task_Pending,
"task_definition": taskDefData,
},
)
if err != nil {
logger.Error("failed-inserting-task", err)
return db.convertSQLError(err)
}
return nil
})
}
示例13: ConvergeLRPs
func (db *ETCDDB) ConvergeLRPs(logger lager.Logger, cellSet models.CellSet) ([]*auctioneer.LRPStartRequest, []*models.ActualLRPKeyWithSchedulingInfo, []*models.ActualLRPKey) {
convergeStart := db.clock.Now()
convergeLRPRunsCounter.Increment()
logger = logger.Session("etcd")
logger.Info("starting-convergence")
defer logger.Info("finished-convergence")
defer func() {
err := convergeLRPDuration.Send(time.Since(convergeStart))
if err != nil {
logger.Error("failed-sending-converge-lrp-duration-metric", err)
}
}()
logger.Debug("gathering-convergence-input")
input, err := db.GatherAndPruneLRPs(logger, cellSet)
if err != nil {
logger.Error("failed-gathering-convergence-input", err)
return nil, nil, nil
}
logger.Debug("succeeded-gathering-convergence-input")
changes := CalculateConvergence(logger, db.clock, models.NewDefaultRestartCalculator(), input)
return db.ResolveConvergence(logger, input.DesiredLRPs, changes)
}
示例14: batchDeleteNodes
func (db *ETCDDB) batchDeleteNodes(keys []string, logger lager.Logger) {
if len(keys) == 0 {
return
}
works := []func(){}
for _, key := range keys {
key := key
works = append(works, func() {
logger.Info("deleting", lager.Data{"key": key})
_, err := db.client.Delete(key, true)
if err != nil {
logger.Error("failed-to-delete", err, lager.Data{
"key": key,
})
}
})
}
throttler, err := workpool.NewThrottler(db.convergenceWorkersSize, works)
if err != nil {
logger.Error("failed-to-create-throttler", err)
}
throttler.Work()
return
}
示例15: DeleteTask
func (db *SQLDB) DeleteTask(logger lager.Logger, taskGuid string) error {
logger = logger.Session("delete-task", lager.Data{"task_guid": taskGuid})
logger.Info("starting")
defer logger.Info("complete")
return db.transact(logger, func(logger lager.Logger, tx *sql.Tx) error {
task, err := db.fetchTaskForUpdate(logger, taskGuid, tx)
if err != nil {
logger.Error("failed-locking-task", err)
return err
}
if task.State != models.Task_Resolving {
err = models.NewTaskTransitionError(task.State, models.Task_Resolving)
logger.Error("invalid-state-transition", err)
return err
}
_, err = db.delete(logger, tx, tasksTable, "guid = ?", taskGuid)
if err != nil {
logger.Error("failed-deleting-task", err)
return db.convertSQLError(err)
}
return nil
})
}