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


Golang log.Log类代码示例

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


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


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