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


Golang gou.Warnf函数代码示例

本文整理汇总了Golang中github.com/araddon/gou.Warnf函数的典型用法代码示例。如果您正苦于以下问题:Golang Warnf函数的具体用法?Golang Warnf怎么用?Golang Warnf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: mergeUvMsgs

func mergeUvMsgs(lmsgs, rmsgs []datasource.Message, lcols, rcols map[string]*expr.Column) []*datasource.ContextUrlValues {
	out := make([]*datasource.ContextUrlValues, 0)
	for _, lm := range lmsgs {
		switch lmt := lm.Body().(type) {
		case *datasource.ContextUrlValues:
			for _, rm := range rmsgs {
				switch rmt := rm.Body().(type) {
				case *datasource.ContextUrlValues:
					// for k, val := range rmt.Data {
					// 	u.Debugf("k=%v v=%v", k, val)
					// }
					newMsg := datasource.NewContextUrlValues(url.Values{})
					newMsg = reAlias(newMsg, lmt.Data, lcols)
					newMsg = reAlias(newMsg, rmt.Data, rcols)
					//u.Debugf("pre:  %#v", lmt.Data)
					//u.Debugf("post:  %#v", newMsg.Data)
					out = append(out, newMsg)
				default:
					u.Warnf("uknown type: %T", rm)
				}
			}
		default:
			u.Warnf("uknown type: %T   %T", lmt, lm)
		}
	}
	return out
}
开发者ID:schmichael,项目名称:qlbridge,代码行数:27,代码来源:source.go

示例2: Run

// Run Command
func (m *Command) Run() error {
	//defer m.Ctx.Recover()
	defer close(m.msgOutCh)

	if m.Ctx.Session == nil {
		u.Warnf("no session?")
		return fmt.Errorf("no session?")
	}

	writeContext, ok := m.Ctx.Session.(expr.ContextWriter)
	if !ok || writeContext == nil {
		u.Warnf("not ok? %T", m.Ctx.Session)
		return fmt.Errorf("No write context?")
	}

	//u.Debugf("running set? %v", m.p.Stmt.String())
	for _, col := range m.p.Stmt.Columns {
		err := evalSetExpression(col, m.Ctx.Session, col.Expr)
		if err != nil {
			u.Warnf("Could not evaluate %s", col.Expr, err)
			return err
		}
	}
	// for k, v := range m.Ctx.Session.Row() {
	// 	u.Infof("%p session? %s: %v", m.Ctx.Session, k, v.Value())
	// }
	return nil
}
开发者ID:allisonmorgan,项目名称:qlbridge,代码行数:29,代码来源:command.go

示例3: ValueTypeFromNode

// Infer Value type from Node
func ValueTypeFromNode(n Node) value.ValueType {
	switch nt := n.(type) {
	case *FuncNode:
	case *StringNode:
		return value.StringType
	case *IdentityNode:
		// ??
		return value.StringType
	case *NumberNode:
		return value.NumberType
	case *BinaryNode:
		switch nt.Operator.T {
		case lex.TokenLogicAnd, lex.TokenLogicOr:
			return value.BoolType
		case lex.TokenMultiply, lex.TokenMinus, lex.TokenAdd, lex.TokenDivide:
			return value.NumberType
		case lex.TokenModulus:
			return value.IntType
		default:
			u.Warnf("NoValueType? %T", n)
		}
	case nil:
		return value.UnknownType
	default:
		u.Warnf("NoValueType? %T", n)
	}
	return value.UnknownType
}
开发者ID:jmptrader,项目名称:qlbridge,代码行数:29,代码来源:node.go

示例4: WalkDelete

func (m *PlannerDefault) WalkDelete(p *Delete) error {
	u.Debugf("VisitDelete %+v", p.Stmt)
	conn, err := m.Ctx.Schema.Open(p.Stmt.Table)
	if err != nil {
		u.Warnf("%p no schema for %q err=%v", m.Ctx.Schema, p.Stmt.Table, err)
		return err
	}

	mutatorSource, hasMutator := conn.(schema.ConnMutation)
	if hasMutator {
		mutator, err := mutatorSource.CreateMutator(m.Ctx)
		if err != nil {
			u.Warnf("%p could not create mutator for %q err=%v", m.Ctx.Schema, p.Stmt.Table, err)
			//return nil, err
		} else {
			p.Source = mutator
			return nil
		}
	}

	deleteDs, isDelete := conn.(schema.ConnDeletion)
	if !isDelete {
		return fmt.Errorf("%T does not implement required schema.Deletion for deletions", conn)
	}
	p.Source = deleteDs
	return nil
}
开发者ID:allisonmorgan,项目名称:qlbridge,代码行数:27,代码来源:planner_mutate.go

