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


Golang Log.Message方法代码示例

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


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

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

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

示例3: Attach

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

	// build options for the docker attach operation
	options := docker.AttachToContainerOptions{
		Container:    id,
		InputStream:  os.Stdin,
		OutputStream: os.Stdout,
		ErrorStream:  logger,

		Logs:   true, // Get container logs, sending it to OutputStream.
		Stream: true, // Stream the response?

		Stdin:  true, // Attach to stdin, and use InputStream.
		Stdout: true, // Attach to stdout, and use OutputStream.
		Stderr: true,

		//Success chan struct{}

		RawTerminal: client.settings.Config.Tty, // Use raw terminal? Usually true when the container contains a TTY.
	}

	logger.Message("Attaching to instance container [" + id + "]")
	err := client.backend.AttachToContainer(options)
	if err != nil {
		logger.Error("Failed to attach to instance container [" + id + "] =>" + err.Error())
		return false
	} else {
		logger.Message("Disconnected from instance container [" + id + "]")
		return true
	}
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:32,代码来源:docker_fsouza.go

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

示例5: Destroy

func (client *FSouza_NodeClient) Destroy(logger log.Log, force bool) bool {
	// Get the image name
	image, tag := client.GetImageName()
	if tag != "" {
		image += ":" + tag
	}

	if !client.HasImage() {
		logger.Warning("Node has no image to destroy [" + image + "]")
		return false
	}

	options := docker.RemoveImageOptions{
		Force: force,
	}

	// ask the docker client to remove the image
	err := client.backend.RemoveImageExtended(image, options)

	if err != nil {
		logger.Error("Node image removal failed [" + image + "] => " + err.Error())
		return false
	} else {
		client.backend.Refresh(true, false)
		logger.Message("Node image was removed [" + image + "]")
		return true
	}
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:28,代码来源:docker_fsouza.go

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

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

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

示例9: Init_Generate

func Init_Generate(logger log.Log, handler string, path string, skip []string, sizeLimit int64, output io.Writer) bool {
	logger.Message("GENERATING INIT")

	var generator Generator
	switch handler {
	case "test":
		generator = Generator(&TestInitGenerator{logger: logger, output: output})
	case "yaml":
		generator = Generator(&YMLInitGenerator{logger: logger, output: output})
	default:
		logger.Error("Unknown init generator (handler) " + handler)
		return false
	}

	iterator := GenerateIterator{
		logger:    logger,
		output:    output,
		skip:      skip,
		sizeLimit: sizeLimit,
		generator: generator,
	}

	if iterator.Generate(path) {
		logger.Message("FINISHED GENERATING YML INIT")
		return true
	} else {
		logger.Error("ERROR OCCURRED GENERATING YML INIT")
		return false
	}
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:30,代码来源:generate.go

示例10: RunTask

func (task *InitTaskFile) RunTask(logger log.Log) bool {
	if task.path == "" {
		return false
	}

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

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

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

示例13: Build

func (client *FSouza_NodeClient) Build(logger log.Log, force bool) bool {
	image, tag := client.GetImageName()

	if client.settings.BuildPath == "" {
		logger.Warning("Node image [" + image + ":" + tag + "] not built as an empty path was provided.  You must point Build: to a path inside .coach")
		return false
	}

	if !force && client.HasImage() {
		logger.Info("Node image [" + image + ":" + tag + "] not built as an image already exists.  You can force this operation to build this image")
		return false
	}

	// determine an absolute buildPath to the build, for Docker to use.
	buildPath := ""
	for _, confBuildPath := range client.conf.Paths.GetConfSubPaths(client.settings.BuildPath) {
		logger.Debug(log.VERBOSITY_DEBUG_STAAAP, "Looking for Build: "+confBuildPath)
		if _, err := os.Stat(confBuildPath); !os.IsNotExist(err) {
			buildPath = confBuildPath
			break
		}
	}
	if buildPath == "" {
		logger.Error("No matching build path could be found [" + client.settings.BuildPath + "]")
	}

	options := docker.BuildImageOptions{
		Name:           image + ":" + tag,
		ContextDir:     buildPath,
		RmTmpContainer: true,
		OutputStream:   logger,
	}

	logger.Info("Building node image [" + image + ":" + tag + "] From build path [" + buildPath + "]")

	// ask the docker client to build the image
	err := client.backend.BuildImage(options)

	if err != nil {
		logger.Error("Node build failed [" + client.node.MachineName() + "] in build path [" + buildPath + "] => " + err.Error())
		return false
	} else {
		client.backend.Refresh(true, false)
		logger.Message("Node succesfully built image [" + image + ":" + tag + "] From path [" + buildPath + "]")
		return true
	}

}
开发者ID:james-nesbitt,项目名称:coach,代码行数:48,代码来源:docker_fsouza.go

示例14: Start

func (client *FSouza_InstanceClient) Start(logger log.Log, force bool) bool {
	// Convert the node data into docker data (transform node keys to container IDs for things like Links & VolumesFrom)
	id := client.instance.MachineName()
	Host := client.settings.Host

	// ask the docker client to start the instance container
	err := client.backend.StartContainer(id, &Host)

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

示例15: Remove

func (client *FSouza_InstanceClient) Remove(logger log.Log, force bool) bool {
	name := client.instance.MachineName()
	options := docker.RemoveContainerOptions{
		ID: name,
	}

	// ask the docker client to remove the instance container
	err := client.backend.RemoveContainer(options)

	if err != nil {
		logger.Error("Failed to remove instance container [" + name + "] =>" + err.Error())
		return false
	} else {
		client.backend.Refresh(false, true)
		logger.Message("Removed instance container [" + name + "] ")
		return true
	}

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


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