Commit e8bcd614 by 孙龙

init

parent 89913c2e
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
"access_url":"api.ichun.com/v3/login", "access_url":"api.ichun.com/v3/login",
"err_msg":"响应超时", "err_msg":"响应超时",
"err_code":"40004", "err_code":"40004",
"request_params":"tttttttttt",
"uid":"16678", "uid":"16678",
"user_name":"张三", "user_name":"张三",
"user_ip":"153.2.15.1", "user_ip":"153.2.15.1",
......
...@@ -62,7 +62,7 @@ func (logSink *LogSink) writeLoop() { ...@@ -62,7 +62,7 @@ func (logSink *LogSink) writeLoop() {
} }
// 把新日志追加到批次中 // 把新日志追加到批次中
logBatch.Logs = append(logBatch.Logs, log) logBatch.Logs = append(logBatch.Logs, *log)
// 如果批次满了, 就立即发送 // 如果批次满了, 就立即发送
if len(logBatch.Logs) >= int(util.Configs.LogSaveConfig.Length) { if len(logBatch.Logs) >= int(util.Configs.LogSaveConfig.Length) {
// 发送日志 // 发送日志
...@@ -78,7 +78,7 @@ func (logSink *LogSink) writeLoop() { ...@@ -78,7 +78,7 @@ func (logSink *LogSink) writeLoop() {
//fmt.Println(len(logBatch.Logs)) //fmt.Println(len(logBatch.Logs))
logSink.saveLogs(logBatch) logSink.saveLogs(logBatch)
logBatch = nil logBatch = nil
t.Reset(time.Second * 20) t.Reset(time.Second * sleepTime)
} }
...@@ -100,7 +100,7 @@ func InitLogSink() (err error) { ...@@ -100,7 +100,7 @@ func InitLogSink() (err error) {
// 选择db和collection // 选择db和collection
G_logSink = &LogSink{ G_logSink = &LogSink{
client: client, client: client,
logCollection: client.Database("monitor").Collection("monitor_log"), logCollection: client.Database(util.Configs.Mongodb_databases.Databases).Collection(util.Configs.Mongodb_databases.Collection),
logChan: make(chan *DataParams, 1000), logChan: make(chan *DataParams, 1000),
//autoCommitChan: make(chan *common.LogBatch, 1000), //autoCommitChan: make(chan *common.LogBatch, 1000),
} }
......
...@@ -87,7 +87,7 @@ func main() { ...@@ -87,7 +87,7 @@ func main() {
for{ for{
var wg sync.WaitGroup var wg sync.WaitGroup
fmt.Println("开始执行任务....") //fmt.Println("开始执行任务....")
for i := 0;i<3;i++{ for i := 0;i<3;i++{
wg.Add(1) wg.Add(1)
go func(wg *sync.WaitGroup){ go func(wg *sync.WaitGroup){
...@@ -102,7 +102,7 @@ func main() { ...@@ -102,7 +102,7 @@ func main() {
}(&wg) }(&wg)
} }
wg.Wait() wg.Wait()
fmt.Println("执行任务完成....") //fmt.Println("执行任务完成....")
time.Sleep(time.Microsecond*10) time.Sleep(time.Microsecond*10)
} }
} }
\ No newline at end of file
...@@ -31,6 +31,8 @@ type RabbitmqIchunt struct { ...@@ -31,6 +31,8 @@ type RabbitmqIchunt struct {
type MongodbDatabases struct { type MongodbDatabases struct {
Dns string `toml:"dns"` Dns string `toml:"dns"`
Databases string `toml:"databases"`
Collection string `toml:"collection"`
} }
type LogSaveConfigs struct { type LogSaveConfigs struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment