• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang log.Log类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: IsValid

// Is this project configured enough to run coach
func (project *Project) IsValid(logger log.Log) bool {
	/**
	 * 1. do we have a project coach folder, and does it exist.
	 */
	if projectCoachPath, ok := project.Path("project-coach"); ok {
		if _, err := os.Stat(projectCoachPath); err != nil {
			logger.Warning(`Could not find a project root .coach folder:  
- At the root of any coach prpject, must be a .coach folder;
- This folder can container project configurations;
- The folder is required, because it tells coach where the project base is.`)
			return false
		}
	} else {
		return false
	}

	/**
	 * 2. Do we have a project name
	 *
	 * This is important as it gets used to make image and container names
	 */
	if project.Name == "" {
		logger.Warning(`Coach project has no Name.  
- A project name can be set in the .coach/conf.yml file.  
- The Name is used as a base for image and container names.`)
		return false
	}

	return true
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:31,代码来源:project.go


示例2: Init

// Constructor for BaseNode
func (node *BaseNode) Init(logger log.Log, name string, project *conf.Project, client Client, instancesSettings InstancesSettings) bool {
	node.log = logger
	node.conf = project
	node.name = name
	node.client = client
	node.manualDependencies = []string{}

	instancesMachineName := node.MachineName()

	settingsInterface := instancesSettings.Settings()
	switch settingsInterface.(type) {
	case FixedInstancesSettings:
		node.instances = Instances(&FixedInstances{})
		instancesMachineName += "_fixed_"
	case TemporaryInstancesSettings:
		node.instances = Instances(&TemporaryInstances{})
		instancesMachineName += "_temp_"
	case ScaledInstancesSettings:
		node.instances = Instances(&ScaledInstances{})
		instancesMachineName += "_scaled_"
	case SingleInstancesSettings:
		node.instances = Instances(&SingleInstances{})
	default:
		node.instances = Instances(&SingleInstances{})
	}

	node.instances.Init(logger, instancesMachineName, client, instancesSettings)

	logger.Debug(log.VERBOSITY_DEBUG_STAAAP, "Built new node:", node.client)
	return true
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:32,代码来源:node.go


示例3: ScaleUpNumber

// scale a node up a certain number of instances
func (operation *ScaleOperation) ScaleUpNumber(logger log.Log, instances libs.Instances, number int) int {
	count := 0
	instancesOrder := instances.InstancesOrder()

InstanceScaleReturn:
	for _, instanceId := range instancesOrder {
		if instance, ok := instances.Instance(instanceId); ok {
			client := instance.Client()

			if client.IsRunning() {
				continue InstanceScaleReturn
			} else if !client.HasContainer() {
				// create a new container for this instance
				client.Create(logger, []string{}, false)
			}

			logger.Info("Node Scaling up. Starting instance :" + instanceId)
			client.Start(logger, false)

			count++
			if count >= number {
				return count
			}
		}
	}

	return count
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:29,代码来源:operation_scale.go


示例4: Commit

func (client *FSouza_InstanceClient) Commit(logger log.Log, tag string, message string) bool {
	id := client.instance.MachineName()
	config := client.settings.Config
	repo := client.settings.Repository
	author := client.settings.Author

	if repo == "" {
		repo, _ = client.GetImageName()
	}

	options := docker.CommitContainerOptions{
		Container:  id,
		Repository: repo,
		Tag:        tag,
		Run:        &config,
	}

	if message != "" {
		options.Message = message
	}
	if author != "" {
		author = client.conf.Author
	}

	_, err := client.backend.CommitContainer(options)
	if err != nil {
		logger.Warning("Failed to commit container changes to an image [" + client.instance.Id() + ":" + id + "] : " + tag)
		return false
	} else {
		client.backend.Refresh(true, false)
		logger.Message("Committed container changes to an image [" + client.instance.Id() + ":" + id + "] : " + tag)
		return true
	}
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:34,代码来源:docker_fsouza.go


示例5: ScaleDownNumber

// scale a node down a certain number of instances
func (operation *ScaleOperation) ScaleDownNumber(logger log.Log, instances libs.Instances, number int) int {

	count := 0
	instancesOrder := []string{}
	for _, instanceId := range instances.InstancesOrder() {
		instancesOrder = append([]string{instanceId}, instancesOrder...)
	}

InstanceScaleReturn:
	for _, instanceId := range instancesOrder {
		if instance, ok := instances.Instance(instanceId); ok {
			client := instance.Client()

			if !client.IsRunning() {
				continue InstanceScaleReturn
			}

			logger.Info("Node Scaling down. Stopping instance :" + instanceId)
			client.Stop(logger, operation.force, operation.timeout)

			if operation.removeStopped {
				client.Remove(logger, operation.force)
			}

			count++
			if count >= number {
				return count
			}
		}
	}

	return count
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:34,代码来源:operation_scale.go


示例6: Init

func (node *PullNode) Init(logger log.Log, name string, project *conf.Project, client Client, instancesSettings InstancesSettings) bool {
	node.BaseNode.Init(logger, name, project, client, instancesSettings)

	settingsInterface := instancesSettings.Settings()
	switch settingsInterface.(type) {
	case FixedInstancesSettings:
		logger.Warning("Pull node cannot be configured to use fixed instances.  Using null instance instead.")
		node.defaultInstances(logger, client, instancesSettings)
	case ScaledInstancesSettings:
		logger.Warning("Pull node cannot be configured to use scaled instances.  Using null instance instead.")
		node.defaultInstances(logger, client, instancesSettings)
	case SingleInstancesSettings:
		logger.Warning("Pull node cannot be configured to use single instances.  Using null instance instead.")
		node.defaultInstances(logger, client, instancesSettings)
	case TemporaryInstancesSettings:
		logger.Warning("Pull node cannot be configured to use disposable instances.  Using null instance instead.")
		node.defaultInstances(logger, client, instancesSettings)
	default:
		node.defaultInstances(logger, client, instancesSettings)
	}

	node.instances.Init(logger, node.MachineName(), client, instancesSettings)

	logger.Debug(log.VERBOSITY_DEBUG_STAAAP, "Built new node:", node.client)
	return true
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:26,代码来源:node_pull.go


示例7: Init_Demo_Run

func (tasks *InitTasks) Init_Demo_Run(logger log.Log, demo string) bool {
	if demoPath, ok := COACH_DEMO_URLS[demo]; ok {
		return tasks.Init_Yaml_Run(logger, demoPath)
	} else {
		logger.Error("Unknown demo key : " + demo)
		return false
	}
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:8,代码来源:demo.go


示例8: CopyFileRecursive

func (task *InitTaskFileBase) CopyFileRecursive(logger log.Log, path string, source string) bool {
	sourceAbsPath, ok := task.absolutePath(source, false)
	if !ok {
		logger.Warning("Couldn't find copy source " + source)
		return false
	}
	return task.copyFileRecursive(logger, path, sourceAbsPath, "")
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:8,代码来源:file.go


示例9: configureProject

// Use the secrets yaml object to configure a project
func (secrets *secrets_Yaml) configureProject(logger log.Log, project *Project) bool {
	for key, value := range secrets.Secrets {
		project.SetToken(key, value)
	}

	logger.Debug(log.VERBOSITY_DEBUG_STAAAP, "Configured project from YAML secrets")
	return true
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:9,代码来源:secrets.go


示例10: Run

func (operation *UnknownOperation) Run(logger log.Log) bool {
	if operation.id == DEFAULT_OPERATION {
		logger.Error("No operation specified")
	} else {
		logger.Error("Unknown operation: " + operation.id)
	}
	return false
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:8,代码来源:operation.go


示例11: from_ConfYamlBytes

// Try to configure a project by parsing yaml from a byte stream
func (project *Project) from_ConfYamlBytes(logger log.Log, yamlBytes []byte) bool {
	// parse the config file contents as a ConfSource_projectyaml object
	source := new(conf_Yaml)
	if err := yaml.Unmarshal(yamlBytes, source); err != nil {
		logger.Warning("YAML parsing error : " + err.Error())
		return false
	}
	logger.Debug(log.VERBOSITY_DEBUG_STAAAP, "YAML source:", *source)

	return source.configureProject(logger, project)
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:12,代码来源:project_fromyaml.go


示例12: Prepare

func (instances *SingleInstances) Prepare(logger log.Log, client Client, nodes *Nodes, node Node) bool {
	instances.log = logger
	logger.Debug(log.VERBOSITY_DEBUG_WOAH, "Prepare: Single Instances")

	instances.instance = SingleInstance{}
	instances.instance.Init(logger, INSTANCE_SINGLE_ID, instances.MachineName(), client, true)

	instances.log.Debug(log.VERBOSITY_DEBUG_WOAH, "Created single instance", instances.instance)

	return true
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:11,代码来源:instances_single.go


示例13: copyFileRecursive

func (task *InitTaskFileBase) copyFileRecursive(logger log.Log, destinationRootPath string, sourceRootPath string, sourcePath string) bool {
	fullPath := sourceRootPath

	if sourcePath != "" {
		fullPath = path.Join(fullPath, sourcePath)
	}

	// get properties of source dir
	info,
		err := os.Stat(fullPath)
	if err != nil {
		// @TODO do something log : source doesn't exist
		logger.Warning("File does not exist :" + fullPath)
		return false
	}

	mode := info.Mode()
	if mode.IsDir() {

		directory, _ := os.Open(fullPath)
		objects, err := directory.Readdir(-1)

		if err != nil {
			// @TODO do something log : source doesn't exist
			logger.Warning("Could not open directory")
			return false
		}

		for _, obj := range objects {

			//childSourcePath := source + "/" + obj.Name()
			childSourcePath := path.Join(sourcePath, obj.Name())
			if !task.copyFileRecursive(logger, destinationRootPath, sourceRootPath, childSourcePath) {
				logger.Warning("Resursive copy failed")
			}

		}

	} else {
		// add file copy
		destinationPath := path.Join(destinationRootPath, sourcePath)
		if task.CopyFile(logger, destinationPath, sourceRootPath) {
			logger.Info("--> Copied file (recursively): " + sourcePath + " [from " + sourceRootPath + "]")
			return true
		} else {
			logger.Warning("--> Failed to copy file: " + sourcePath + " [from " + sourceRootPath + "]")
			return false
		}
		return true
	}
	return true
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:52,代码来源:file.go


示例14: Stop

func (client *FSouza_InstanceClient) Stop(logger log.Log, force bool, timeout uint) bool {
	id := client.instance.MachineName()

	err := client.backend.StopContainer(id, timeout)
	if err != nil {
		logger.Error("Failed to stop node container [" + id + "] => " + err.Error())
		return false
	} else {
		client.backend.Refresh(false, true)
		logger.Message("Node instance stopped [" + id + "]")
		return true
	}
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:13,代码来源:docker_fsouza.go


示例15: Unpause

func (client *FSouza_InstanceClient) Unpause(logger log.Log) bool {
	id := client.instance.MachineName()

	err := client.backend.UnpauseContainer(id)
	if err != nil {
		logger.Error("Failed to unpause Instance [" + client.instance.Id() + "] Container [" + id + "] =>" + err.Error())
		return false
	} else {
		client.backend.Refresh(false, true)
		logger.Message("Unpaused Instance [" + client.instance.Id() + "] Container [" + id + "]")
		return true
	}
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:13,代码来源:docker_fsouza.go


示例16: RunTask

func (task *InitTaskFileCopy) RunTask(logger log.Log) bool {
	if task.path == "" || task.root == "" || task.source == "" {
		return false
	}

	if task.CopyFileRecursive(logger, task.path, task.source) {
		logger.Message("--> Copied file : " + task.source + " -> " + task.path)
		return true
	} else {
		logger.Warning("--> Failed to copy file : " + task.source + " -> " + task.path)
		return false
	}
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:13,代码来源:file.go


示例17: Run

func (operation *InitGenerateOperation) Run(logger log.Log) bool {
	logger.Info("running init operation:" + operation.output)

	var writer io.Writer
	switch operation.output {
	case "logger":
		fallthrough
	case "":
		writer = logger
	default:
		if strings.HasSuffix(operation.output, ".") {
			operation.output = operation.output + operation.handler
		}
		if fileWriter, err := os.Create(operation.output); err == nil {
			operation.skip = append(operation.skip, operation.output)
			writer = io.Writer(fileWriter)
			defer fileWriter.Close()
			logger.Message("Opening file for init generation output: " + operation.output)
		} else {
			logger.Error("Could not open output file to write init to:" + operation.output)
		}
	}

	initialize.Init_Generate(logger.MakeChild("init-generate"), operation.handler, operation.root, operation.skip, operation.sizeLimit, writer)

	return true
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:27,代码来源:operation_initgenerate.go


示例18: Run

func (operation *StatusOperation) Run(logger log.Log) bool {
	logger.Message("RUNNING Status OPERATION")

	logger.Debug(log.VERBOSITY_DEBUG, "Run:Targets", operation.targets.TargetOrder())
	for _, targetID := range operation.targets.TargetOrder() {
		target, targetExists := operation.targets.Target(targetID)
		node, hasNode := target.Node()
		instances, hasInstances := target.Instances()

		if !targetExists {
			// this is strange
			logger.Warning("Internal target error, was told to use a target that doesn't exist")
			continue
		}

		nodeLogger := logger.MakeChild(targetID)
		status := []string{}

		if hasNode {
			status = append(status, operation.NodeStatus(nodeLogger, node)...)
		} else {
			status = append(status, "No node for target")
		}
		if hasInstances {
			status = append(status, operation.InstancesStatus(nodeLogger, instances)...)
		} else {
			status = append(status, "No instances for target")
		}

		nodeLogger.Message("[" + strings.Join(status, "][") + "]")
	}

	return true
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:34,代码来源:operation_status.go


示例19: Init_User_Run

func (tasks *InitTasks) Init_User_Run(logger log.Log, template string) bool {

	if template == "" {
		logger.Error("You have not provided a template name  $/> coach init user {template}")
		return false
	}

	templatePath, ok := tasks.conf.Path("user-templates")
	if !ok {
		logger.Error("COACH has no user template path for the current user")
		return false
	}
	sourcePath := path.Join(templatePath, template)

	if _, err := os.Stat(sourcePath); err != nil {
		logger.Error("Invalid template path suggested for new project init : [" + template + "] expected path [" + sourcePath + "] => " + err.Error())
		return false
	}

	logger.Message("Perfoming init operation from user template [" + template + "] : " + sourcePath)

	tasks.AddFileCopy(tasks.root, sourcePath)

	tasks.AddMessage("Copied coach template [" + template + "] to init project")
	tasks.AddFile(".coach/CREATEDFROM.md", `THIS PROJECT WAS CREATED FROM A User Template :`+template)

	return true
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:28,代码来源:user.go


示例20: Init_Git_Run

func (tasks *InitTasks) Init_Git_Run(logger log.Log, source string) bool {

	if source == "" {
		logger.Error("You have not provided a git target $/> coach init git https://github.com/aleksijohansson/docker-drupal-coach")
		return false
	}

	url := source
	path := tasks.root

	cmd := exec.Command("git", "clone", "--progress", url, path)
	cmd.Stdin = os.Stdin
	cmd.Stdout = logger
	cmd.Stderr = logger

	err := cmd.Start()

	if err != nil {
		logger.Error("Failed to clone the remote repository [" + url + "] => " + err.Error())
		return false
	}

	logger.Message("Clone remote repository to local project folder [" + url + "]")
	err = cmd.Wait()

	if err != nil {
		logger.Error("Failed to clone the remote repository [" + url + "] => " + err.Error())
		return false
	}

	tasks.AddMessage("Cloned remote repository [" + url + "] to local project folder")
	tasks.AddFile(".coach/CREATEDFROM.md", `THIS PROJECT WAS CREATED FROM GIT`)

	return true
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:35,代码来源:git.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang rbxweb.Client类代码示例发布时间:2022-05-23
下一篇:
Golang bitset.BitSet类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap