本文整理汇总了Golang中github.com/james-nesbitt/coach/log.Log.Warning方法的典型用法代码示例。如果您正苦于以下问题:Golang Log.Warning方法的具体用法?Golang Log.Warning怎么用?Golang Log.Warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/james-nesbitt/coach/log.Log
的用法示例。
在下文中一共展示了Log.Warning方法的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
}
示例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
}
示例3: 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
}
示例4: 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
}
}
示例5: 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
}
示例6: 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
}
示例7: 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
}
示例8: 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
}
}
示例9: 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, "")
}
示例10: 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)
}
示例11: 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
}
示例12: 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
}
}
示例13: 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
}
示例14: 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
}
示例15: 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
}