本文整理匯總了Golang中github.com/nwaycn/Nway_ac2/ac/nway-util/logger.Error函數的典型用法代碼示例。如果您正苦於以下問題:Golang Error函數的具體用法?Golang Error怎麽用?Golang Error使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Error函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Load
func (this *NwayConfig) Load() bool {
conf, result := SetConfig("conf.ini")
if result == false {
logger.Debug("load the config file failed")
return false
}
this.Dbconf.ConnString, result = conf.GetValue("database", "connstring")
if result == false {
logger.Error("load database connect string failed")
return false
}
this.Fsconf.FsHost, result = conf.GetValue("freeswitch", "host")
if result == false {
logger.Error("load freeswitch host string failed")
return false
}
this.Fsconf.FsAuth, result = conf.GetValue("freeswitch", "auth")
if result == false {
logger.Error("load freeswitch auth string failed")
return false
}
this.Fsconf.FsPort = conf.GetInt("freeswitch", "port", 8021)
this.Fsconf.FsTimeout = conf.GetInt("freeswitch", "timeout", 500)
this.Fsoutboundconf.ObPort, result = conf.GetValue("freeswitch", "outboundport")
this.Fsoutboundconf.ObPPort, result = conf.GetValue("freeswitch", "pub-outboundport")
return true
}
示例2: GetExtId
func (d *DbExtension) GetExtId(ext string, call_numberid int64) (int64, bool) {
var extid int64
sqlstr := "SELECT a.id FROM nway_callout_extensions a,nway_callout_numbers b " +
" where a.extension_number='" + ext +
"' and a.domain_id=b.domain_id and b.id=" +
strconv.FormatInt(call_numberid, 10)
rows, bOp := d.dbbase.Query(sqlstr)
if bOp == false {
logger.Error("query the data failed ")
rows.Close()
return 0, false
}
defer rows.Close()
for rows.Next() {
err := rows.Scan(&extid)
if err != nil {
logger.Error("scan the data error,", err)
return 0, false
}
}
return extid, true
}
示例3: LoadConfig
func (d *DbBaseConfig) LoadConfig() (map[string]string, bool) {
logger.Info("load all config from base_config table")
var configs map[string]string
var param, value string
configs = make(map[string]string, 4)
var strsql string
strsql = "SELECT config_name, config_param FROM nway_callout_base_config"
rows, bOp := d.dbbase.Query(strsql) //conn.Query(strsql)
if bOp == false {
logger.Error("query the data failed ")
rows.Close()
return configs, false
}
defer rows.Close()
for rows.Next() {
err := rows.Scan(¶m, &value)
if err != nil {
logger.Error("scan the data error,", err)
}
configs[param] = value
}
return configs, true
}
示例4: GetGroupByDomain
func (d *DbExtensionGroup) GetGroupByDomain(domain_name string) (map[int64]ExtensionGroup, bool) {
var groups map[int64]ExtensionGroup
groups = make(map[int64]ExtensionGroup, 0)
sqlstr := "SELECT a.id, a.domain_id, a.group_name, a.call_order_id," +
" a.call_order_crycle " +
" FROM nway_callout_extension_groups a,nway_callout_domains b " +
" where a.domain_id=b.domain_uuid and b.domain_name='" +
domain_name + "'"
rows, bOp := d.dbbase.Query(sqlstr)
if bOp == false {
logger.Error("query the data failed ")
rows.Close()
return groups, false
}
var group ExtensionGroup
defer rows.Close()
for rows.Next() {
err := rows.Scan(&group.Id, &group.Domain_id, &group.Group_name,
&group.Call_order_id, &group.Call_order_crycle)
if err != nil {
logger.Error("scan the data error,", err)
return groups, false
}
groups[group.Id] = group
}
return groups, true
}
示例5: GetGatewayById
func (d *DbGateway) GetGatewayById(gw_id int64) (Gateway, bool) {
var gwt Gateway
//
sqlstr := "SELECT id, gateway_name, gateway_url, call_prefix, max_call, added_autodial," +
"curr_talking, domain_id " +
" FROM nway_callout_gateways " +
" where id=" + strconv.FormatInt(gw_id, 10)
rows, bOp := d.dbbase.Query(sqlstr)
if bOp == false {
logger.Error("query the data failed ")
rows.Close()
return gwt, false
}
defer rows.Close()
for rows.Next() {
err := rows.Scan(&gwt.Id, &gwt.Gateway_name, &gwt.Gateway_url, &gwt.Call_prefix, &gwt.Max_call,
&gwt.Added_autodial, &gwt.Curr_talking, &gwt.Domain_id)
if err != nil {
logger.Error("scan the data error,", err)
return gwt, false
}
}
return gwt, true
}
示例6: GetExtByExtNumber
func (d *DbExtension) GetExtByExtNumber(ext_number string) (Extension, bool) {
var ext Extension
sqlstr := "SELECT id, domain_id, extension_name, extension_number, callout_number, " +
"extension_type, group_id, extension_pswd, extension_login_state, " +
"extension_reg_state, callout_gateway, is_allow_callout, limit_max, " +
"limit_destination, mailbox, vm_password, accountcode, effective_caller_id_name, " +
"effective_caller_id_number, outbound_caller_id_name, outbound_caller_id_number," +
"call_group, hold_music, call_state, is_record, curr_talking, " +
"domain_name" +
"FROM nway_callout_extensions " +
" where extension_number='" + ext_number + "'"
rows, bOp := d.dbbase.Query(sqlstr)
if bOp == false {
logger.Error("query the data failed ")
rows.Close()
return ext, false
}
defer rows.Close()
for rows.Next() {
err := rows.Scan(&ext.Id,
&ext.Domain_id,
&ext.Extension_name,
&ext.Extension_number,
&ext.Callout_number,
&ext.Extension_type,
&ext.Group_id,
&ext.Extension_pswd,
&ext.Extension_login_state,
&ext.Extension_reg_state,
&ext.Callout_gateway,
&ext.Is_allow_callout,
&ext.Limit_max,
&ext.Limit_destination,
&ext.Mailbox,
&ext.Vm_password,
&ext.Accountcode,
&ext.Effective_caller_id_name,
&ext.Effective_caller_id_number,
&ext.Outbound_caller_id_name,
&ext.Outbound_caller_id_number,
&ext.Call_group,
&ext.Hold_music,
&ext.Call_state,
&ext.Is_record,
&ext.Curr_talking,
&ext.Domain_name)
if err != nil {
logger.Error("scan the data error,", err)
return ext, false
}
}
return ext, true
}
示例7: GetInt
//to return a int value of the key value
//param d: a default value
//param section: the section name
//param name: the param name
func (c *Config) GetInt(section, name string, d int) int {
svalue, bvalue := c.GetValue(section, name)
if bvalue {
if rvalue, err := strconv.Atoi(svalue); err == nil {
return rvalue
} else {
logger.Error("convert the value failed from section:%s,name:%s ' value", section, name)
return d
}
} else {
logger.Error("not found the section:%q,name:%q ' value", section, name)
return d
}
}
示例8: main
func main() {
var dbinstance *nwayconnection.NwayConnect = nil
dbinstance = nwayconnection.NewDb()
if dbinstance == nil {
logger.Error("Database create instance failed")
return
}
bInit := dbinstance.Init()
if bInit == false {
logger.Error("Database create connection failed")
return
}
beego.Run()
}
示例9: Init
func (this *NwayConnect) Init() bool {
// result := true
var err error
var conf *pbxconfig.NwayConfig
var isload bool
conf, isload = pbxconfig.LoadConf()
if isload == true {
dbstring := conf.Dbconf.ConnString
this.NwayDb, err = sql.Open("postgres", dbstring)
this.NwayDb.SetMaxIdleConns(4)
this.NwayDb.SetMaxOpenConns(10)
if err != nil {
//log.Fatalf()
logger.Error("Got error when connect database, the error is '%v'", err)
fmt.Println(dbstring)
return false
}
return true
} else {
return false
}
}
示例10: GetNumbers
func (d *DbCallNumber) GetNumbers(taskid int64, runpostion int64) (map[int64]CallNumber, bool) {
var numbers map[int64]CallNumber
numbers = make(map[int64]CallNumber, 0)
sqlstr := "SELECT id, domain_id, group_id, 'number', is_called, call_state, start_time," +
"answer_time, hangup_time, hangup_reason_id, answer_extension_id, " +
"record_file, wait_sec, cdr_id, call_out_task_id, create_time" +
"FROM nway_callout_numbers" +
" where call_out_task_id=" + strconv.FormatInt(taskid, 10) +
" and id > " + strconv.FormatInt(runpostion, 10)
rows, bOp := d.dbbase.Query(sqlstr)
if bOp == false {
logger.Error("query the data failed ")
rows.Close()
return numbers, false
}
var nmb CallNumber
defer rows.Close()
for rows.Next() {
err := rows.Scan(
&nmb.Id,
&nmb.Domain_id,
&nmb.Group_id,
&nmb.Number,
&nmb.Is_called,
&nmb.Call_state,
&nmb.Start_time,
&nmb.Answer_time,
&nmb.Hangup_time,
&nmb.Hangup_reason_id,
&nmb.Answer_extension_id,
&nmb.Record_file,
&nmb.Wait_sec,
&nmb.Cdr_id,
&nmb.Call_out_task_id,
&nmb.Create_time)
if err != nil {
logger.Error("scan the data error,", err)
return numbers, false
}
numbers[nmb.Id] = nmb
}
return numbers, true
}
示例11: SetAnswerCall
func (d *DbCallNumber) SetAnswerCall(id int64, ext string) bool {
var dbext DbExtension
ext_id, mybool := dbext.GetExtId(ext, id)
if mybool == false {
logger.Error("the ext id not found")
return false
}
sqlstr := "update nway_callout_numbers set call_state=2,Answer_time=current_timestamp, " +
"Answer_extension_id=" + strconv.FormatInt(ext_id, 10) +
" where id=" + strconv.FormatInt(id, 10)
bSuccess, err := d.dbbase.Exec(sqlstr)
if err != nil {
logger.Error("update call error,", err)
return false
}
return bSuccess
}
示例12: process_outbound
//處理outound的函數
func process_outbound(c *SocketConnection) error {
msg, err := c.ReadMessage()
if err != nil {
logger.Error("Read esl Message error ", err)
}
err = c.Send("linger")
if err != nil {
logger.Error(err)
}
caller_uuid := msg.GetHeader("Caller-Unique-ID")
content_type := msg.GetHeader("Content-Type")
event_name := msg.GetHeader("Event-Name")
call_direction := msg.GetHeader("Call-Direction")
b_uuid := msg.GetHeader("Unique-ID")
channel_state := msg.GetHeader("Channel-State")
caller_destination_number := msg.GetHeader("Caller-Destination-Number")
caller_username := msg.GetHeader("Caller-Username")
caller_number := msg.GetHeader("Caller-Caller-ID-Number")
channel_call_state := msg.GetHeader("Channel-Call-State")
gateway_name := msg.GetHeader("Gateway-Name")
if (len(gateway_name) > 0) && (call_direction == "inbound") {
//由外線呼入的
Debug("caller id ", caller_uuid)
Debug("content_type ", content_type)
Debug("event_name ", event_name)
Debug("b_uuid ", b_uuid)
Debug("channel_state ", channel_state)
Debug("caller_destination_number ", caller_destination_number)
Debug("caller_username ", caller_username)
Debug("caller_number ", caller_number)
Debug("channel_call_state ", channel_call_state)
//通過呼入號碼查找外線呼入的號碼或ivr等
outbRegex := nwayregex.NewRegex()
//Debug(outbRegex)
_, _, _ = outbRegex.Match("18621575908")
} else {
//由內呼外的
}
return err
}
示例13: Query
func (d *DbBase) Query(sqlstring string) (*sql.Rows, bool) {
var dbinstance *nwayconnection.NwayConnect = nil
dbinstance = nwayconnection.NewDb()
NwayConn := dbinstance.GetConn()
if NwayConn == nil {
logger.Error("Get The Connect Failed")
return nil, false
}
rows, err := NwayConn.Query(sqlstring)
if err != nil {
//log.Fatal("failed to scan", err)
logger.Error(err)
return nil, false
}
return rows, true
}
示例14: Exec
func (d *DbBase) Exec(sqlstring string) (bool, error) {
var dbinstance *nwayconnection.NwayConnect = nil
dbinstance = nwayconnection.NewDb()
NwayConn := dbinstance.GetConn()
if NwayConn == nil {
logger.Error("Get The Connect Failed")
err := errors.New("connect failed")
return false, err
}
_, err := NwayConn.Exec(sqlstring)
if err != nil {
//log.Fatal("failed to scan", err)
logger.Error(err)
return false, err
}
return true, nil
}
示例15: QureyPaging
func (d *DbBase) QureyPaging(sqlstring string, page, perpage int) (*sql.Rows, bool) {
sqlstring += " limit " + strconv.Itoa(perpage) + " offset " + strconv.Itoa((page-1)*perpage)
var dbinstance *nwayconnection.NwayConnect = nil
dbinstance = nwayconnection.NewDb()
NwayConn := dbinstance.GetConn()
if NwayConn == nil {
logger.Error("Get The Connect Failed")
return nil, false
}
rows, err := NwayConn.Query(sqlstring)
if err != nil {
//log.Fatal("failed to scan", err)
logger.Error(err)
return nil, false
}
return rows, true
}