当前位置: 首页>>代码示例>>Golang>>正文


Golang log.Log函数代码示例

本文整理汇总了Golang中github.com/jin06/Caesar/log.Log函数的典型用法代码示例。如果您正苦于以下问题:Golang Log函数的具体用法?Golang Log怎么用?Golang Log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
	//set runtime
	runtime.GOMAXPROCS(runtime.NumCPU())

	log.Log("", "Welcom to use Caesar. Caesar is a high performance message queue.", nil)
	loadConf()
	sflag.FlagResolve(&listenAddr)

	//resolve TCPAddress
	log.Log("info", "Now start server...", log.Fields{"Listen Address": listenAddr})
	tcpAddr, err := net.ResolveTCPAddr("tcp4", listenAddr)
	handleErr(err)

	//Create listener
	ln, err := net.ListenTCP("tcp4", tcpAddr)

	//start message server service
	go control.MsgServerStart()

	//start control server service
	control.Init(ln)
	//	rpcServer := rpc.NewServer()
	//	users := new(command.Users)
	//	rpcServer.Register(users)
	//	log.Log("info", "Server start success, and now accept request from client.", nil)
	//	rpcServer.Accept(ln)
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:27,代码来源:CaesarServer.go

示例2: CreateUsertoDB

func CreateUsertoDB(userTable *User_Table) error {
	err1 := DB.Connect()
	defer DB.Close()
	if err1 != nil {
		log.Log("err", err1.Error(), nil)
		return err1
	}
	stmt, err := DB.Prepare("insert into user values (?, ?, ?, ?, ?, ?,?,?)")
	handleErr(err)
	if err != nil {
		log.Log("err", err.Error(), nil)
		return err
	}
	stmt.Bind(userTable)
	if err != nil {
		log.Log("err", err.Error(), nil)
		return err
	}
	//err = getData(msgq)
	stmt.Bind(userTable.Id, userTable.Group_id, userTable.Name, userTable.Password, userTable.Register_time, userTable.Sign, userTable.Last_login_time, userTable.Other)
	log.Log("info", string(userTable.Id), nil)
	_, err = stmt.Run() //msgq.MQid, msgq.MQname, msgq.MQType, msgq.Owner, msgq.Persistence
	handleErr(err)
	return nil
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:25,代码来源:db.go

示例3: DeleteMqById

func DeleteMqById(mqid int) error {
	_, err := GetMqDataById(mqid)
	if err != nil {
		return err
	}

	err1 := DB.Connect()
	defer DB.Close()
	if err1 != nil {
		log.Log("err", err1.Error(), nil)
		return err1
	}
	stmt, err := DB.Prepare(`delete from msgqueue where msgqueue_id=?`)
	if err != nil {
		log.Log("err", err.Error(), nil)
		return err
	}
	//stmt.Bind(mqid)
	//_, _, err = stmt.Exec(mqid)
	_, _, err = stmt.Exec(mqid)
	if err != nil {
		log.Log("err", err.Error(), nil)
		return err
	}
	//	num := res.AffectedRows()
	//	fmt.Println(num)
	return nil
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:28,代码来源:db.go

示例4: init

func init() {
	err := config.ReadConfigFile("../config/msgserver.yaml")
	if err != nil {
		//fmt.Print(err)
		mylog.Log("err", err.Error(), nil)
	} else {
		mylog.Log("info", "Message server config read!", nil)
	}
	ListenPort, err = config.GetString("listenport")
	handleErr(err)
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:11,代码来源:msgServer.go

示例5: loadConf

//Load configuration file.
func loadConf() {
	log.Log("info", "Load config file...", nil)
	err := config.ReadConfigFile("../config/server.yaml")
	if err != nil {
		//fmt.Print(err)
		log.Log("err", err.Error(), nil)
	} else {
		log.Log("info", "Completely read!", nil)
	}

	listenAddr, err = config.GetString("rpcAddress")
	handleErr(err)
	msgAddr, err = config.GetString("msgAddress")
	handleErr(err)
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:16,代码来源:CaesarServer.go

示例6: PostMsg

func (mqmsg MqMsg) PostMsg(w rest.ResponseWriter, r *rest.Request) {
	//msg := message.NewMsg()
	mqid, err := strconv.Atoi(r.PathParam("mqid"))
	if err != nil {
		log.Log("info", err.Error(), nil)
	}
	mq, ok := DefaultMM[mqid]
	if ok {
		mqmsg.Msg.MQid = mqid
		mqmsg.Msg.Generator = mq.Owner
		mqmsg.Msg.MsgId = Counter
		Counter++
		r.DecodeJsonPayload(mqmsg.Msg)

		fmt.Println(mqmsg.Msg.Value)

		//fmt.Println("post msg")
		mq.Lock()
		mq.AddMsg(*mqmsg.Msg)
		mq.Unlock()
		//w.WriteJson(mqmsg.Msg)
		w.WriteJson(map[string]string{"1016": "post success"})
	} else {
		w.WriteJson(map[string]string{"1010": "mq not running"})
	}
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:26,代码来源:mqMsg.go

示例7: checkLogined

func checkLogined() bool {
	if StatusLine == 0 {
		log.Log("info", "You are offline, please login.", nil)
		return true
	} else {
		return false
	}
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:8,代码来源:cmdsplit.go

示例8: init

func init() {
	err := config.ReadConfigFile("../config/db.yaml")
	if err != nil {
		//fmt.Print(err)
		log.Log("err", err.Error(), nil)
	} else {
		log.Log("info", "DB config read!", nil)
	}
	user, err = config.GetString("username")
	handleErr(err)
	pwd, err = config.GetString("password")
	handleErr(err)
	dbname, err = config.GetString("dbname")
	handleErr(err)
	dbaddress, err = config.GetString("address")
	handleErr(err)
	//log.Log("info", "", log.Fields{"username":user,"password":pwd,"dbname":dbname,"address":dbaddress})
	DB = mysql.New("tcp", "", dbaddress, user, pwd, dbname)
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:19,代码来源:db.go

示例9: DeleteMqByUserId

func DeleteMqByUserId(userId int) error {
	err := DB.Connect()
	defer DB.Close()
	if err != nil {
		log.Log("err", err.Error(), nil)
		return err
	}
	stmt, err := DB.Prepare(`delete from msgqueue where user_id=?`)
	if err != nil {
		log.Log("err", err.Error(), nil)
		return err
	}
	_, _, err = stmt.Exec(userId)
	if err != nil {
		log.Log("err", err.Error(), nil)
		return err
	}
	return nil
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:19,代码来源:db.go

示例10: Init

//init the defaultServer, publice receiver's method and accept the listener from client.
func Init(ln *net.TCPListener) {
	//DefaultServer = rpc.NewServer()
	//test := new(Test)
	//DefaultServer.Register(test)
	//users := new(command.Users)
	//rpcServer.Register(users)
	Register()
	log.Log("info", "Server start success, and now accept connection request from client.", nil)
	DefaultServer.Accept(ln)
	//log.Log("info", "run here now.", nil)
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:12,代码来源:rpcServer.go

示例11: LogOff

func (users *Users) LogOff(user *User, res *string) error {
	if users.isLogined(user) && user.Key == users.UM[user.Name].Key {
		*res = ""
		delete(users.UM, user.Name)
		//fmt.Printf("%s exit.\n", user.Name)
		logs := "Client " + user.Name + " logoff."
		log.Log("info", logs, nil)
	} else {
		*res = ""
	}
	return nil
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:12,代码来源:user.go

示例12: CreateUser

func (lead *User_Table) CreateUser(userTable *User_Table, res *string) error {
	//fmt.Println("here")
	//log.Log("info", mqtable.Name, nil)
	err := CreateUsertoDB(userTable)
	if err != nil {
		*res = "User create failed!"
	} else {
		*res = userTable.Name + " create success."
		log.Log("info", userTable.Name+" created.", nil)
	}
	return nil
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:12,代码来源:table.go

示例13: CreateMQ

func (lead *Mq_Table) CreateMQ(mqtable *Mq_Table, res *string) error {
	//fmt.Println("here")
	//log.Log("info", mqtable.Name, nil)
	err := CreateMqtoDB(mqtable)
	if err != nil {
		*res = "Mq create failed!"
	} else {
		*res = mqtable.Name + " create success."
		log.Log("info", mqtable.Name+" created.", nil)
	}
	return nil
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:12,代码来源:table.go

示例14: Login

//user login control
func (users *Users) Login(user *User, res *string) error {
	//log.Log("warn","1234455566666666" , nil)
	if users.isLogined(user) {
		*res = "User has logined."
		return nil
	} else {
		i, err := db.VerifyUser(user.Name, user.Password)
		if err != nil {
			log.Log("err", err.Error(), nil)
			*res = "Server error."
			return nil
		} else {
			switch i {
			case 0: //no user
				*res = "Wrong username."
				return nil
			case 1:
				users.UM[user.Name] = *user
				err = db.UpdateRegisterTime(user.Name)
				if err != nil {
					log.Log("err", err.Error(), nil)
				}

				//fmt.Println(user.Key)
				*res = "Login success."

				//fmt.Printf("%s login.\n", user.Name)
				logs := "A new client login. Client's name is " + user.Name
				log.Log("info", logs, nil)
				return nil
			case 2: //wrong password
				*res = "Wrong password."
				return nil
			default:
				*res = "Server error."
				return nil
			}
		}
	}
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:41,代码来源:user.go

示例15: FlagResolve

func FlagResolve(listenAddr *string) {
	flag.Parse()

	if *versionFlag != false {
		err := config.ReadConfigFile("../config/server.yml")
		if err != nil {
			fmt.Println(err)
			os.Exit(0)
		}
		version, _ := config.GetString("version")
		update, _ := config.GetList("update")
		instruction, _ := config.GetString("instruction")
		fmt.Printf("CaeserClient version: %s\n", version)
		fmt.Printf("New speciality contrast to old version: \n")
		for k, v := range update {
			fmt.Printf("%d-- %s\n", k+1, v)
		}
		fmt.Printf("       %s\n", instruction)
		os.Exit(0)
	}
	if *runtimeFlag == "min" {
		log.Log("warn", "Start up with least CPU's resousces", log.Fields{"Occupy CPU Num": 1})
	}

	if *listenFlag != "" {
		fp, err := regexp.MatchString(ipPattern, *listenFlag)
		handleError(err)
		if !fp {
			//fmt.Printf("\"%s\" is not a valid address, please check it and try again!\n", *listenFlag)
			log.Log("fatal", "-address is not a valid address, please check it and try again!", map[string]interface{}{"address": *listenFlag})
			os.Exit(0)
		}
		*listenAddr = *listenFlag
		fmt.Println("--Notice: you have set a new listen address", *listenAddr)
	} else {
		//fmt.Println("--Didn't set the listen address. Server will start at default address.")
		log.Log("info", "Didn't set the listen address. Server will start at default address.", log.Fields{"Default Address": *listenAddr})
	}
}
开发者ID:jmptrader,项目名称:Caesar,代码行数:39,代码来源:flag.go


注:本文中的github.com/jin06/Caesar/log.Log函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。