本文整理汇总了Golang中github.com/araddon/gou.Infof函数的典型用法代码示例。如果您正苦于以下问题:Golang Infof函数的具体用法?Golang Infof怎么用?Golang Infof使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Infof函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestParseExpressions
func TestParseExpressions(t *testing.T) {
for _, test := range parseTests {
exprTree, err := expr.ParseExpression(test.qlText)
//u.Infof("After Parse: %v", err)
switch {
case err == nil && !test.ok:
t.Errorf("%q: 1 expected error; got none", test.name)
continue
case err != nil && test.ok:
t.Errorf("%q: 2 unexpected error: %v", test.name, err)
continue
case err != nil && !test.ok:
// expected error, got one
if *VerboseTests {
u.Infof("%s: %s\n\t%s", test.name, test.qlText, err)
}
continue
}
var result string
result = exprTree.Root.StringAST()
if result != test.result {
t.Errorf("reslen: %v vs %v", len(result), len(test.result))
t.Errorf("\n%s \n\t'%v'\nexpected\n\t'%v'", test.name, result, test.result)
}
}
}
示例2: Run
func (m *DeletionScanner) Run(context *expr.Context) error {
defer context.Recover()
defer close(m.msgOutCh)
u.Infof("In Delete Scanner expr %#v", m.sql.Where)
select {
case <-m.SigChan():
return nil
default:
if m.sql.Where != nil {
// Hm, how do i evaluate here? Do i need a special Vm?
//return fmt.Errorf("Not implemented delete vm")
deletedCt, err := m.db.DeleteExpression(m.sql.Where)
if err != nil {
u.Errorf("Could not put values: %v", err)
return err
}
m.deleted = deletedCt
vals := make([]driver.Value, 2)
vals[0] = int64(0)
vals[1] = int64(deletedCt)
m.msgOutCh <- &datasource.SqlDriverMessage{vals, 1}
}
}
return nil
}
示例3: ToFloat64
// toFloat64 convert all reflect.Value-s into float64.
func ToFloat64(v reflect.Value) float64 {
if v.Kind() == reflect.Interface {
v = v.Elem()
}
switch v.Kind() {
case reflect.Float32, reflect.Float64:
return v.Float()
case reflect.Int16, reflect.Int8, reflect.Int, reflect.Int32, reflect.Int64:
return float64(v.Int())
case reflect.String:
s := v.String()
var f float64
var err error
if strings.HasPrefix(s, "0x") {
f, err = strconv.ParseFloat(s, 64)
} else {
f, err = strconv.ParseFloat(s, 64)
}
if err == nil {
return float64(f)
}
case reflect.Slice:
// Should we grab first one?
item1 := v.Index(0)
u.Infof("is slice of strings?: %T", v, item1)
default:
u.Warnf("Cannot convert type? %v", v.Kind())
}
return math.NaN()
}
示例4: walkUnary
func walkUnary(ctx expr.EvalContext, node *expr.UnaryNode) (value.Value, bool) {
a, ok := Eval(ctx, node.Arg)
if !ok {
u.Infof("whoops, %#v", node)
return a, false
}
switch node.Operator.T {
case lex.TokenNegate:
switch argVal := a.(type) {
case value.BoolValue:
//u.Infof("found urnary bool: res=%v expr=%v", !argVal.v, node.StringAST())
return value.NewBoolValue(!argVal.Val()), true
default:
//u.Errorf("urnary type not implementedUnknonwn node type: %T", argVal)
panic(ErrUnknownNodeType)
}
case lex.TokenMinus:
if an, aok := a.(value.NumericValue); aok {
return value.NewNumberValue(-an.Float()), true
}
default:
u.Warnf("urnary not implemented: %#v", node)
}
return value.NewNilValue(), false
}
示例5: LoadConn
func (m *Source) LoadConn() error {
//u.Debugf("LoadConn() nil?%v", m.Conn == nil)
if m.Conn != nil {
return nil
}
if m.DataSource == nil {
// Not all sources require a source, ie literal queries
// and some, information schema, or fully qualifyied schema queries
// requires schema switching
if m.IsSchemaQuery() && m.ctx != nil {
m.ctx.Schema = m.ctx.Schema.InfoSchema
u.Infof("switching to info schema")
if err := m.load(); err != nil {
u.Errorf("could not load schema? %v", err)
return err
}
if m.DataSource == nil {
return u.LogErrorf("could not load info schema source %v", m.Stmt)
}
} else {
u.Debugf("return bc no datasource ctx=nil?%v schema?%v", m.ctx == nil, m.IsSchemaQuery())
return nil
}
}
source, err := m.DataSource.Open(m.Stmt.SourceName())
if err != nil {
return err
}
m.Conn = source
return nil
}
示例6: testSubselect
// sub-select not implemented in exec yet
func testSubselect(t *testing.T) {
sqlText := `
select
user_id, email
FROM users
WHERE user_id in
(select user_id from orders)
`
job, err := BuildSqlJob(rtConf, "mockcsv", sqlText)
assert.Tf(t, err == nil, "no error %v", err)
//writeCtx := NewContextSimple()
msgs := make([]datasource.Message, 0)
go func() {
outChan := job.DrainChan()
for msg := range outChan {
u.Infof("msg: %v", msg)
msgs = append(msgs, msg)
}
}()
err = job.Run()
time.Sleep(time.Millisecond * 30)
assert.Tf(t, err == nil, "no error %v", err)
assert.Tf(t, len(msgs) == 1, "should have filtered out 2 messages")
}
示例7: 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
}
示例8: TestWithJson
func TestWithJson(t *testing.T) {
// This is obviously not exactly sql standard
// but is nice for proxy's
sql := `
SELECT id, name FROM user
WITH {
"key":"value2"
,"keyint":45,
"keyfloat":55.5,
"keybool": true,
"keyarraymixed":["a",2,"b"],
"keyarrayobj":[
{"hello":"value","age":55},
{"hello":"value","age":55}
],
"keyobj":{"hello":"value","age":55},
"keyobjnested":{
"hello":"value",
"array":[
"a",
2,
"b"
]
}
}
`
req, err := ParseSql(sql)
assert.Tf(t, err == nil && req != nil, "Must parse: %s \n\t%v", sql, err)
sel, ok := req.(*SqlSelect)
assert.Tf(t, ok, "is SqlSelect: %T", req)
assert.Tf(t, len(sel.From) == 1 && sel.From[0].Name == "user", "has 1 from: %v", sel.From)
assert.Tf(t, len(sel.With) == 8, "has with: %v", sel.With)
assert.Tf(t, len(sel.With.Helper("keyobj")) == 2, "has 2obj keys: %v", sel.With.Helper("keyobj"))
u.Infof("sel.With: \n%s", sel.With.PrettyJson())
}
示例9: Table
func (m *SourceSchema) Table(tableName string) (*Table, error) {
tbl, ok := m.tableMap[tableName]
if ok && tbl != nil {
return tbl, nil
} else if ok && tbl == nil {
u.Infof("try to get table from source schema %v", tableName)
if sourceTable, ok := m.DS.(SchemaProvider); ok {
tbl, err := sourceTable.Table(tableName)
if err == nil {
m.AddTable(tbl)
}
return tbl, err
}
}
if tbl != nil && !tbl.Current() {
// What?
if sourceTable, ok := m.DS.(SchemaProvider); ok {
tbl, err := sourceTable.Table(tableName)
if err == nil {
m.AddTable(tbl)
}
return tbl, err
}
}
return nil, fmt.Errorf("Could not find that table: %v", tableName)
}
示例10: 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
}
示例11: RunKafkaConsumer
func RunKafkaConsumer(msgChan chan *loges.LineEvent, partitionstr, topic, kafkaHost string, offset, maxMsgCt uint64, maxSize uint) {
var broker *kafka.BrokerConsumer
u.Infof("Connecting to host=%s topic=%s part=%s", kafkaHost, topic, partitionstr)
parts := strings.Split(partitionstr, ",")
if len(parts) > 1 {
tps := kafka.NewTopicPartitions(topic, partitionstr, offset, uint32(maxSize))
broker = kafka.NewMultiConsumer(kafkaHost, tps)
} else {
partition, _ := strconv.Atoi(partitionstr)
broker = kafka.NewBrokerConsumer(kafkaHost, topic, partition, offset, uint32(maxSize))
}
var msgCt int
done := make(chan bool, 1)
kafkaMsgs := make(chan *kafka.Message)
go broker.ConsumeOnChannel(kafkaMsgs, 1000, done)
for msg := range kafkaMsgs {
if msg != nil {
msgCt++
if uint64(msgCt) > maxMsgCt {
panic("ending")
}
//msg.Print()
msgChan <- &loges.LineEvent{Data: msg.Payload(), Offset: msg.Offset(), Item: msg}
} else {
u.Error("No kafka message?")
break
}
}
}
示例12: loadTable
func (m *MockCsvSource) loadTable(tableName string) error {
csvRaw, ok := m.raw[tableName]
if !ok {
return schema.ErrNotFound
}
sr := strings.NewReader(csvRaw)
u.Debugf("mockcsv:%p load mockcsv: %q data:%v", m, tableName, csvRaw)
csvSource, _ := datasource.NewCsvSource(tableName, 0, sr, make(<-chan bool, 1))
tbl := membtree.NewStaticData(tableName)
u.Infof("loaded columns %v", csvSource.Columns())
tbl.SetColumns(csvSource.Columns())
//u.Infof("set index col for %v: %v -- %v", tableName, 0, csvSource.Columns()[0])
m.tables[tableName] = tbl
// Now we are going to page through the Csv rows and Put into
// Static Data Source, ie copy into memory btree structure
for {
msg := csvSource.Next()
if msg == nil {
//u.Infof("table:%v len=%v", tableName, tbl.Length())
return nil
}
dm, ok := msg.Body().(*datasource.SqlDriverMessageMap)
if !ok {
return fmt.Errorf("Expected *datasource.SqlDriverMessageMap but got %T", msg.Body())
}
// We don't know the Key
tbl.Put(nil, nil, dm.Values())
}
return nil
}
示例13: TestPlans
func TestPlans(t *testing.T) {
for _, pt := range planTests {
ctx := td.TestContext(pt.q)
u.Infof("running %s for plan check", pt.q)
p := selectPlan(t, ctx)
assert.T(t, p != nil)
u.Infof("%#v", ctx.Projection)
u.Infof("cols %#v", ctx.Projection)
if pt.cols > 0 {
// ensure our projection has these columns
assert.Tf(t, len(ctx.Projection.Proj.Columns) == pt.cols,
"expected %d cols got %v %#v", pt.cols, len(ctx.Projection.Proj.Columns), ctx.Projection.Proj)
}
}
}
示例14: LoadTestDataOnce
func LoadTestDataOnce() {
loadData.Do(func() {
// Load in a "csv file" into our mock data store
u.Infof("about to load table?")
mockcsv.LoadTable("users", `user_id,email,interests,reg_date,referral_count
9Ip1aKbeZe2njCDM,"[email protected]","fishing","2012-10-17T17:29:39.738Z",82
hT2impsOPUREcVPc,"[email protected]","swimming","2009-12-11T19:53:31.547Z",12
hT2impsabc345c,"not_an_email","swimming","2009-12-11T19:53:31.547Z",12`)
u.Infof("after load users table")
mockcsv.LoadTable("orders", `order_id,user_id,item_id,price,order_date,item_count
1,9Ip1aKbeZe2njCDM,1,22.50,"2012-12-24T17:29:39.738Z",82
2,9Ip1aKbeZe2njCDM,2,37.50,"2013-10-24T17:29:39.738Z",82
3,abcabcabc,1,22.50,"2013-10-24T17:29:39.738Z",82
`)
})
}
示例15: NewGraphiteRunner
func NewGraphiteRunner(addr string) *GraphiteRunner {
conn, err := net.Dial("tcp", addr)
if err != nil {
u.Errorf("Failed to connect to graphite/carbon: %+v", err)
} else {
u.Infof("Connected graphite to %v", addr)
}
return &GraphiteRunner{conn: conn}
}