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


Golang Log.MakeChild方法代码示例

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


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

示例1: from_ToolYamlBytes

// Try to Tooligure a project by parsing yaml from a byte stream
func (tools *Tools) from_ToolYamlBytes(logger log.Log, project *conf.Project, yamlBytes []byte) bool {
	if project != nil {
		// token replace
		tokens := &project.Tokens
		yamlBytes = []byte(tokens.TokenReplace(string(yamlBytes)))
	}

	var yaml_tools map[string]map[string]interface{}
	err := yaml.Unmarshal(yamlBytes, &yaml_tools)
	if err != nil {
		logger.Warning("Could not parse tool yaml:" + err.Error())
		return false
	}

	for name, tool_struct := range yaml_tools {
		switch tool_struct["Type"] {
		case "script":
			json_tool, _ := json.Marshal(tool_struct)
			var scriptTool Tool_Script
			err := json.Unmarshal(json_tool, &scriptTool)
			if err != nil {
				logger.Warning("Couldn't process tool [" + name + "] :" + err.Error())
				continue
			}

			tool := Tool(&scriptTool)
			tool.Init(logger.MakeChild("SCRIPT:"+name), project)

			tools.SetTool(name, tool)
		}

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

示例2: Run

func (operation *BuildOperation) Run(logger log.Log) bool {
	logger.Info("Running operation: build")
	logger.Debug(log.VERBOSITY_DEBUG, "Run:Targets", operation.targets.TargetOrder())

	for _, targetID := range operation.targets.TargetOrder() {
		target, targetExists := operation.targets.Target(targetID)
		if !targetExists {
			// this is strange
			logger.Warning("Internal target error, was told to use a target that doesn't exist")
			continue
		}

		node, hasNode := target.Node()
		nodeLogger := logger.MakeChild(targetID)

		if !hasNode {
			nodeLogger.Info("No node [" + node.MachineName() + "]")
		} else if !node.Can("build") {
			nodeLogger.Info("Node doesn't build [" + node.MachineName() + "]")
		} else {
			nodeLogger.Message("Building node")
			node.Client().Build(nodeLogger, operation.force)
		}
	}

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

示例3: from_ClientFactoriesYamlBytes

// Try to configure factories by parsing yaml from a byte stream
func (clientFactories *ClientFactories) from_ClientFactoriesYamlBytes(logger log.Log, project *conf.Project, yamlBytes []byte) bool {
	if project != nil {
		// token replace
		tokens := &project.Tokens
		yamlBytes = []byte(tokens.TokenReplace(string(yamlBytes)))
	}

	var yaml_clients map[string]map[string]interface{}
	err := yaml.Unmarshal(yamlBytes, &yaml_clients)
	if err != nil {
		logger.Warning("YAML parsing error : " + err.Error())
		return false
	}
	logger.Debug(log.VERBOSITY_DEBUG_STAAAP, "YAML source:", yaml_clients)

	for name, client_struct := range yaml_clients {
		clientType := ""
		client_json, _ := json.Marshal(client_struct)
		logger.Debug(log.VERBOSITY_DEBUG_STAAAP, "Single client JSON:", string(client_json))

		if clientType_struct, ok := client_struct["Type"]; ok {
			clientType, _ = clientType_struct.(string)
		} else {
			clientType = name
		}

		switch strings.ToLower(clientType) {
		case "docker":
			fallthrough
		case "fsouza":

			clientFactorySettings := &FSouza_ClientFactorySettings{}
			err := json.Unmarshal(client_json, clientFactorySettings)

			if err != nil {
				logger.Warning("Factory definition failed to configure client factory :" + err.Error())
				logger.Debug(log.VERBOSITY_DEBUG, "Factory configuration json: ", string(client_json), clientFactorySettings)
				continue
			}

			factory := FSouza_ClientFactory{}
			if !factory.Init(logger.MakeChild(clientType), project, ClientFactorySettings(clientFactorySettings)) {
				logger.Error("Failed to initialize FSouza factory from client factory configuration: " + err.Error())
				continue
			}

			// Add this factory to the factory list
			logger.Debug(log.VERBOSITY_DEBUG_LOTS, "Client Factory Created [Client_DockerFSouzaFactory]", factory)
			clientFactories.AddClientFactory(clientType, ClientFactory(&factory))

		case "":
			logger.Warning("Client registration failure, client has a bad value for 'Type'")
		default:
			logger.Warning("Client registration failure, client has an unknown value for 'Type' :" + clientType)
		}

	}

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

示例4: 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

示例5: 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

示例6: Init

func (clientFactory *FSouza_ClientFactory) Init(logger log.Log, project *conf.Project, settings ClientFactorySettings) bool {
	clientFactory.log = logger
	clientFactory.conf = project

	// make sure that the settings that were given, where the proper "FSouza_ClientFactory" type
	typedSettings := settings.Settings()
	switch asserted := typedSettings.(type) {
	case *FSouza_ClientFactorySettings:
		clientFactory.settings = *asserted
	default:
		logger.Error("Invalid settings type passed to Fsouza Factory")
		logger.Debug(log.VERBOSITY_DEBUG, "Settings passed:", asserted)
	}

	// if we haven't made an actual fsouza docker client, then do it now
	if clientFactory.client == nil {
		if client, pk := clientFactory.makeFsouzaClientWrapper(logger.MakeChild("fsouza")); pk {
			clientFactory.client = client
			return true
		} else {
			logger.Error("Failed to create actual FSouza Docker client from client factory configuration")
			return false
		}
	}
	return true
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:26,代码来源:docker_fsouza.go

示例7: Run

func (operation *InfoOperation) Run(logger log.Log) bool {
	logger.Message("RUNNING INFO 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()
		_, 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)

		if hasNode {
			nodeLogger.Message(targetID + " Information")
			node.Client().NodeInfo(nodeLogger)
		} else {
			nodeLogger.Message("No node [" + node.MachineName() + "]")
		}
		if hasInstances {
			node.Instances().Client().InstancesInfo(nodeLogger)
		} else {
			nodeLogger.Message("|-- No instances [" + node.MachineName() + "]")
		}
	}

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

示例8: Run

func (operation *CreateOperation) Run(logger log.Log) bool {
	logger.Info("Running operation: create")
	logger.Debug(log.VERBOSITY_DEBUG, "Run:Targets", operation.targets.TargetOrder())

	for _, targetID := range operation.targets.TargetOrder() {
		target, targetExists := operation.targets.Target(targetID)
		if !targetExists {
			// this is strange
			logger.Warning("Internal target error, was told to use a target that doesn't exist")
			continue
		}

		node, hasNode := target.Node()
		instances, hasInstances := target.Instances()
		nodeLogger := logger.MakeChild(targetID)

		if !hasNode {
			nodeLogger.Warning("No node [" + node.MachineName() + "]")
		} else if !node.Can("create") {
			nodeLogger.Info("Node doesn't create [" + node.MachineName() + ":" + node.Type() + "]")
		} else if !hasInstances {
			nodeLogger.Info("No valid instances specified in target list [" + node.MachineName() + "]")
		} else {
			nodeLogger.Message("Creating instance containers")
			for _, id := range instances.InstancesOrder() {
				instance, _ := instances.Instance(id)
				instance.Client().Create(logger, []string{}, operation.force)
			}
		}
	}

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

示例9: Run

// Run all of the prepared operations
func (operations *Operations) Run(logger log.Log) {
	if len(operations.operationsList) == 0 {
		logger.Error("No operation created")
	} else {
		for _, operation := range operations.operationsList {
			operation.Run(logger.MakeChild(operation.Id()))
		}
	}
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:10,代码来源:operation.go

示例10: Run

func (operation *ScaleOperation) Run(logger log.Log) bool {
	logger.Info("Running operation: scale")
	logger.Debug(log.VERBOSITY_DEBUG, "Run:Targets", operation.targets.TargetOrder())

	if operation.scale == 0 {
		operation.log.Warning("scale operation was told to scale to 0")
		return false
	}

	for _, targetID := range operation.targets.TargetOrder() {
		target, targetExists := operation.targets.Target(targetID)
		if !targetExists {
			// this is strange
			logger.Warning("Internal target error, was told to use a target that doesn't exist")
			continue
		}

		node, hasNode := target.Node()
		nodeLogger := logger.MakeChild(targetID)

		if !hasNode {
			nodeLogger.Info("No node [" + node.MachineName() + "]")
		} else if !node.Can("scale") {
			nodeLogger.Info("Node doesn't Scale [" + node.MachineName() + "]")
		} else {
			nodeLogger.Message("Scaling node " + node.Id())

			if operation.scale > 0 {
				count := operation.ScaleUpNumber(nodeLogger, node.Instances(), operation.scale)

				if count == 0 {
					nodeLogger.Warning("Scale operation could not scale up any new instances of node")
				} else if count < operation.scale {
					nodeLogger.Warning("Scale operation could not scale up all of the requested instances of node. " + strconv.FormatInt(int64(count+1), 10) + " started.")
				} else {
					nodeLogger.Message("Scale operation scaled up " + strconv.FormatInt(int64(count), 10) + " instances")
				}

			} else {
				count := operation.ScaleDownNumber(nodeLogger, node.Instances(), -operation.scale)

				if count == 0 {
					nodeLogger.Warning("Scale operation could not scale down any new instances of node")
				} else if count < (-operation.scale) {
					nodeLogger.Warning("Scale operation could not scale down all of the requested instances of node. " + strconv.FormatInt(int64(count+1), 10) + " stopped.")
				} else {
					nodeLogger.Message("Scale operation scaled down " + strconv.FormatInt(int64(count), 10) + " instances")
				}
			}

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

示例11: from_NodesYamlFilePath

// Try to configure a project by parsing yaml from a conf file
func (nodes *Nodes) from_NodesYamlFilePath(logger log.Log, project *conf.Project, clientFactories *ClientFactories, yamlFilePath string, overwrite bool) bool {
	// read the config file
	yamlFile, err := ioutil.ReadFile(yamlFilePath)
	if err != nil {
		logger.Debug(log.VERBOSITY_DEBUG_LOTS, "Could not read a YAML file: "+err.Error())
		return false
	}

	if !nodes.from_NodesYamlBytes(logger.MakeChild(yamlFilePath), project, clientFactories, yamlFile, overwrite) {
		logger.Warning("YAML marshalling of the YAML nodes file failed [" + yamlFilePath + "]: " + err.Error())
		return false
	}
	return true
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:15,代码来源:nodes_fromyaml.go

示例12: Prepare

// Post initialization preparation
func (node *BaseNode) Prepare(logger log.Log, nodes *Nodes) (success bool) {
	logger.Debug(log.VERBOSITY_DEBUG_WOAH, "Prepare: Base Node")
	success = true

	node.log = logger

	logger.Debug(log.VERBOSITY_DEBUG_WOAH, "Preparing Client", nil)
	success = success && node.client.Prepare(logger.MakeChild("client"), nodes, node)

	logger.Debug(log.VERBOSITY_DEBUG_WOAH, "Preparing Instances", nil)
	success = success && node.instances.Prepare(logger.MakeChild("instances"), node.client, nodes, node)

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

示例13: from_ConfYamlFilePath

// Try to configure a project by parsing yaml from a conf file
func (project *Project) from_ConfYamlFilePath(logger log.Log, yamlFilePath string) bool {
	// read the config file
	yamlFile, err := ioutil.ReadFile(yamlFilePath)
	if err != nil {
		logger.Debug(log.VERBOSITY_DEBUG_LOTS, "Could not read a YAML file: "+err.Error())
		return false
	}

	if !project.from_ConfYamlBytes(logger.MakeChild(yamlFilePath), yamlFile) {
		logger.Warning("YAML marshalling of the YAML conf file failed [" + yamlFilePath + "]: " + err.Error())
		return false
	}
	return true
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:15,代码来源:project_fromyaml.go

示例14: Run

func (operation *PauseOperation) Run(logger log.Log) bool {
	logger.Info("Running operation: pause")
	logger.Debug(log.VERBOSITY_DEBUG, "Run:Targets", operation.targets.TargetOrder())

	for _, targetID := range operation.targets.TargetOrder() {
		target, targetExists := operation.targets.Target(targetID)
		if !targetExists {
			// this is strange
			logger.Warning("Internal target error, was told to use a target that doesn't exist")
			continue
		}

		node, hasNode := target.Node()
		instances, hasInstances := target.Instances()

		nodeLogger := logger.MakeChild(targetID)

		if !hasNode {
			nodeLogger.Warning("No node [" + node.MachineName() + "]")
		} else if !node.Can("pause") {
			nodeLogger.Info("Node doesn't Pause [" + node.MachineName() + ":" + node.Type() + "]")
		} else if !hasInstances {
			nodeLogger.Info("No valid instances specified in target list [" + node.MachineName() + "]")
		} else {
			nodeLogger.Message("Pausing instances")

			if !instances.IsFiltered() {
				nodeLogger.Info("Switching to using all instances")
				instances.UseAll()
			}

			for _, id := range instances.InstancesOrder() {
				instance, _ := instances.Instance(id)

				if !instance.IsRunning() {
					if !instance.IsReady() {
						nodeLogger.Info("Instance will not be paused as it is not ready :" + id)
					} else {
						nodeLogger.Info("Instance will not be paused as it is not running :" + id)
					}
				} else {
					instance.Client().Pause(logger)
				}
			}
		}
	}

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

示例15: Prepare

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

	for _, name := range instances.settings.Names {
		machineName := instances.MachineName() + "_" + name

		instance := Instance(&FixedInstance{})
		if instance.Init(logger.MakeChild(name), name, machineName, client, true) {
			instances.instancesMap[name] = instance
			instances.instancesOrder = append(instances.instancesOrder, name)
		}
	}

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


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