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


Golang Logger.Infof方法代码示例

本文整理汇总了Golang中github.com/op/go-logging.Logger.Infof方法的典型用法代码示例。如果您正苦于以下问题:Golang Logger.Infof方法的具体用法?Golang Logger.Infof怎么用?Golang Logger.Infof使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/op/go-logging.Logger的用法示例。


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

示例1: UpdateAllMachines

func UpdateAllMachines(flags *UpdateFlags, log *logging.Logger) error {
	// Get all members
	members, err := flags.GetClusterMembers(log)
	if err != nil {
		return maskAny(err)
	}

	// Pull image on all machines
	log.Infof("Pulling gluon image on %d machines", len(members))
	var pullGroup errgroup.Group
	for _, m := range members {
		m := m
		pullGroup.Go(func() error {
			return maskAny(pullImage(m, *flags, log))
		})
	}
	if err := pullGroup.Wait(); err != nil {
		return maskAny(err)
	}

	// Update all machines, one at a time
	for index, m := range members {
		if index > 0 {
			log.Infof("Waiting %s...", flags.MachineDelay)
			time.Sleep(flags.MachineDelay)
		}
		if err := updateMachine(m, *flags, log); err != nil {
			return maskAny(err)
		}
	}

	return nil
}
开发者ID:pulcy,项目名称:gluon,代码行数:33,代码来源:update.go

示例2: initMakefile

func initMakefile(log *log.Logger, projectDir, projectType string) error {
	if projectType != ProjectTypeGo {
		return nil
	}
	path := filepath.Join(projectDir, makefilePath)
	if info, err := os.Stat(path); os.IsNotExist(err) {
		log.Infof("Creating %s", makefilePath)
		options := struct {
			GoVersion string
		}{
			GoVersion: "1.7.3-alpine",
		}
		t, err := template.New("makefile").Parse(initialMakefile)
		if err != nil {
			return maskAny(err)
		}
		buffer := &bytes.Buffer{}
		if err := t.Execute(buffer, options); err != nil {
			return maskAny(err)
		}

		if err := ioutil.WriteFile(path, buffer.Bytes(), 0644); err != nil {
			return maskAny(err)
		}
		return nil
	} else if err != nil {
		return maskAny(err)
	} else if info.IsDir() {
		return maskAny(fmt.Errorf("%s must be a file", path))
	} else {
		log.Debugf("%s already initialized in %s", gitIgnorePath, projectDir)
		return nil
	}
}
开发者ID:pulcy,项目名称:pulsar,代码行数:34,代码来源:makefile.go

示例3: initGitIgnore

func initGitIgnore(log *log.Logger, projectDir string) error {
	path := filepath.Join(projectDir, gitIgnorePath)
	if info, err := os.Stat(path); os.IsNotExist(err) {
		log.Infof("Creating %s", gitIgnorePath)
		if err := ioutil.WriteFile(path, []byte(initialGitIgnore), 0644); err != nil {
			return maskAny(err)
		}
		return nil
	} else if err != nil {
		return maskAny(err)
	} else if info.IsDir() {
		return maskAny(fmt.Errorf("%s must be a file", path))
	} else {
		log.Debugf("%s already initialized in %s", gitIgnorePath, projectDir)
		return nil
	}
}
开发者ID:pulcy,项目名称:pulsar,代码行数:17,代码来源:init.go

示例4: updateMachine

