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


Golang Log.Error方法代码示例

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


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

示例1: from_Default

/**
 * This is a fallback client builder, which builds the default
 * coach client.  The default coach client is currently the
 * FSouza Docker client, configured to use ENV settings, or
 * a local socket.
 */
func (clientFactories *ClientFactories) from_Default(logger log.Log, project *conf.Project) {
	clientFactorySettings := &FSouza_ClientFactorySettings{}
	clientType := "fsouza"

	if DockerHost := os.Getenv("DOCKER_HOST"); DockerHost == "" {
		logger.Debug(log.VERBOSITY_DEBUG, "No local environment DOCKER settings found, assuming a locally running docker client will be found.")
		clientFactorySettings.Host = "unix:///var/run/docker.sock"
	} else {
		clientFactorySettings.Host = DockerHost
	}

	// if we have no cert path, and we are going to use a TCP socket, test for a default cert path.
	if DockerCertPath := os.Getenv("DOCKER_CERT_PATH"); DockerCertPath != "" {
		clientFactorySettings.CertPath = DockerCertPath
	}

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

	// Add this factory to the factory list
	logger.Debug(log.VERBOSITY_DEBUG_LOTS, "Client Factory Created [Client_DockerFSouzaFactory]", factory)
	clientFactories.AddClientFactory(clientType, ClientFactory(&factory))
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:31,代码来源:clientfactory.go

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

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

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

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

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

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

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

示例10: Pull

func (client *FSouza_NodeClient) Pull(logger log.Log, force bool) bool {
	image, tag := client.GetImageName()
	actionCacheTag := "pull:" + image + ":" + tag

	if _, ok := actionCache[actionCacheTag]; ok {
		logger.Message("Node image [" + image + ":" + tag + "] was just pulled, so not pulling it again.")
		return true
	}

	if !force && client.HasImage() {
		logger.Info("Node already has an image [" + image + ":" + tag + "], so not pulling it again.  You can force this operation if you want to pull this image.")
		return false
	}

	options := docker.PullImageOptions{
		Repository:    image,
		OutputStream:  logger,
		RawJSONStream: false,
	}

	if tag != "" {
		options.Tag = tag
	}

	var auth docker.AuthConfiguration
	// 		var ok bool
	//options.Registry = "https://index.docker.io/v1/"

	// 		auths, _ := docker.NewAuthConfigurationsFromDockerCfg()
	// 		if auth, ok = auths.Configs[registry]; ok {
	// 			options.Registry = registry
	// 		} else {
	// 			node.log.Warning("You have no local login credentials for any repo. Defaulting to no login.")
	auth = docker.AuthConfiguration{}
	options.Registry = "https://index.docker.io/v1/"
	// 		}

	logger.Message("Pulling node image [" + image + ":" + tag + "] from server [" + options.Registry + "] using auth [" + auth.Username + "] : " + image + ":" + tag)
	logger.Debug(log.VERBOSITY_DEBUG_LOTS, "AUTH USED: ", map[string]string{"Username": auth.Username, "Password": auth.Password, "Email": auth.Email, "ServerAdddress": auth.ServerAddress})

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

	if err != nil {
		logger.Error("Node image not pulled : " + image + " => " + err.Error())
		actionCache[actionCacheTag] = false
		return false
	} else {
		client.backend.Refresh(true, false)
		logger.Message("Node image pulled: " + image + ":" + tag)
		actionCache[actionCacheTag] = false
		return true
	}
}
开发者ID:james-nesbitt,项目名称:coach,代码行数:54,代码来源:docker_fsouza.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.Error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。