optimize log tool

This commit is contained in:
hoteas
2021-05-25 19:53:34 +08:00
parent 770f0a94c9
commit 740059075a
6 changed files with 41 additions and 27 deletions
+13 -15
View File
@@ -3,8 +3,6 @@ package main
import (
"../../hotime"
"../../hotime/cache"
"../../hotime/common"
"database/sql"
"fmt"
"golang.org/x/net/websocket"
"time"
@@ -12,8 +10,8 @@ import (
func main() {
appIns := hotime.Application{}
//appIns := hotime.Application{}
appIns := hotime.Init("example/config/config.json")
appIns.SetConnectListener(func(context *hotime.Context) bool {
//fmt.Println(context.HandlerStr + time.Now().Format(" 2006-01-02 15:04 ") + hotime.Substr(context.Req.RemoteAddr, 0, strings.Index(context.Req.RemoteAddr, ":")))
@@ -22,7 +20,7 @@ func main() {
})
//手动模式,
appIns.SetConfig("example/config/config.json")
//appIns.SetConfig("example/config/config.json")
//redis缓存接入
ca := cache.CacheIns(&cache.CacheRedis{Host: appIns.Config.GetString("redisHost"), Pwd: appIns.Config.GetString("redisPwd"), Time: appIns.Config.GetCeilInt64("cacheLongTime")})
ca.Cache("xyzm", "dasdas")
@@ -38,16 +36,16 @@ func main() {
appIns.SetCache(cache.CacheIns(&cache.CacheMemory{}))
//快捷模式
appIns.SetDefault(func(err ...*common.Error) (*sql.DB, *sql.DB) {
query := appIns.Config.GetString("dbUser") + ":" + appIns.Config.GetString("dbPwd") +
"@tcp(" + appIns.Config.GetString("dbHost") + ":" + appIns.Config.GetString("dbPort") + ")/" + appIns.Config.GetString("dbName") + "?charset=utf8"
DB, e := sql.Open("mysql", query)
if e != nil && len(err) != 0 {
err[0].SetError(e)
}
return DB, nil
})
//appIns.SetDefault(func(err ...*common.Error) (*sql.DB, *sql.DB) {
// query := appIns.Config.GetString("dbUser") + ":" + appIns.Config.GetString("dbPwd") +
// "@tcp(" + appIns.Config.GetString("dbHost") + ":" + appIns.Config.GetString("dbPort") + ")/" + appIns.Config.GetString("dbName") + "?charset=utf8"
// DB, e := sql.Open("mysql", query)
// if e != nil && len(err) != 0 {
// err[0].SetError(e)
// }
// return DB, nil
//})
//init
appIns.Run(hotime.Router{
"app": hotime.Proj{
"index": hotime.Ctr{