示例5: encodeExpected

func encodeExpected(
	t *testing.T, label string, val interface{}, wantStr string, wantErr error,
) {
	var buf bytes.Buffer
	enc := NewEncoder(&buf)
	err := enc.Encode(val)
	if err != wantErr {
		if wantErr != nil {
			if wantErr == errAnything && err != nil {
				return
			}
			t.Errorf("%s: want Encode error %v, got %v", label, wantErr, err)
		} else {
			t.Errorf("%s: Encode failed: %s", label, err)
		}
	}
	if err != nil {
		return
	}
	if got := buf.String(); wantStr != got {
		u.Debugf("\n\n%s wanted: \n%s\ngot: \n%s", label, wantStr, got)
		for pos, r := range wantStr {
			if len(got)-1 <= pos {
				u.Warnf("len mismatch? %v vs %v", len(got), len(wantStr))
			} else if r != rune(got[pos]) {
				u.Warnf("mismatch at position: %v   %s!=%s", pos, string(r), string(got[pos]))
				break
			}
		}
		t.Fatalf("%s: want\n-----\n%q\n-----\nbut got\n-----\n%q\n-----\n", label, wantStr, got)
	}
}
开发者ID:postfix,项目名称:confl,代码行数:32,代码来源:encode_test.go

示例6: joinValue

func joinValue(ctx *Context, node expr.Node, msg datasource.Message) (string, bool) {

	if msg == nil {
		u.Warnf("got nil message?")
	}
	if msgReader, ok := msg.Body().(expr.ContextReader); ok {

		joinVal, ok := vm.Eval(msgReader, node)
		//u.Debugf("msg: %#v", msgReader)
		//u.Infof("evaluating: ok?%v T:%T result=%v node expr:%v", ok, joinVal, joinVal.ToString(), node.StringAST())
		if !ok {
			u.Errorf("could not evaluate: %v", msg)
			return "", false
		}
		switch val := joinVal.(type) {
		case value.StringValue:
			return val.Val(), true
		default:
			u.Warnf("unknown type? %T", joinVal)
		}
	} else {
		u.Errorf("could not convert to message reader: %T", msg.Body())
	}
	return "", false
}
开发者ID:jmptrader,项目名称:qlbridge,代码行数:25,代码来源:source.go

示例7: WalkSource

func (m *JobExecutor) WalkSource(p *plan.Source) (Task, error) {
	//u.Debugf("%p NewSource? %p", m, p)
	if len(p.Static) > 0 {
		//u.Warnf("found static source")
		static := membtree.NewStaticData("static")
		static.SetColumns(p.Cols)
		_, err := static.Put(nil, nil, p.Static)
		if err != nil {
			u.Errorf("Could not put %v", err)
		}
		return NewSourceScanner(m.Ctx, p, static), nil
	} else if p.Conn == nil {
		u.Warnf("no conn? %T", p.DataSource)
		if p.DataSource == nil {
			u.Warnf("no datasource")
			return nil, fmt.Errorf("missing data source")
		}
		source, err := p.DataSource.Open(p.Stmt.SourceName())
		if err != nil {
			return nil, err
		}
		p.Conn = source
		//u.Debugf("setting p.Conn %p %T", p.Conn, p.Conn)
	}

	e, hasSourceExec := p.Conn.(ExecutorSource)
	if hasSourceExec {
		return e.WalkExecSource(p)
	}
	return NewSource(m.Ctx, p)
}
开发者ID:allisonmorgan,项目名称:qlbridge,代码行数:31,代码来源:executor.go

示例8: expect

// Test to make sure we get what we expect.
func expect(t *testing.T, lx *lexer, items []item) {
	for i := 0; i < len(items); i++ {
		item := lx.nextItem()
		if item.typ == itemEOF {
			break
		} else if item.typ == itemError {
			t.Fatal(item.val)
		}
		if item != items[i] {
			//u.Debugf("\n\n%s wanted: \n%s\ngot: \n%s", label, wantStr, got)
			wantStr := items[i].val
			got := item.val
			for pos, r := range wantStr {
				if len(got)-1 < pos {
					u.Warnf("len mismatch? %v vs %v", len(got), len(wantStr))
				} else if r != rune(got[pos]) {
					u.Warnf("mismatch at position: %v   %q!=%q", pos, string(r), string(got[pos]))
					break
				} else {
					//u.Debugf("match at position: %v   %q=%q", pos, string(r), string(got[pos]))
				}
			}
			t.Fatalf("Testing: '%s'\nExpected %q, received %q\n",
				lx.input, items[i], item)
		}
	}
}
开发者ID:postfix,项目名称:confl,代码行数:28,代码来源:lex_test.go

示例9: keyFromWhere

func keyFromWhere(wh expr.Node) datasource.Key {
	switch n := wh.(type) {
	case *expr.SqlWhere:
		return keyFromWhere(n.Expr)
	case *expr.BinaryNode:
		if len(n.Args) != 2 {
			u.Warnf("need more args? %#v", n.Args)
			return nil
		}
		in, ok := n.Args[0].(*expr.IdentityNode)
		if !ok {
			u.Warnf("not identity? %T", n.Args[0])
			return nil
		}
		// This only allows for    identity = value
		// NOT:      identity = expr(identity, arg)
		//
		switch valT := n.Args[1].(type) {
		case *expr.NumberNode:
			return datasource.NewKeyCol(in.Text, valT.Float64)
		case *expr.StringNode:
			return datasource.NewKeyCol(in.Text, valT.Text)
		//case *expr.FuncNode:
		default:
			u.Warnf("not supported arg? %#v", valT)
		}
	default:
		u.Warnf("not supported node type? %#v", n)
	}
	return nil
}
开发者ID:schmichael,项目名称:qlbridge,代码行数:31,代码来源:mutations.go

示例10: walkMulti

// MultiNode evaluator
//
//     A   IN   (b,c,d)
//
func walkMulti(ctx expr.EvalContext, node *expr.MultiArgNode) (value.Value, bool) {

	a, aok := Eval(ctx, node.Args[0])
	//u.Infof("multi:  %T:%v  %v", a, a, node.Operator)
	if !aok {
		u.Infof("Could not evaluate args, %#v", node.Args[0])
		return value.BoolValueFalse, false
	}
	switch node.Operator.T {
	case lex.TokenIN:
		for i := 1; i < len(node.Args); i++ {
			v, ok := Eval(ctx, node.Args[i])
			if ok {
				//u.Debugf("in? %v %v", a, v)
				if eq, err := value.Equal(a, v); eq && err == nil {
					return value.NewBoolValue(true), true
				}
			} else {
				u.Warnf("could not evaluate arg: %v", node.Args[i])
			}
		}
		return value.NewBoolValue(false), true
	default:
		u.Warnf("tri node walk not implemented:   %#v", node)
	}

	return value.NewNilValue(), false
}
开发者ID:chrislusf,项目名称:qlbridge,代码行数:32,代码来源:vm.go

示例11: Check

func (c *FuncNode) Check() error {

	if len(c.Args) < len(c.F.Args) && !c.F.VariadicArgs {
		return fmt.Errorf("parse: not enough arguments for %s  supplied:%d  f.Args:%v", c.Name, len(c.Args), len(c.F.Args))
	} else if (len(c.Args) >= len(c.F.Args)) && c.F.VariadicArgs {
		// ok
	} else if len(c.Args) > len(c.F.Args) {
		u.Warnf("lenc.Args >= len(c.F.Args?  %v", (len(c.Args) >= len(c.F.Args)))
		err := fmt.Errorf("parse: too many arguments for %s want:%v got:%v   %#v", c.Name, len(c.F.Args), len(c.Args), c.Args)
		u.Errorf("funcNode.Check(): %v", err)
		return err
	}
	for i, a := range c.Args {

		if ne, isNodeExpr := a.(Node); isNodeExpr {
			if err := ne.Check(); err != nil {
				return err
			}
		} else if _, isValue := a.(value.Value); isValue {
			// TODO: we need to check co-ercion here, ie which Args can be converted to what types
			if nodeVal, ok := a.(NodeValueType); ok {
				// For Env Variables, we need to Check those (On Definition?)
				if c.F.Args[i].Kind() != nodeVal.Type().Kind() {
					u.Errorf("error in parse Check(): %v", a)
					return fmt.Errorf("parse: expected %v, got %v    ", nodeVal.Type().Kind(), c.F.Args[i].Kind())
				}
			}
		} else {
			u.Warnf("Unknown type for func arg %T", a)
			return fmt.Errorf("Unknown type for func arg %T", a)
		}
	}
	return nil
}
开发者ID:allisonmorgan,项目名称:qlbridge,代码行数:34,代码来源:node.go

示例12: createSchema

