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


Golang Task.Event方法代码示例

本文整理汇总了Golang中github.com/BellerophonMobile/logberry.Task.Event方法的典型用法代码示例。如果您正苦于以下问题:Golang Task.Event方法的具体用法?Golang Task.Event怎么用?Golang Task.Event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/BellerophonMobile/logberry.Task的用法示例。


在下文中一共展示了Task.Event方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: LogCommandLine

// CommandLineEvent generates a configuration log event for the given
// Task reporting the command line used to execute the currently
// executing process.
func LogCommandLine(main *logberry.Task) error {

	hostname, err := os.Hostname()
	if err != nil {
		return logberry.WrapError("Could not retrieve hostname", err)
	}

	u, err := user.Current()
	if err != nil {
		return logberry.WrapError("Could not retrieve user info", err)
	}

	dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
	if err != nil {
		return logberry.WrapError("Could not retrieve program path", err)
	}

	prog := path.Base(os.Args[0])

	d := logberry.D{
		"Host":    hostname,
		"User":    u.Username,
		"Path":    dir,
		"Program": prog,
		"Args":    os.Args[1:],
	}

	main.Event(logberry.CONFIGURATION, "Command line", d)

	return nil

}
开发者ID:BellerophonMobile,项目名称:logberry,代码行数:35,代码来源:EnvironmentEvent.go

示例2: LogProcess

// ProcessEvent generates a configuration log event for the given Task
// reporting identifiers for the currently executing process.
func LogProcess(main *logberry.Task) error {

	hostname, err := os.Hostname()
	if err != nil {
		return logberry.WrapError("Could not retrieve hostname", err)
	}

	wd, err := os.Getwd()
	if err != nil {
		return logberry.WrapError("Could not retrieve working dir", err)
	}

	u, err := user.Current()
	if err != nil {
		return logberry.WrapError("Could not retrieve user info", err)
	}

	d := logberry.D{
		"Host": hostname,
		"WD":   wd,
		"UID":  u.Uid,
		"User": u.Username,
		"PID":  os.Getpid(),
	}

	main.Event(logberry.CONFIGURATION, "Process", d)

	return nil

}
开发者ID:BellerophonMobile,项目名称:logberry,代码行数:32,代码来源:EnvironmentEvent.go

示例3: LogEnvironment

// EnvironmentEvent generates a configuration log event for the given
// Task reporting the current operating system host environment
// variables of the currently executing process.
func LogEnvironment(main *logberry.Task) {

	d := logberry.D{}
	for _, e := range os.Environ() {
		pair := strings.Split(e, "=")
		d[pair[0]] = pair[1]
	}

	main.Event(logberry.CONFIGURATION, "Environment", d)

}
开发者ID:BellerophonMobile,项目名称:logberry,代码行数:14,代码来源:EnvironmentEvent.go

示例4: LogVersion

func LogVersion(main *logberry.Task, data ...interface{}) {
	main.Event(logberry.CONFIGURATION, "Version", data...)
}
开发者ID:BellerophonMobile,项目名称:logberry,代码行数:3,代码来源:EnvironmentEvent.go

示例5: LogConfiguration

// ConfigurationEvent generates a configuration log event for the
// given Task reporting parameters or other initialization data.  The
// variadic data parameter is aggregated as a D and reporting with the
// event, as is the data permanently associated with the Task.  The
// given data is not associated to the Task permanently.
func LogConfiguration(main *logberry.Task, data ...interface{}) {
	main.Event(logberry.CONFIGURATION, "Configuration", data...)
}
开发者ID:BellerophonMobile,项目名称:logberry,代码行数:8,代码来源:EnvironmentEvent.go

示例6: LogBuildSignature

// BuildSignatureEvent generates a configuration log event for the
// given Task reporting build configuration, as captured by the given
// string.  A utility script to generate such metadata automatically
// is in the util/ folder of the Logberry repository.  It can be
// useful to use this string rather than a BuildMetadata object so
// that it can be passed in through the standard go tools command
// line, i.e., via linker flags.
func LogBuildSignature(main *logberry.Task, build string) {
	main.Event(logberry.CONFIGURATION, "Build signature", logberry.D{"Signature": build})
}
开发者ID:BellerophonMobile,项目名称:logberry,代码行数:10,代码来源:EnvironmentEvent.go

示例7: LogBuildMetadata

// BuildMetadataEvent generates a configuration log event for the
// given Task reporting the build configuration, as captured by the
// passed object.  A utility script to generate such metadata
// automatically is in the util/ folder of the Logberry repository.
func LogBuildMetadata(main *logberry.Task, build *BuildMetadata) {
	main.Event(logberry.CONFIGURATION, "Build metadata", build)
}
开发者ID:BellerophonMobile,项目名称:logberry,代码行数:7,代码来源:EnvironmentEvent.go


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