本文整理匯總了Golang中github.com/donnie4w/go-logger/logger.Info函數的典型用法代碼示例。如果您正苦於以下問題:Golang Info函數的具體用法?Golang Info怎麽用?Golang Info使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Info函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Writer
/*將數據寫入數據庫*/
func Writer(dbIni *DBini, xmlInfo *XmlInfo) {
logger.Info("***************************")
logger.Info("Writer begin >>>>>>>>>>>>>>>>")
if len(xmlInfo.Datas) == 0 {
logger.Info("Writer end >>>>>>>>>>>>>>>>")
return
}
stmt, err := dbIni.T_Db.db.Prepare(xmlInfo.InsertSQL)
defer stmt.Close()
if err != nil {
logger.Error(err)
return
}
colsLength := len(xmlInfo.Columns)
c := 0
arrIds := make([]string, len(xmlInfo.Datas))
for _, v := range xmlInfo.Datas {
scans := make([]interface{}, colsLength+2)
for i := range xmlInfo.Columns {
scans[i] = v[xmlInfo.Columns[i]]
}
scans[colsLength] = dbIni.SysId
scans[colsLength+1] = dbIni.SysName
arrIds[c] = v[xmlInfo.Columns[0]]
stmt.Exec(scans...)
c++
}
xmlInfo.Datas = nil
xmlInfo.Ids = arrIds
logger.Info("Writer end >>>>>>>>>>>>>>>>")
}
示例2: copyFile
/*複製文件 如果存在則不再複製*/
func copyFile(src, dest string) error {
srcFile, e := os.Open(src)
if e != nil {
logger.Error("copyFile:", e.Error())
return e
}
defer srcFile.Close()
df, e := os.Open(dest)
defer df.Close()
if e != nil && os.IsNotExist(e) {
logger.Info("desIniFile:", dest, "file not exist!")
destFile, e := os.Create(dest)
if e != nil {
logger.Error("copyFile destFile:", e.Error())
return e
}
defer destFile.Close()
io.Copy(destFile, srcFile)
logger.Info("copy file from :", src, " to ", dest)
} else {
logger.Info("desIniFile:", dest, "已存在")
}
return nil
}
示例3: RunSingleDataPipe
/*執行數據同步讀取直接寫入 single data 單次執行可變的業務數據 */
func (xmlInfo *XmlInfo) RunSingleDataPipe(dbIni *DBini) {
logger.Info("All run begin >>>>>>>>>>>>>>>>")
logger.Info("dbIni.F_DbType:", dbIni.F_DbType, "dbIni.T_DbType:", dbIni.T_DbType)
if !StartFlag {
return
}
defer func() {
if err := recover(); err != nil {
logger.Error("查詢數據庫失敗", err)
}
}()
f_pwd, _ := Base64Dec(dbIni.F_Password)
t_pwd, _ := Base64Dec(dbIni.T_Password)
dbIni.F_Db.Db_open(dbIni.F_DbType, dbIni.F_User, f_pwd, dbIni.F_Ip, dbIni.F_Port, dbIni.F_Dbname)
dbIni.T_Db.Db_open(dbIni.T_DbType, dbIni.T_User, t_pwd, dbIni.T_Ip, dbIni.T_Port, dbIni.T_Dbname)
//關閉數據庫
defer dbIni.F_Db.db.Close()
defer dbIni.T_Db.db.Close()
if dbIni.F_Db.db == nil || dbIni.T_Db.db == nil {
logger.Error("無法鏈接兩方數據庫")
panic("無法鏈接兩方數據庫")
return
}
DataSinglePipe(dbIni, xmlInfo)
Updater(dbIni, xmlInfo)
ExecProc(dbIni, xmlInfo)
logger.Info("All run end >>>>>>>>>>>>>>>>")
time.Sleep(5 * time.Second)
}
示例4: Alter
/*判斷是否需要添加標記位,如需要添加標記位*/
func Alter(dbIni *DBini, xmlInfo *XmlInfo) {
if len(xmlInfo.CheckColumnSQL) > 0 {
defer func() {
if err := recover(); err != nil {
logger.Error("數據庫執行失敗", err)
}
}()
f_pwd, _ := Base64Dec(dbIni.F_Password)
dbIni.F_Db.Db_open(dbIni.F_DbType, dbIni.F_User, f_pwd, dbIni.F_Ip, dbIni.F_Port, dbIni.F_Dbname)
defer dbIni.F_Db.db.Close()
query, err := dbIni.F_Db.db.Query(strings.Replace(xmlInfo.CheckColumnSQL, "@[dbname]", dbIni.F_Dbname, -1)) //查詢數據庫
defer query.Close()
if err != nil {
logger.Error("查詢數據庫失敗", err.Error())
panic(err)
return
}
testQuery, err := dbIni.F_Db.db.Query("select 1")
if err != nil {
logger.Error("數據庫連接異常,無法查詢測試數據")
panic(err)
return
} else {
if !testQuery.Next() {
logger.Error("數據庫連接異常,無法遍曆測試數據")
panic(err)
return
}
defer testQuery.Close()
}
if query.Next() {
logger.Info(xmlInfo.Remark, "經檢測,標記位已添加")
xmlInfo.AlterFlag = true
} else {
stmt, err := dbIni.F_Db.db.Prepare(xmlInfo.AlterSQL)
defer stmt.Close()
if err != nil {
logger.Error(err)
return
}
stmt.Exec()
logger.Info(xmlInfo.Remark, "在源數據庫中添加成功")
updateStmt, err := dbIni.F_Db.db.Prepare(xmlInfo.UpdateFlagSQL)
defer updateStmt.Close()
if err != nil {
logger.Error(err)
return
}
updateStmt.Exec()
logger.Info(xmlInfo.Remark, "在源數據庫中更新成功")
xmlInfo.AlterFlag = true
}
} else {
logger.Info(xmlInfo.Remark, "無需檢測標記位")
xmlInfo.AlterFlag = true
}
}
示例5: StartOrgSync
/*啟動組織機構同步服務*/
func (configinfo *ConfigInfo) StartOrgSync() {
logger.Info(" StartOrgSync is run... ")
var orgVersionUrl = "http://" + configinfo.core_ip + ":" + configinfo.core_port + configinfo.orgversion_url
var allOrgUrl = "http://" + configinfo.core_ip + ":" + configinfo.core_port + configinfo.allorg_url
logger.Info("orgVersionUrl start >>>>>>>>>>>>>>>>", orgVersionUrl)
logger.Info("allOrgUrl start >>>>>>>>>>>>>>>>", allOrgUrl)
//發起鏈接訪問,獲取返回的json數據
for {
var return_orgs []byte
var return_version []byte
var tmpOrgVersion string = ""
if response, err := http.Get(orgVersionUrl); err != nil {
logger.Error(" err = ", err)
} else {
defer response.Body.Close()
if return_version, err = ioutil.ReadAll(response.Body); err != nil {
logger.Error(" err = ", err)
}
tmpOrgVersion = string(return_version)
}
logger.Info(" return_version = ", tmpOrgVersion)
if len(OrgVersion) == 0 || (len(tmpOrgVersion) > 0 && !strings.EqualFold(tmpOrgVersion, OrgVersion)) {
OrgVersion = tmpOrgVersion
//重新加載組織機構
if response, err := http.Get(allOrgUrl); err != nil {
logger.Error(" err = ", err)
} else {
defer response.Body.Close()
if return_orgs, err = ioutil.ReadAll(response.Body); err != nil {
logger.Error(" err = ", err)
}
}
var orgInfos []OrgInfo
err := json.Unmarshal(return_orgs, &orgInfos)
if err != nil {
logger.Error(" err = ", err)
}
if len(orgInfos) > 0 {
for k, _ := range OrgMap {
delete(OrgMap, k)
}
for k, _ := range OrgNameMap {
delete(OrgNameMap, k)
}
for i := range orgInfos {
org := &orgInfos[i]
OrgMap[org.Org_path] = org.Id
OrgMap[org.Name] = org.Id
OrgNameMap[org.Id] = org.Name
}
}
}
time.Sleep(Time_interval * time.Second)
}
}
示例6: main
/*主入口*/
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
//指定是否控製台打印,默認為true
logger.SetConsole(true)
//指定日誌級別 ALL,DEBUG,INFO,WARN,ERROR,FATAL,OFF 級別由低到高
logger.SetLevel(logger.INFO)
logger.SetRollingFile("./log", "datapostlog.log", 100, 50, logger.MB)
if beego.AppConfig.String("runmode") == "dev" {
orm.Debug = true
}
//支持異構版本升級
pipe.Upgrade()
time.Sleep(3 * time.Second)
//配置文件初始化
err := pipe.InitFile()
if err != nil {
logger.Error("InitFile():", err)
}
//注冊運行服務
ServiceHandle(cSvcName, cSvcName, cSvcName, func() {
//初始化運行參數
pipe.InitConfigMap()
//運行參數管理UI服務
beego.Router("/", &pipe.IndexInfo{}, "*:Index")
beego.Router("/index/list", &pipe.IndexInfo{}, "*:List")
beego.Router("/index/edit", &pipe.IndexInfo{}, "*:Edit")
beego.Router("/index/test", &pipe.IndexInfo{}, "*:Test")
beego.Router("/index/help", &pipe.IndexInfo{}, "*:Help")
beego.Router("/index/treedata", &pipe.IndexInfo{}, "*:TreeData")
//啟動數據同步
go pipe.StartAllSys()
//啟動https服務
go pipe.Https_start()
//啟動參數管理UI 服務
beego.Run()
logger.Info("DaemonName=", cSvcName, "Daemon started.")
for {
time.Sleep(time.Hour)
}
}, func() {
Stop()
logger.Info("DaemonName=", cSvcName, "Daemon stoped.")
})
}
示例7: GC
func (p *Workshop) GC() {
runtime.ReadMemStats(&(p.ms))
alloc := p.ms.Alloc / 1024 / 1024
logger.Info("memAlloc: ", alloc, "M heapAlloc: ", p.ms.HeapAlloc/1024/1024, "M, stackAlloc: ", p.ms.StackInuse/1024/1024, "M")
if alloc >= p.memLimit {
debug.FreeOSMemory()
runtime.ReadMemStats(&(p.ms))
alloc = p.ms.Alloc / 1024 / 1024
logger.Info("after GC memAlloc: ", alloc, "M heapAlloc: ", p.ms.HeapAlloc/1024/1024, "M, stackAlloc: ", p.ms.StackInuse/1024/1024, "M")
}
}
示例8: Decode_pack
func (protocol *TransProtocolComm) Decode_pack(data []byte) (*Packet, int) {
log.Info("Enter Decode_pack")
decodeLen := 0
pack := &Packet{}
dataLen := len(data)
offset := 0
headLen := binary.Size(pack._header)
//1.get packhader
//= not cause out of memory so >= is needed
for offset = 0; dataLen-offset >= headLen; offset++ {
pack._header._ver = int16(binary.BigEndian.Uint16(data[offset : offset+2]))
pack._header._seq = int32(binary.BigEndian.Uint32(data[offset+2 : offset+6]))
pack._header._type = int16(binary.BigEndian.Uint16(data[offset+6 : offset+8]))
pack._header._bodyLen = int32(binary.BigEndian.Uint32(data[offset+8 : offset+12]))
//get pack header successful
if int16(VER) == pack._header._ver && pack._header._bodyLen < int32(MAX_PACK_SIZE) {
break
}
}
//2.check is a complete Packet
if dataLen-offset < headLen || dataLen-offset < int(pack._header._bodyLen) {
//can't find VER in data Slice or is not a complete pack.
log.Error("[PACK_NOT_COMPLETE],pack bodyLen is", pack._header._bodyLen)
return nil, 0
}
//3.get a complete pack
pack._data = make([]byte, pack._header._bodyLen)
copy(pack._data, data[offset:])
decodeLen = offset + headLen + int(pack._header._bodyLen)
return pack, decodeLen
}
示例9: StartAllSys
/*啟動所有配置信息*/
func StartAllSys() {
dirs := strings.Split(ConfigMap["transferes"], ",")
nosqlDir := ConfigMap["nosql"]
logger.Info("nosqlDir >>>>>>>>>>>>>>>>", nosqlDir)
StartFlag = true
//nosql目錄
if len(nosqlDir) > 0 {
noSqlDbIni := GetSysIni(nosqlDir)
noSqlDbIni.RegisterSys()
go noSqlDbIni.StartNoSqlSys()
}
for i := range dirs {
dirName := dirs[i]
if len(dirName) > 0 {
sysIni := GetSysIni(dirName)
if i == 0 {
go sysIni.StdOrgSync()
}
//非nosql目錄
sysIni.RegisterSys()
go sysIni.StartSys()
}
}
for {
time.Sleep(2 * time.Second)
}
}
示例10: log
func log(i int) {
logger.Debug("Debug>>>>>>>>>>>>>>>>>>>>>>" + strconv.Itoa(i))
logger.Info("Info>>>>>>>>>>>>>>>>>>>>>>>>>" + strconv.Itoa(i))
logger.Warn("Warn>>>>>>>>>>>>>>>>>>>>>>>>>" + strconv.Itoa(i))
logger.Error("Error>>>>>>>>>>>>>>>>>>>>>>>>>" + strconv.Itoa(i))
logger.Fatal("Fatal>>>>>>>>>>>>>>>>>>>>>>>>>" + strconv.Itoa(i))
}
示例11: StopWorkShop
func StopWorkShop() error {
WSChan_ <- CMD_EXIT
StopWorkShop_LOOP:
for {
select {
case ret := <-WSReportChan_:
if ret == RET_EXIT_SUCCESS {
logger.Info("workshop exit success")
} else {
logger.Info("workshop exit fail")
}
}
break StopWorkShop_LOOP
}
return nil
}
示例12: Check
/*判斷是否需要查詢數據*/
func Check(dbIni *DBini, xmlInfo *XmlInfo) {
if strings.EqualFold(xmlInfo.IsValData, "true") {
xmlInfo.CheckFlag = true
return
}
if len(xmlInfo.CheckRowSQL) > 0 {
defer func() {
if err := recover(); err != nil {
logger.Error("查詢數據庫失敗", err)
}
}()
f_pwd, _ := Base64Dec(dbIni.F_Password)
dbIni.F_Db.Db_open(dbIni.F_DbType, dbIni.F_User, f_pwd, dbIni.F_Ip, dbIni.F_Port, dbIni.F_Dbname)
defer dbIni.F_Db.db.Close()
query, err := dbIni.F_Db.db.Query(strings.Replace(xmlInfo.CheckRowSQL, "@[dbname]", dbIni.F_Dbname, -1)) //查詢數據庫
defer query.Close()
if err != nil {
logger.Error("查詢數據庫失敗", err.Error())
xmlInfo.CheckFlag = false
panic(err)
return
}
cols, _ := query.Columns()
values := make([][]byte, len(cols)) //values是每個列的值
scans := make([]interface{}, len(cols)) //query.Scan的參數 用len(cols)定住當次查詢的長度
for i := range values { //讓每一行數據都填充到[][]byte裏麵
scans[i] = &values[i]
}
dbRows := 0
if query.Next() {
//判斷是否與上次的數據一致,如果不一致則查詢數據庫,否則不查詢
if err := query.Scan(scans...); err != nil { //query.Scan查詢出來的不定長值放到scans[i] = &values[i],也就是每行都放在values裏
logger.Error(err)
xmlInfo.CheckFlag = false
return
}
for _, v := range values {
intV, err := strconv.Atoi(string(v))
if err != nil {
xmlInfo.CheckFlag = false
} else {
dbRows = intV
}
}
if dbRows != 0 && dbRows != xmlInfo.RowNum { //獲取reader 如何獲取到數據則置為0,如果獲取不到了則賦予全局GobalNum
xmlInfo.RowNum = dbRows
xmlInfo.GobalNum = dbRows
xmlInfo.CheckFlag = true
} else {
xmlInfo.CheckFlag = false
}
} else {
xmlInfo.CheckFlag = true
}
} else {
logger.Info(xmlInfo.Remark, "無需查詢係統庫行記錄是否變化")
xmlInfo.CheckFlag = true
}
}
示例13: StartSys
/*啟動*/
func (sys *SysIni) StartSys() {
fmt.Println("SysIni is start................")
StartFlag = true
if StartFlag { //判斷標記位並增加標記位
for i := range sys.xmlInfoes {
Alter(&sys.dbini, &sys.xmlInfoes[i])
logger.Info("Alter >>>>>>>>>>>>>>>>:", i)
}
}
logger.Info("StartSys >>>>>>>>>>>>>>>>goto for ")
//單次同步
c := cron.New()
c.Start()
defer c.Stop()
fmt.Println("singletimer>>>>", sys.configInfo.singletimer)
//單次同步
for j := range sys.singleXmlInfoes {
go func(sys *SysIni, j int) {
singleXmlInfo := sys.singleXmlInfoes[j]
c.AddFunc(sys.configInfo.singletimer,
func() {
logger.Info("single[", singleXmlInfo.FileName, "] job is run ......................")
singleXmlInfo.RunSingleDataPipe(&sys.dbini)
},
singleXmlInfo.FileName)
}(sys, j)
}
//實時同步
for StartFlag {
//邊讀邊寫,更新
for i := range sys.xmlInfoes {
//logger.Info("sys.xmlInfoes[i].NotExistData >>>>>>>>>>>>>>>>", sys.xmlInfoes[i].Remark, sys.xmlInfoes[i].NotExistData)
if sys.xmlInfoes[i].NotExistData {
Check(&sys.dbini, &sys.xmlInfoes[i])
}
if sys.xmlInfoes[i].CheckFlag {
sys.xmlInfoes[i].RunDataPipe(&sys.dbini)
}
}
time.Sleep(2 * time.Second)
}
}
示例14: Run
/*執行數據同步*/
func (xmlInfo *XmlInfo) Run(dbIni *DBini) {
logger.Info("All run begin >>>>>>>>>>>>>>>>")
f_pwd, _ := Base64Dec(dbIni.F_Password)
t_pwd, _ := Base64Dec(dbIni.T_Password)
dbIni.F_Db.Db_open(dbIni.F_DbType, dbIni.F_User, f_pwd, dbIni.F_Ip, dbIni.F_Port, dbIni.F_Dbname)
dbIni.T_Db.Db_open(dbIni.T_DbType, dbIni.T_User, t_pwd, dbIni.T_Ip, dbIni.T_Port, dbIni.T_Dbname)
//關閉數據庫
defer dbIni.F_Db.db.Close()
defer dbIni.T_Db.db.Close()
if dbIni.F_Db.db == nil || dbIni.T_Db.db == nil {
logger.Error("無法鏈接兩方數據庫")
return
}
Reader(dbIni, xmlInfo)
Writer(dbIni, xmlInfo)
Updater(dbIni, xmlInfo)
logger.Info("All run end >>>>>>>>>>>>>>>>")
time.Sleep(5 * time.Second)
}
示例15: Reader
/*訪問數據庫獲取數據*/
func Reader(dbIni *DBini, xmlInfo *XmlInfo) {
logger.Info("***************************")
logger.Info("Reader begin >>>>>>>>>>>>>>>>")
query, err := dbIni.F_Db.db.Query(xmlInfo.DataSQL) //查詢數據庫
if err != nil {
logger.Error("查詢數據庫失敗", err.Error())
return
}
defer query.Close()
cols, _ := query.Columns()
values := make([][]byte, len(cols)) //values是每個列的值
scans := make([]interface{}, len(cols)) //query.Scan的參數 用len(cols)定住當次查詢的長度
for i := range values { //讓每一行數據都填充到[][]byte裏麵
scans[i] = &values[i]
}
results := make(map[int]map[string]string) //最後得到的map
i := 0
for query.Next() { //循環
if err := query.Scan(scans...); err != nil { //query.Scan查詢出來的不定長值放到scans[i] = &values[i],也就是每行都放在values裏
logger.Error(err)
return
}
row := make(map[string]string) //每行數據
for k, v := range values {
key := cols[k]
row[key] = string(v)
}
results[i] = row //裝入結果集中
i++
}
if i == 0 {
xmlInfo.RowNum = xmlInfo.GobalNum
} else {
xmlInfo.RowNum = 0
}
xmlInfo.Datas = results
xmlInfo.Columns = cols
logger.Info("Reader end >>>>>>>>>>>>>>>>")
}