本文整理匯總了Golang中github.com/koding/logging.Logger.Warning方法的典型用法代碼示例。如果您正苦於以下問題:Golang Logger.Warning方法的具體用法?Golang Logger.Warning怎麽用?Golang Logger.Warning使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/koding/logging.Logger
的用法示例。
在下文中一共展示了Logger.Warning方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: UninstallCommand
// UninstallCommand configures the Uninstall struct and calls it based on the
// given codegangsta/cli context.
//
// TODO: remove all artifacts, ie bolt db, ssh keys, kd etc.
func UninstallCommand(c *cli.Context, log logging.Logger, _ string) (string, int) {
warnings := []string{}
// Ensure /etc/kite/kite.key is migrated to konfig.bolt before
// old klient gets uninstalled. The endpoint/config package
// performs lazy migrations, so it's enough to call any of
// its methods and disregard the result.
_ = configcli.List()
s, err := newService(nil)
if err != nil {
log.Warning("Failed creating Service for uninstall. err:%s", err)
warnings = append(warnings, FailedUninstallingKlientWarn)
}
uninstaller := &Uninstall{
ServiceUninstaller: s,
KlientName: config.KlientName,
KlientctlName: config.Name,
KlientctlPath: filepath.Join(KlientctlDirectory, KlientctlBinName),
// TODO: Store the klient directory structure(s) somewhere
KlientParentDirectory: "/opt",
KlientDirectory: "kite/klient",
KlientFilename: "klient",
KlientshFilename: "klient.sh",
remover: os.Remove,
warnings: warnings,
log: log,
}
return uninstaller.Uninstall()
}
示例2: startKlient
func startKlient(log logging.Logger, s service.Service) error {
// For debug purposes, run a health check before we even attempt to start. This
// will help give us a sense of what this machine's health check was before
// klient tried to start.
if res, ok := defaultHealthChecker.CheckAllExceptRunning(); !ok {
log.Warning("before attempting to start klient health check returned not-okay. reason: %s", res)
}
if err := s.Start(); err != nil {
log.Error("Error starting Service. err:%s", err)
fmt.Println(FailedStartKlient)
return err
}
fmt.Println("Starting...")
err := WaitUntilStarted(config.Konfig.Endpoints.Klient.Private.String(), CommandAttempts, CommandWaitTime)
if err != nil {
log.Error(
"Timed out while waiting for Klient to start. attempts:%d, err:%s",
CommandAttempts, err,
)
if s, ok := defaultHealthChecker.CheckAllExceptRunning(); !ok {
fmt.Printf(`Failed to start %s in time.
A health check found the following issue:
%s
`, config.KlientName, s)
} else {
fmt.Println(FailedStartKlient)
}
return err
}
return nil
}
示例3: restoreLoadedMachineFromKite
// restoreLoadedMachineFromKite takes an old loaded machine and applies meta
// changes to it, while also creating a valid machine instance with a proper
// transport/etc.
func (r *Remote) restoreLoadedMachineFromKite(c *KodingClient, loadedMachine *machine.Machine, log logging.Logger) (bool, error) {
// metaChanged is our return value, which lets the caller know if any of the meta
// for this machine changed from the given kite. If it does, the caller will
// want to save the machines to the local db.
var metaChanged bool
host, err := r.hostFromClient(c.Client)
if err != nil {
log.Error("Unable to extract host from *kite.Client. err:%s", err)
return false, err
}
// Get our old machine meta, loaded from the DB
machineMeta := loadedMachine.MachineMeta
if machineMeta.MachineLabel != c.MachineLabel {
machineMeta.MachineLabel = c.MachineLabel
metaChanged = true
}
if machineMeta.URL == "" && c.URL != "" {
log.Warning("Machine missing MachineMeta.URL, updating it to %q", c.URL)
machineMeta.URL = c.URL
metaChanged = true
}
if machineMeta.IP == "" && host != "" {
log.Warning("Machine missing MachineMeta.IP, updating it to %q", host)
machineMeta.IP = host
metaChanged = true
}
if machineMeta.Hostname != c.Hostname {
machineMeta.Hostname = c.Hostname
metaChanged = true
}
if machineMeta.Username != c.Username {
machineMeta.Username = c.Username
metaChanged = true
}
// Remove the machine, because we're going to be creating a new machine instance
// below.
err = r.machines.Remove(loadedMachine)
if err != nil && err != machine.ErrMachineNotFound {
log.Error("Unable to Remove old machine from *machine.Machines. err:%s", err)
return false, err
}
restoredMachine, err := machine.NewMachine(machineMeta, r.log, c.Client)
if err != nil {
return false, err
}
// Add our newly created machine instance.
if err = r.machines.Add(restoredMachine); err != nil {
log.Error("Unable to Add new machine to *machine.Machines. err:%s", err)
return false, err
}
return metaChanged, nil
}