本文整理匯總了Golang中github.com/keybase/client/go/libcmdline.CommandLine.GetLogForward方法的典型用法代碼示例。如果您正苦於以下問題:Golang CommandLine.GetLogForward方法的具體用法?Golang CommandLine.GetLogForward怎麽用?Golang CommandLine.GetLogForward使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/keybase/client/go/libcmdline.CommandLine
的用法示例。
在下文中一共展示了CommandLine.GetLogForward方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: configureLogging
func configureLogging(g *libkb.GlobalContext, cl *libcmdline.CommandLine) error {
g.Log.Debug("+ configureLogging")
defer func() {
g.Log.Debug("- configureLogging")
}()
// Whether or not we autoforked, we're now running in client-server
// mode (as opposed to standalone). Register a global LogUI so that
// calls to G.Log() in the daemon can be copied to us. This is
// something of a hack on the daemon side.
if !g.Env.GetDoLogForward() || cl.GetLogForward() == libcmdline.LogForwardNone {
g.Log.Debug("Disabling log forwarding")
return nil
}
// TODO This triggers a connection to the RPC server before cmd.Run() is
// called, so the command has no way to deal with errors on its own.
// This should probably be moved into RegisterProtocols?
// Also rpc.RegisterProtocolsWithContext seems to automatically add the
// LogUIProtocol?
return registerGlobalLogUI(g)
}
示例2: configureLogging
func configureLogging(g *libkb.GlobalContext, cl *libcmdline.CommandLine) error {
g.Log.Debug("+ configureLogging")
defer func() {
g.Log.Debug("- configureLogging")
}()
// Whether or not we autoforked, we're now running in client-server
// mode (as opposed to standalone). Register a global LogUI so that
// calls to G.Log() in the daemon can be copied to us. This is
// something of a hack on the daemon side.
if !g.Env.GetDoLogForward() || cl.GetLogForward() == libcmdline.LogForwardNone {
g.Log.Debug("Disabling log forwarding")
return nil
}
protocols := []rpc.Protocol{client.NewLogUIProtocol()}
if err := client.RegisterProtocolsWithContext(protocols, g); err != nil {
return err
}
logLevel := keybase1.LogLevel_INFO
if g.Env.GetDebug() {
logLevel = keybase1.LogLevel_DEBUG
}
logClient, err := client.GetLogClient(g)
if err != nil {
return err
}
arg := keybase1.RegisterLoggerArg{
Name: "CLI client",
Level: logLevel,
}
if err := logClient.RegisterLogger(context.TODO(), arg); err != nil {
g.Log.Warning("Failed to register as a logger: %s", err)
}
return nil
}