Exemple #1
0
func (this *SimpleFormater) Format(level int, msg []byte) []byte {
	lm, ok := logLevels[level]
	if !ok {
		lm = "-"
	}
	return misc.AppendBytes(
		[]byte("["),
		[]byte(lm),
		[]byte("]\t"),
		[]byte("["),
		[]byte(time.Now().Format(misc.TimeGeneralLayout())),
		[]byte("]\t"),
		msg,
		[]byte("\n"),
	)
}
Exemple #2
0
func RunCmd(cmdStr string) *ShellResult {
	result := &ShellResult{
		Ok: true,
	}

	var err error

	cmd := NewCmd(cmdStr)
	result.Output, err = cmd.CombinedOutput()

	if err != nil {
		result.Ok = false
		result.Output = misc.AppendBytes(result.Output, []byte(err.Error()))
	}
	return result
}
Exemple #3
0
func afterAction(context *controller.Context, args []string) {
	context.RespBody = misc.AppendBytes(context.RespBody, []byte("after "+args[0]+"\n"))

	context.TransData["after"] = "after"
}
Exemple #4
0
func regexAction(context *controller.Context, args []string) {
	context.RespBody = misc.AppendBytes(context.RespBody, []byte(" regex id = "+args[0]+" "))
}
Exemple #5
0
func exactAction(context *controller.Context, args []string) {
	context.RespBody = misc.AppendBytes(context.RespBody, []byte(" exact "))
}
Exemple #6
0
func afterAction(context *controller.Context, args []string) {
	context.RespBody = misc.AppendBytes(context.RespBody, []byte("after\n"))
}