testlog.go 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package main
  2. import (
  3. //"fmt"
  4. //"time"
  5. //"math"
  6. . "git.wecise.com/wecise/odbserver/odb"
  7. "git.wecise.com/wecise/odbserver/odb/test"
  8. "gitee.com/wecisecode/util/logger"
  9. )
  10. // CGO_ENABLED=1 go run --ldflags '-linkmode external -extldflags "-static"' testlog.go
  11. // #cgo LDFLAGS: -L/opt/odbserver/sqlite -lsqlite -ldl
  12. // #include "/opt/odbserver/sqlite/sqlite.h"
  13. // #include <stdint.h>
  14. // #include <stdlib.h>
  15. // extern int64_t uhaha_seed;
  16. // extern int64_t uhaha_ts;
  17. // void uhaha_begin_reader();
  18. // void uhaha_end_reader();
  19. func main() {
  20. //options := map[string]interface{} {"cache":odb.CacheAll}
  21. //g,err:= odb.New( options )
  22. logger.SetConsole(true)
  23. //option := &StoreOption{Cache:CacheAll}
  24. option := &Option{Cache: CacheAll, Keyspace: "ootest", DisableInitialHostLookup: true, DisableNotify: true}
  25. g, err := test.NewG(option)
  26. if err != nil {
  27. logger.Error(err.Error())
  28. } else {
  29. defer g.Close()
  30. }
  31. //logger.SetRollingDaily("C:/test/zkcron/src/test", "test.log")
  32. //logger.SetLevel(logger.DEBUG)
  33. // 测试MQL
  34. //stat, _ := g.Prepare(`select * from /system/log/rule where name='xxxx' and level=1`)
  35. //rst,meta,err := stat.Exec( "IBPS", 202301251540, "aaaaa", 6789, 1, "sahnghai", 1 )
  36. rst, meta, err := g.Query(`select * from /system/log/rule where name='xxxx' and level=1`)
  37. /*stat, _ := g.Prepare(`select * from /native/cnccbdos@202301251540 where syscode = ? and minute = ? and batchno = ?`)
  38. rst,meta,err := stat.Exec( "IBPS", 202301251540, 1 )*/
  39. /*stat, _ := g.Prepare(`update /native/cnccbdos@202301251540 set node=? where syscode = ? and minute = ? and batchno = ? and transuid= ? and appno=?`)
  40. rst,meta,err := stat.Exec( "bbbbbb", "IBPS", 202301251540, 1, "aaaaa", 1 )*/
  41. //rst,meta,err := g.Query(`insert into /native/cnccbdos@202301271540 (syscode, minute, transuid, comptime, appno, dc, batchno) values( 'IBPS', 202301251540, 'aaaaa', 6789, 1, 'sahnghai', 1)` )
  42. //rst,meta,err := g.Query(`select * from /native/cnccbdos where syscode = 'IBPS' and minute = 202301251540 and batchno = 1` )
  43. //rst,meta,err := g.Query(`update /native/cnccbdos set node='bbbbbb' where syscode = 'IBPS' and minute = 202301251540 and batchno = 1 and transuid='aaaaa' and appno=1` )
  44. //rst,meta,err := g.Query(`insert into /native/cnccbdos (syscode, minute, transuid, comptime, appno, dc) values( 'IBPS', 202301251540, 'aaaaa', 6789, 1, 'sahnghai')` )
  45. if err != nil {
  46. logger.Info("Query error:" + err.Error())
  47. logger.Warn(meta["type"])
  48. } else {
  49. logger.Info("rst ===>", rst)
  50. //logger.Error("meta ===>", meta)
  51. if meta["trace"] != nil && len(meta["trace"].([]string)) > 0 {
  52. for _, msg := range meta["trace"].([]string) {
  53. logger.Error(msg)
  54. }
  55. }
  56. logger.Warn(meta["columns"])
  57. logger.Warn(meta["params"])
  58. }
  59. }