|
@ -13,8 +13,11 @@ import ( |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
func init() { |
|
|
func init() { |
|
|
//将日志同时输出到控制台和文件
|
|
|
//日志初始化,将日志同时输出到控制台和文件
|
|
|
file := "./" + "jd_seckill_" + time.Now().Format("20060102") + ".log" |
|
|
if !common.IsDir("./logs/") { |
|
|
|
|
|
_=os.Mkdir("./logs/",0777) |
|
|
|
|
|
} |
|
|
|
|
|
file := "./logs/jd_seckill_" + time.Now().Format("20060102") + ".log" |
|
|
logFile, logErr := os.OpenFile(file, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0666) |
|
|
logFile, logErr := os.OpenFile(file, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0666) |
|
|
if logErr != nil { |
|
|
if logErr != nil { |
|
|
panic(logErr) |
|
|
panic(logErr) |
|
@ -22,7 +25,7 @@ func init() { |
|
|
defer logFile.Close() |
|
|
defer logFile.Close() |
|
|
mw := io.MultiWriter(os.Stdout, logFile) |
|
|
mw := io.MultiWriter(os.Stdout, logFile) |
|
|
log.SetOutput(mw) |
|
|
log.SetOutput(mw) |
|
|
log.SetPrefix("[jd_seckill]") |
|
|
log.SetPrefix("[jd_seckill] ") |
|
|
log.SetFlags(log.LstdFlags | log.Lshortfile | log.LUTC) |
|
|
log.SetFlags(log.LstdFlags | log.Lshortfile | log.LUTC) |
|
|
|
|
|
|
|
|
//客户端设置初始化
|
|
|
//客户端设置初始化
|
|
@ -40,7 +43,6 @@ func init() { |
|
|
|
|
|
|
|
|
//抢购状态管道
|
|
|
//抢购状态管道
|
|
|
common.SeckillStatus=make(chan bool) |
|
|
common.SeckillStatus=make(chan bool) |
|
|
log.Println("jd_seckill 程序启动成功,祝您成功!") |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func main() { |
|
|
func main() { |
|
|