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


Golang CommandLine.GetLogForward方法代码示例

本文整理汇总了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)
}
开发者ID:mark-adams,项目名称:client,代码行数:22,代码来源:main.go

示例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
}
开发者ID:Varjelus,项目名称:keybase-client,代码行数:38,代码来源:main.go


注:本文中的github.com/keybase/client/go/libcmdline.CommandLine.GetLogForward方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。