本文整理匯總了Golang中github.com/Centny/gwf/log.D函數的典型用法代碼示例。如果您正苦於以下問題:Golang D函數的具體用法?Golang D怎麽用?Golang D使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了D函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Notify
func (c *Client) Notify(hs *routing.HTTPSession) routing.HResult {
log.D("Notify->%v", "xxx")
var addr = hs.R.Header.Get("X-Real-IP")
if len(addr) < 1 {
addr = hs.R.RemoteAddr
}
hs.R.ParseForm()
var vals = hs.R.Form
var sign, sign_type = vals.Get("sign"), vals.Get("sign_type")
vals.Del("sign")
vals.Del("sign_type")
var data = vals.Encode()
data, _ = url.QueryUnescape(data)
var err = c.Web.Verify(data, sign, sign_type)
if err != nil {
log.W("Client.Notify recieve bad request from address(%v),err:%v->\nsign_type=%v&sign=%v&%v", addr, err, sign_type, sign, data)
hs.W.WriteHeader(400)
hs.W.Write([]byte(err.Error()))
return routing.HRES_RETURN
}
log.D("Client.Notify receive verify request from address(%v) by args:\nsign_type=%v&sign=%v&%v\n<-", addr, sign_type, sign, data)
err = c.H.OnNotify(c, hs)
if err == nil {
hs.W.Write([]byte("success"))
} else {
log.W("Client.Notify call on notify fail with error(%v)", err)
hs.W.WriteHeader(400)
hs.W.Write([]byte(err.Error()))
}
return routing.HRES_RETURN
}
示例2: LoopPing
func (m *MDbs) LoopPing() {
log.D("MDbs loop ping is started...")
for m.Running {
for _, mdb := range m.Dbs {
if mdb.ping < 1 {
mdb.ping = 1
go mdb.TPing()
}
}
time.Sleep(time.Duration(m.Delay) * time.Millisecond)
}
log.D("MDbs loop ping is stopped...")
}
示例3: Create
func (s *SQL_H) Create() (interface{}, error) {
log.D("SQL_H start connect to %v", s)
db, err := sql.Open(s.Driver, s.Url)
if err == nil {
db.SetMaxIdleConns(s.Idle)
db.SetMaxOpenConns(s.Max)
log.D("SQL_H connect to %v success", s)
return db, nil
} else {
log.D("SQL_H connect to %v error->%v", s, err)
return nil, err
}
}
示例4: InsertTx
func InsertTx(tx *sql.Tx, o interface{}, tableName string) (int64, error) {
dfs := parseToDbfield(o)
s := bytes.Buffer{}
s.WriteString("insert into ")
s.WriteString(tableName)
s.WriteString("(")
s.WriteString(selectColumn(dfs))
s.WriteString(")values(")
s.WriteString(placeholders(dfs))
s.WriteString(")")
log.D("sql:%v", s.String())
log.D("args:%v", args(dfs))
return dbutil.DbInsert2(tx, s.String(), args(dfs))
}
示例5: Insert
func Insert(o DbModel) (int64, error) {
dfs := parseToDbfield(o)
s := bytes.Buffer{}
s.WriteString("insert into ")
s.WriteString(o.GetTableName())
s.WriteString("(")
s.WriteString(selectColumn(dfs))
s.WriteString(")values(")
s.WriteString(placeholders(dfs))
s.WriteString(")")
log.D("sql:%v", s.String())
log.D("args:%v", args(dfs))
return dbutil.DbInsert(DbConn(), s.String(), args(dfs))
}
示例6: dbQueryStruct
func dbQueryStruct(db *sql.DB, res interface{}, query string, args ...interface{}) error {
rows, err := db.Query(query, args...)
if err != nil {
return err
}
cols, err := rows.Columns()
if err != nil {
return err
}
rval := reflect.ValueOf(res).Elem()
rtype := rval.Type()
pls := []interface{}{}
for _, col := range cols {
for i := 0; i < rtype.NumField(); i++ {
if rtype.Field(i).Tag.Get("m2s") == col {
pls = append(pls, rval.Field(i).Addr().Interface())
}
}
}
log.D("query:%v \n pls:%v", query, pls)
if rows.Next() {
return rows.Scan(pls...)
}
return sql.ErrNoRows
}
示例7: UpdateBankPaper
func UpdateBankPaper(rc *impl.RCM_Cmd) (interface{}, error) {
var uid, bankId int64
var paperIds, p2bIds, ext string
err := rc.ValidF(`
uid,R|I,R:0;
bankId,R|I,R:0;
paperIds,R|S,L:0;
p2bIds,O|S,L:0;
ext,O|S,L:0;
`, &uid, &bankId, &paperIds, &p2bIds, &ext)
if err != nil {
log.E("UpdateBankPaper arg err:%v", err)
return 0, err
}
extParse := []P2b_Paper{}
json.Unmarshal([]byte(ext), &extParse)
rs := []P2b_Paper{}
paperIdsArr := []int64{}
err = json.Unmarshal([]byte(paperIds), &paperIdsArr)
if err != nil {
return nil, err
}
if p2bIds == "" {
p2bIds = "0"
}
sql_ := "delete from ebs_p2b where bank_id=? and tid not in (" + p2bIds + ")"
var conn *sql.DB = dbMgr.DbConn()
tx, err := conn.Begin()
if err != nil {
return nil, err
}
//同步練習
for _, v := range extParse {
fmt.Println(tx.Exec("insert into ebs_p2b (tid,bank_id,paper_id,status,add1) values (?,?,?,'N','P')", v.P2bId, bankId, v.PId))
}
//同步練習
if ext != "" {
sql_ += " and add1='P'"
} else {
sql_ += " and (add1!='P' or add1 is null)"
}
log.D("%s", sql_)
if _, err := tx.Exec(sql_, bankId); err != nil {
tx.Rollback()
return nil, err
}
for _, v := range paperIdsArr {
if res, err := tx.Exec("insert into ebs_p2b (bank_id,paper_id,status) values (?,?,'N')", bankId, v); err != nil {
tx.Rollback()
return nil, err
} else {
p2bId, _ := res.LastInsertId()
rs = append(rs, P2b_Paper{p2bId, v})
}
}
return rs, tx.Commit()
}
示例8: CreateBank
func CreateBank(rc *impl.RCM_Cmd) (interface{}, error) {
log.D("rc CreateBank")
var uid int64
var uname string
var bName string
err := rc.ValidF(`
uid,R|I,R:0;
uname,R|S,L:0;
bName,R|S,L:0;
`, &uid, &uname, &bName)
if err != nil {
log.E("CreateBank arg err:%v", err)
return 0, err
}
b := &bank.BANK{}
b.UId = &uid
b.Name = &bName
b.UName = &uname
b.Status = bank.GetString("N")
b.Public = bank.GetInt(1)
if n, err := b.C(nil); err != nil {
log.E("CreateBank err:%v", err)
return 0, err
} else {
return n, nil
}
}
示例9: Create
func (m *MGO_H) Create() (interface{}, error) {
if len(m.Url) < 1 || len(m.Name) < 1 {
return nil, util.Err("the database con/name is empty")
}
log.D("MGO_H start dail to %v", m)
ss, err := tmgo.Dial(m.Url)
if err == nil {
log.D("MGO_H dail to %v success", m)
return ss.DB(m.Name), nil
}
log.D("MGO_H dail to %v error->%v", m, err)
if ss != nil {
ss.Close()
}
return nil, err
}
示例10: CallC
func CallC(rc *impl.RCM_Cmd) (interface{}, error) {
var cid = rc.Kvs().StrVal("cid")
log.D("run_rc_s doing call_c by cid(%v)", cid)
var cmd = rcs.CmdC(cid)
if cmd == nil {
return util.Map{
"code": -1,
"err": "not found",
}, nil
}
var name = rc.StrVal("name")
var args = rc.MapVal("args")
log.D("run_rc_s call client by name(%v),args(%v)", name, util.S2Json(args))
var res, err = cmd.Exec_m(name, args)
log.D("run_rc_s call client result->%v", util.S2Json(res))
return res, err
}
示例11: RunFFCM_S_V
func RunFFCM_S_V(fcfg *util.Fcfg) error {
if SRV == nil {
return util.Err("server is not running")
}
var listen = fcfg.Val("listen")
SRV.Hand("", routing.Shared)
routing.Shared.Print()
log.D("listen web server on %v", listen)
return routing.ListenAndServe(listen)
}
示例12: ChkIdx
func ChkIdx(C func(string) *tmgo.Collection, indexes map[string]map[string]tmgo.Index) error {
for cname, index := range indexes {
tc := C(cname)
if _, err := tc.Count(); err != nil {
return err
}
log.D("ChkIdx checking index on collection(%v)...", cname)
idx_l, err := tc.Indexes()
if err != nil {
if qerr, ok := err.(*tmgo.QueryError); !ok || qerr.Code != 26 {
err = util.Err("ChkIdx list indexes fail with error(%v) on collection(%v)", err, cname)
log.E("%v", err)
return err
}
log.D("ChkIdx the collection(%v) is not found, it will create empty one...", cname)
err = tc.Create(&tmgo.CollectionInfo{})
if err != nil {
err = util.Err("ChkIdx create collection(%v) fail with error(%v)", cname, err)
log.E("%v", err)
return err
}
}
exists := map[string]tmgo.Index{}
for _, idx := range idx_l {
exists[idx.Name] = idx
}
for iname, idx := range index {
if _, ok := exists[iname]; ok {
continue
}
idx.Name = iname
err = C(cname).EnsureIndex(idx)
if err != nil {
err = util.Err("ChkIdx ensure index by keys(%v),name(%v) fail with error(%v) on collection(%v)", idx.Key, idx.Name, err, cname)
log.E("%v", err)
return err
}
log.D("ChkIdx ensure index(%v) on collection(%v) success", iname, cname)
}
}
return nil
}
示例13: tsql2
func tsql2() {
db, err := vsql.Open("mysql", "cny:[email protected](127.0.0.1:3306)/test?charset=utf8&loc=Local")
if err != nil {
panic(err.Error())
}
for {
_, err := dbutil.DbQueryInt(db, "select 1")
log.D("%v", err)
time.Sleep(time.Second)
}
}
示例14: TPing
func (m *MDb) TPing() {
var showlog = ShowLog && (util.Now()-m.log_time > ShowLogTime)
if showlog {
m.log_time = util.Now()
log.D("MDb start ping to %v ", m.String())
}
err := m.H.Ping(m.DB)
if err == nil || err.Error() != "Closed explicitly" {
if err == nil {
if showlog {
log.D("MDb ping to %v success", m.String())
}
} else {
log.E("MDb ping to %v error->%v, will mark to not active", m.String(), err)
}
m.lck.Lock()
m.Active = err == nil
m.ping = 0
m.lck.Unlock()
return
}
// m.H.Close(m.DB)
//do reconnect
log.E("MDb ping to %v error->%v, will try reconnect", m.String(), err)
for {
db, err := m.H.Create()
if err == nil {
log.D("MDb connect to %v success, will mark to active", m.String())
m.lck.Lock()
m.DB = db
m.ping = 0
m.Active = true
m.lck.Unlock()
break
} else {
log.E("MDb connect to %v error->%v, will retry after 5s", m.String(), err)
time.Sleep(5 * time.Second)
}
}
}
示例15: run
func run(args []string) {
defer StopSrv()
mux := http.NewServeMux()
mux.Handle("/jsup/", NewSrvMux("/jsup", "www"))
log.D("running server on %v", "7899")
s = http.Server{Addr: ":7899", Handler: mux}
err := s.ListenAndServe()
if err != nil {
fmt.Println(err)
}
// lock.Done()
}