本文整理汇总了Golang中code/cloudfoundry/org/lager.Logger.Debug方法的典型用法代码示例。如果您正苦于以下问题:Golang Logger.Debug方法的具体用法?Golang Logger.Debug怎么用?Golang Logger.Debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类code/cloudfoundry/org/lager.Logger
的用法示例。
在下文中一共展示了Logger.Debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: exec
func (p *externalBinaryNetworker) exec(log lager.Logger, action, handle string,
inputData interface{}, outputData interface{}) error {
stdinBytes, err := json.Marshal(inputData)
if err != nil {
return err
}
args := append(p.extraArg, "--action", action, "--handle", handle)
cmd := exec.Command(p.path, args...)
stdout := &bytes.Buffer{}
cmd.Stdout = stdout
stderr := &bytes.Buffer{}
cmd.Stderr = stderr
cmd.Stdin = bytes.NewReader(stdinBytes)
err = p.commandRunner.Run(cmd)
logData := lager.Data{"action": action, "stdin": string(stdinBytes), "stderr": stderr.String(), "stdout": stdout.String()}
if err != nil {
log.Error("external-networker-result", err, logData)
return fmt.Errorf("external networker %s: %s", action, err)
}
if outputData != nil {
err = json.Unmarshal(stdout.Bytes(), outputData)
if err != nil {
log.Error("external-networker-result", err, logData)
return fmt.Errorf("unmarshaling result from external networker: %s", err)
}
}
log.Debug("external-networker-result", logData)
return nil
}
示例2: Metrics
func (p *ExternalImageManager) Metrics(log lager.Logger, _, rootfs string) (garden.ContainerDiskStat, error) {
log = log.Session("image-plugin-metrics", lager.Data{"rootfs": rootfs})
log.Debug("start")
defer log.Debug("end")
imagePath := filepath.Dir(rootfs)
cmd := exec.Command(p.binPath, "stats", imagePath)
cmd.Stderr = lagregator.NewRelogger(log)
outBuffer := bytes.NewBuffer([]byte{})
cmd.Stdout = outBuffer
if err := p.commandRunner.Run(cmd); err != nil {
logData := lager.Data{"action": "stats", "stderr": outBuffer.String()}
log.Error("external-image-manager-result", err, logData)
return garden.ContainerDiskStat{}, fmt.Errorf("external image manager metrics failed: %s (%s)", outBuffer.String(), err)
}
var metrics map[string]map[string]uint64
if err := json.NewDecoder(outBuffer).Decode(&metrics); err != nil {
return garden.ContainerDiskStat{}, fmt.Errorf("parsing metrics: %s", err)
}
return garden.ContainerDiskStat{
TotalBytesUsed: metrics["disk_usage"]["total_bytes_used"],
ExclusiveBytesUsed: metrics["disk_usage"]["exclusive_bytes_used"],
}, nil
}
示例3: ActualLRPGroupsByProcessGuid
func (db *SQLDB) ActualLRPGroupsByProcessGuid(logger lager.Logger, processGuid string) ([]*models.ActualLRPGroup, error) {
logger = logger.WithData(lager.Data{"process_guid": processGuid})
logger.Debug("starting")
defer logger.Debug("complete")
return db.getActualLRPS(logger, "process_guid = ?", processGuid)
}
示例4: migrateDomains
func (e *ETCDToSQL) migrateDomains(logger lager.Logger) error {
logger = logger.Session("migrating-domains")
logger.Debug("starting")
defer logger.Debug("finished")
response, err := e.storeClient.Get(etcd.DomainSchemaRoot, false, true)
if err != nil {
logger.Error("failed-fetching-domains", err)
}
if response != nil {
for _, node := range response.Node.Nodes {
domain := path.Base(node.Key)
expireTime := e.clock.Now().UnixNano() + int64(time.Second)*node.TTL
_, err := e.rawSQLDB.Exec(sqldb.RebindForFlavor(`
INSERT INTO domains
(domain, expire_time)
VALUES (?, ?)
`, e.dbFlavor), domain, expireTime)
if err != nil {
logger.Error("failed-inserting-domain", err)
continue
}
}
}
return nil
}
示例5: StopAll
func (stopper *CgroupStopper) StopAll(log lager.Logger, cgroupName string, exceptions []int, kill bool) error {
log = log.Session("stop-all", lager.Data{
"name": cgroupName,
})
log.Debug("start")
defer log.Debug("finished")
devicesSubsystemPath, err := stopper.cgroupPathResolver.Resolve(cgroupName, "devices")
if err != nil {
return err
}
if !kill {
stopper.retrier.Run(func() error {
return stopper.killAllRemaining(syscall.SIGTERM, devicesSubsystemPath, exceptions)
})
}
stopper.retrier.Run(func() error {
return stopper.killAllRemaining(syscall.SIGKILL, devicesSubsystemPath, exceptions)
})
return nil // we killed, so everything must die
}
示例6: UnclaimActualLRP
func (db *ETCDDB) UnclaimActualLRP(logger lager.Logger, key *models.ActualLRPKey) (*models.ActualLRPGroup, *models.ActualLRPGroup, error) {
actualLRP, modifiedIndex, err := db.rawActualLRPByProcessGuidAndIndex(logger, key.ProcessGuid, key.Index)
bbsErr := models.ConvertError(err)
if bbsErr != nil {
return nil, nil, bbsErr
}
beforeActualLRP := *actualLRP
if actualLRP.State == models.ActualLRPStateUnclaimed {
logger.Debug("already-unclaimed")
return nil, nil, models.ErrActualLRPCannotBeUnclaimed
}
actualLRP.State = models.ActualLRPStateUnclaimed
actualLRP.ActualLRPKey = *key
actualLRP.ActualLRPInstanceKey = models.ActualLRPInstanceKey{}
actualLRP.ActualLRPNetInfo = models.EmptyActualLRPNetInfo()
actualLRP.Since = db.clock.Now().UnixNano()
actualLRP.ModificationTag.Increment()
data, err := db.serializeModel(logger, actualLRP)
if err != nil {
return nil, nil, err
}
_, err = db.client.CompareAndSwap(ActualLRPSchemaPath(key.ProcessGuid, key.Index), data, 0, modifiedIndex)
if err != nil {
logger.Error("failed-compare-and-swap", err)
return nil, nil, ErrorFromEtcdError(logger, err)
}
return &models.ActualLRPGroup{Instance: &beforeActualLRP}, &models.ActualLRPGroup{Instance: actualLRP}, nil
}
示例7: 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)
}
示例8: Unmount
func (client *localClient) Unmount(logger lager.Logger, driverId string, volumeName string) error {
logger = logger.Session("unmount")
logger.Info("start")
defer logger.Info("end")
logger.Debug("unmounting-volume", lager.Data{"volumeName": volumeName})
unmountStart := client.clock.Now()
defer func() {
sendUnmountDurationMetrics(logger, time.Since(unmountStart), driverId)
}()
driver, found := client.driverRegistry.Driver(driverId)
if !found {
err := errors.New("Driver '" + driverId + "' not found in list of known drivers")
logger.Error("mount-driver-lookup-error", err)
volmanUnmountErrorsCounter.Increment()
return err
}
env := driverhttp.NewHttpDriverEnv(logger, context.TODO())
if response := driver.Unmount(env, voldriver.UnmountRequest{Name: volumeName}); response.Err != "" {
err := errors.New(response.Err)
logger.Error("unmount-failed", err)
volmanUnmountErrorsCounter.Increment()
return err
}
return nil
}
示例9: DesireTask
func (db *ETCDDB) DesireTask(logger lager.Logger, taskDef *models.TaskDefinition, taskGuid, domain string) error {
logger = logger.WithData(lager.Data{"task_guid": taskGuid})
logger.Info("starting")
defer logger.Info("finished")
now := db.clock.Now().UnixNano()
task := &models.Task{
TaskDefinition: taskDef,
TaskGuid: taskGuid,
Domain: domain,
State: models.Task_Pending,
CreatedAt: now,
UpdatedAt: now,
}
value, err := db.serializeModel(logger, task)
if err != nil {
return err
}
logger.Debug("persisting-task")
_, err = db.client.Create(TaskSchemaPathByGuid(task.TaskGuid), value, NO_TTL)
if err != nil {
return ErrorFromEtcdError(logger, err)
}
logger.Debug("succeeded-persisting-task")
return nil
}
示例10: 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)
}
}
示例11: Create
func (p *ExternalImageManager) Create(log lager.Logger, handle string, spec rootfs_provider.Spec) (string, []string, error) {
log = log.Session("image-plugin-create")
log.Debug("start")
defer log.Debug("end")
args := []string{"create"}
if spec.QuotaSize != 0 {
if spec.QuotaScope == garden.DiskLimitScopeExclusive {
args = append(args, "--exclude-image-from-quota")
}
args = append(args, "--disk-limit-size-bytes", strconv.FormatInt(spec.QuotaSize, 10))
}
if spec.Namespaced {
for _, mapping := range p.mappings {
args = append(args, "--uid-mapping", stringifyMapping(mapping))
args = append(args, "--gid-mapping", stringifyMapping(mapping))
}
}
if spec.RootFS == nil || spec.RootFS.String() == "" {
args = append(args, p.defaultBaseImage.String())
} else {
args = append(args, strings.Replace(spec.RootFS.String(), "#", ":", 1))
}
args = append(args, handle)
cmd := exec.Command(p.binPath, args...)
cmd.Stderr = lagregator.NewRelogger(log)
outBuffer := bytes.NewBuffer([]byte{})
cmd.Stdout = outBuffer
if spec.Namespaced {
cmd.SysProcAttr = &syscall.SysProcAttr{
Credential: &syscall.Credential{
Uid: p.mappings[0].HostID,
Gid: p.mappings[0].HostID,
},
}
}
if err := p.commandRunner.Run(cmd); err != nil {
logData := lager.Data{"action": "create", "stdout": outBuffer.String()}
log.Error("external-image-manager-result", err, logData)
return "", nil, fmt.Errorf("external image manager create failed: %s (%s)", outBuffer.String(), err)
}
imagePath := strings.TrimSpace(outBuffer.String())
envVars, err := p.readEnvVars(imagePath)
if err != nil {
return "", nil, err
}
rootFSPath := filepath.Join(imagePath, "rootfs")
return rootFSPath, envVars, nil
}
示例12: fetchRaw
func (db *ETCDDB) fetchRaw(logger lager.Logger, key string) (*etcd.Node, error) {
logger.Debug("fetching-from-etcd")
response, err := db.client.Get(key, false, false)
if err != nil {
return nil, ErrorFromEtcdError(logger, err)
}
logger.Debug("succeeded-fetching-from-etcd")
return response.Node, nil
}
示例13: SetVcapRequestIdHeader
func SetVcapRequestIdHeader(request *http.Request, logger lager.Logger) {
guid, err := uuid.GenerateUUID()
if err == nil {
request.Header.Set(VcapRequestIdHeader, guid)
if logger != nil {
logger.Debug("vcap-request-id-header-set", lager.Data{VcapRequestIdHeader: guid})
}
}
}
示例14: streamProcess
func (s *GardenServer) streamProcess(logger lager.Logger, conn net.Conn, process garden.Process, stdinPipe *io.PipeWriter, connCloseCh chan struct{}) {
statusCh := make(chan int, 1)
errCh := make(chan error, 1)
go func() {
status, err := process.Wait()
if err != nil {
logger.Error("wait-failed", err, lager.Data{
"id": process.ID(),
})
errCh <- err
} else {
logger.Info("exited", lager.Data{
"status": status,
"id": process.ID(),
})
statusCh <- status
}
}()
for {
select {
case status := <-statusCh:
transport.WriteMessage(conn, &transport.ProcessPayload{
ProcessID: process.ID(),
ExitStatus: &status,
})
stdinPipe.Close()
return
case err := <-errCh:
e := err.Error()
transport.WriteMessage(conn, &transport.ProcessPayload{
ProcessID: process.ID(),
Error: &e,
})
stdinPipe.Close()
return
case <-s.stopping:
logger.Debug("detaching", lager.Data{
"id": process.ID(),
})
return
case <-connCloseCh:
return
}
}
}
示例15: fetchRecursiveRaw
func (db *ETCDDB) fetchRecursiveRaw(logger lager.Logger, key string) (*etcd.Node, error) {
logger.Debug("fetching-recursive-from-etcd")
response, err := db.client.Get(key, false, true)
if err != nil {
return nil, ErrorFromEtcdError(logger, err)
}
logger.Debug("succeeded-fetching-recursive-from-etcd", lager.Data{"num_nodes": response.Node.Nodes.Len()})
return response.Node, nil
}