// Create a source schema from given named source
//  we will find Source for that name and introspect
func createSchema(sourceName string) (*schema.Schema, bool) {

	sourceName = strings.ToLower(sourceName)
	ss := schema.NewSchemaSource(sourceName, sourceName)

	ds := registry.Get(sourceName)
	if ds == nil {
		parts := strings.SplitN(sourceName, "://", 2)
		//u.Infof("parts: %d   %v", len(parts), parts)
		if len(parts) == 2 {
			ds = registry.Get(parts[0])
			if ds == nil {
				//return &qlbConn{schema: s, connInfo: parts[1]}, nil
				u.Warnf("not able to find schema %q", sourceName)
				return nil, false
			}
		} else {
			//u.WarnT(7)
			u.Warnf("not able to find schema %q", sourceName)
			return nil, false
		}
	}

	u.Infof("reg p:%p source=%q  ds %#v tables:%v", registry, sourceName, ds, ds.Tables())
	ss.DS = ds
	schema := schema.NewSchema(sourceName)
	ss.Schema = schema
	u.Debugf("schema:%p ss:%p createSchema(%q) NEW ", schema, ss, sourceName)

	loadSchema(ss)

	return schema, true
}
开发者ID:allisonmorgan,项目名称:qlbridge,代码行数:35,代码来源:sourceregistry.go

示例13: ValueTypeFromNode

// Infer Value type from Node
func ValueTypeFromNode(n Node) value.ValueType {
	switch nt := n.(type) {
	case *FuncNode:
		return value.UnknownType
	case *StringNode:
		return value.StringType
	case *IdentityNode:
		// ??
		return value.StringType
	case *NumberNode:
		return value.NumberType
	case *BinaryNode:
		switch nt.Operator.T {
		case lex.TokenLogicAnd, lex.TokenLogicOr, lex.TokenEqual, lex.TokenEqualEqual:
			return value.BoolType
		case lex.TokenMultiply, lex.TokenMinus, lex.TokenAdd, lex.TokenDivide:
			return value.NumberType
		case lex.TokenModulus:
			return value.IntType
		case lex.TokenLT, lex.TokenLE, lex.TokenGT, lex.TokenGE:
			return value.BoolType
		default:
			//u.LogTracef(u.WARN, "hello")
			u.Warnf("NoValueType? %T  %#v", n, n)
		}
	case nil:
		return value.UnknownType
	default:
		u.Warnf("NoValueType? %T", n)
	}
	return value.UnknownType
}
开发者ID:allisonmorgan,项目名称:qlbridge,代码行数:33,代码来源:node.go

示例14: upsertSource

func upsertSource(ctx *Context, table string) (schema.ConnUpsert, error) {

	conn, err := ctx.Schema.Open(table)
	if err != nil {
		u.Warnf("%p no schema for %q err=%v", ctx.Schema, table, err)
		return nil, err
	}

	mutatorSource, hasMutator := conn.(schema.ConnMutation)
	if hasMutator {
		mutator, err := mutatorSource.CreateMutator(ctx)
		if err != nil {
			u.Warnf("%p could not create mutator for %q err=%v", ctx.Schema, table, err)
			//return nil, err
		} else {
			return mutator, nil
		}
	}

	upsertDs, isUpsert := conn.(schema.ConnUpsert)
	if !isUpsert {
		return nil, fmt.Errorf("%T does not implement required schema.Upsert for upserts", conn)
	}
	return upsertDs, nil
}
开发者ID:allisonmorgan,项目名称:qlbridge,代码行数:25,代码来源:planner_mutate.go

示例15: rewriteNode

func rewriteNode(from *SqlSource, isLeft bool, node Node) Node {
	switch nt := node.(type) {
	case *IdentityNode:
		if left, right, ok := nt.LeftRight(); ok {
			//u.Debugf("rewriteNode   isLeft?%v from.Name:%v l:%v  r:%v", isLeft, from.alias, left, right)
			if left == from.alias {
				in := IdentityNode{Text: right}
				//u.Warnf("nice, found it! in = %v", in)
				return &in
			}
		}
	case *BinaryNode:
		switch nt.Operator.T {
		case lex.TokenAnd, lex.TokenLogicAnd, lex.TokenLogicOr:
			n1 := rewriteNode(from, isLeft, nt.Args[0])
			n2 := rewriteNode(from, isLeft, nt.Args[1])
			return &BinaryNode{Operator: nt.Operator, Args: [2]Node{n1, n2}}
		case lex.TokenEqual, lex.TokenEqualEqual:
			n := rewriteNode(from, isLeft, nt.Args[0])
			if n != nil {
				return n
			}
			n = rewriteNode(from, isLeft, nt.Args[1])
			if n != nil {
				return n
			}
			u.Warnf("Could not find node: %#v", node)
		default:
			u.Warnf("un-implemented op: %v", nt.Operator)
		}
	default:
		u.Warnf("%T node types are not suppored yet for join rewrite", node)
	}
	return nil
}
开发者ID:chrislusf,项目名称:qlbridge,代码行数:35,代码来源:sql.go


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