本文整理汇总了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
}