func updateMachine(member service.ClusterMember, flags UpdateFlags, log *logging.Logger) error {
	askConfirmation := flags.AskConfirmation
	log.Infof("Updating %s...", member.ClusterIP)

	// Extract gluon binary
	cmd := fmt.Sprintf("docker run --rm -v /home/core/bin/:/destination/ %s", flags.GluonImage)
	if _, err := runRemoteCommand(member, flags.UserName, log, cmd, "", false); err != nil {
		return maskAny(err)
	}

	// Update image version on disk
	if _, err := runRemoteCommand(member, flags.UserName, log, "sudo tee /etc/pulcy/gluon-image", flags.GluonImage, false); err != nil {
		return maskAny(err)
	}

	// Setup new gluon version
	if _, err := runRemoteCommand(member, flags.UserName, log, "sudo systemctl restart gluon", "", false); err != nil {
		return maskAny(err)
	}

	// Reboot if needed
	if flags.Reboot {
		log.Infof("Rebooting %s...", member.ClusterIP)
		runRemoteCommand(member, flags.UserName, log, "sudo reboot -f", "", true)
		time.Sleep(time.Second * 15)
		if err := waitUntilMachineUp(member, flags, log); err != nil {
			return maskAny(err)
		}
		if !member.EtcdProxy {
			log.Warningf("Core machine %s is back up, check services", member.ClusterIP)
			askConfirmation = true
		} else {
			log.Infof("Machine %s is back up", member.ClusterIP)
		}
	}

	if askConfirmation {
		confirm("Can we continue?")
	}

	return nil
}
开发者ID:pulcy,项目名称:gluon,代码行数:42,代码来源:update.go

示例5: Get

// Get ensures that flags.Folder contains an up to date copy of flags.RepoUrl checked out to flags.Version.
func Get(log *log.Logger, flags *Flags) error {
	// Get cache dir
	cachedir, cacheIsValid, err := cache.Dir(flags.RepoUrl, 0)
	if err != nil {
		return maskAny(err)
	}

	// Expand folder
	flags.Folder, err = filepath.Abs(flags.Folder)
	if err != nil {
		return maskAny(err)
	}

	// Get current folder
	wd, _ := os.Getwd()

	linked := false
	if flags.AllowLink {
		if info, err := util.ParseVCSURL(flags.RepoUrl); err == nil {
			siblingPath := filepath.Join(filepath.Dir(wd), info.Name)
			if _, err := os.Stat(siblingPath); err == nil {
				//log.Infof("Sibling folder %s exists", siblingPath)
				util.ExecuteInDir(siblingPath, func() error {
					remote, err := git.GetRemoteOriginUrl(nil)
					if err != nil {
						return maskAny(err)
					}
					if remote == flags.RepoUrl {
						if relPath, err := filepath.Rel(filepath.Dir(flags.Folder), siblingPath); err == nil {
							if err := os.Symlink(relPath, flags.Folder); err == nil {
								log.Infof("Linked -> %s", siblingPath)
								linked = true

								if vendorDir, err := golang.GetVendorDir(siblingPath); err != nil {
									return maskAny(err)
								} else {
									// Flatten sibling in copy-only mode
									if err := golang.Flatten(log, &golang.FlattenFlags{
										VendorDir: vendorDir,
										NoRemove:  true,
									}); err != nil {
										return maskAny(err)
									}
								}

							}
						}
					}
					return nil
				})
			}
		}
	}
	if linked {
		return nil
	}

	// Fill cache if needed
	cloned := false
	if !cacheIsValid {
		// Clone repo into cachedir
		if err := git.Clone(log, flags.RepoUrl, cachedir); err != nil {
			return maskAny(err)
		}
		cloned = true
	}

	// Make sure a clone exists
	_, err = os.Stat(flags.Folder)
	if os.IsNotExist(err) {
		// Sync into target folder
		if err := os.MkdirAll(flags.Folder, 0777); err != nil {
			return maskAny(err)
		}
		if err := util.ExecPrintError(nil, "rsync", "-a", appendDirSep(cachedir), appendDirSep(flags.Folder)); err != nil {
			return maskAny(err)
		}
	}
	// Change dir to folder
	if err := os.Chdir(flags.Folder); err != nil {
		return maskAny(err)
	}
	// Specific version needed?
	if flags.Version == "" {
		// Get latest version
		if !cloned {
			localCommit, err := git.GetLatestLocalCommit(nil, flags.Folder, defaultGetBranch, false)
			if err != nil {
				return maskAny(err)
			}
			remoteCommit, err := git.GetLatestRemoteCommit(nil, flags.RepoUrl, defaultGetBranch)
			if err != nil {
				return maskAny(err)
			}
			if localCommit != remoteCommit {
				if err := git.Pull(log, "origin"); err != nil {
					return maskAny(err)
				}
			} else {
//.........这里部分代码省略.........
开发者ID:pulcy,项目名称:pulsar,代码行数:101,代码来源:get.go


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