package main import ( "../cmd/mmysql" "encoding/json" "io" "log" "os" ) var ( Info *log.Logger Warning *log.Logger Error *log.Logger ) func init() { errFile, err := os.OpenFile("errors.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) if err != nil { log.Fatalln("打开日志文件失败:", err) } Info = log.New(os.Stdout, "Info:", log.Ldate|log.Ltime|log.Lshortfile) Warning = log.New(os.Stdout, "Warning:", log.Ldate|log.Ltime|log.Lshortfile) Error = log.New(io.MultiWriter(os.Stderr, errFile), "Error:", log.Ldate|log.Ltime|log.Lshortfile) } type ServiceStatus struct { id int32 `service id` costtime int32 `monitor cost time second` status bool `serivces status` clientip string `monitor run client ip` client_area string `client area` } func GetServiceStatus(c *ServiceStatus) bool { Info.Println("get message from client", c) return true } func SaveServiceStatus() bool { return true } func main() { Info.Println("run main") //var m mmysql.ServiceList vv := mmysql.GetServiceList("bj") jsons, errs := json.Marshal(vv) if errs != nil { Error.Println(errs.Error()) } Info.Println(string(jsons)) //Warning.Println(string(jsons)) //for i := 0; i < len(vv); i++ { // Warning.Println(vv[i]) //} //for k, v := range vv { // Error.Println(k) // Error.Println(v) // Error.Println(v.Id) //} //Info.Println(vv) //var myconn config.MysqlConf //myconn.GetMysqlConn() //Error.Printf("mmysql user %s,passwd %s,url %s", myconn.User, myconn.Passwd, myconn.Conn) }