v1.3.3 暴露两个配置方法
This commit is contained in:
		
							parent
							
								
									cd94900f19
								
							
						
					
					
						commit
						3c03b5c497
					
				@ -48,7 +48,7 @@ func TestGetAliLs(t *testing.T) {
 | 
				
			|||||||
		l.Warn("Warn")
 | 
							l.Warn("Warn")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Close(lable, lable, lable)
 | 
						time.Sleep(time.Hour * 1)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestDropAdapter(t *testing.T) {
 | 
					func TestDropAdapter(t *testing.T) {
 | 
				
			||||||
 | 
				
			|||||||
@ -5,6 +5,7 @@ import (
 | 
				
			|||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"github.com/aliyun/aliyun-log-go-sdk/producer"
 | 
						"github.com/aliyun/aliyun-log-go-sdk/producer"
 | 
				
			||||||
	"golib.gaore.com/GaoreGo/grlogs/logs"
 | 
						"golib.gaore.com/GaoreGo/grlogs/logs"
 | 
				
			||||||
 | 
						"runtime"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -40,7 +41,10 @@ func (a *alilsLogger) Init(jsonconfig string) error {
 | 
				
			|||||||
	producerConfig.AccessKeyID = a.KeyID
 | 
						producerConfig.AccessKeyID = a.KeyID
 | 
				
			||||||
	producerConfig.AccessKeySecret = a.KeySecret
 | 
						producerConfig.AccessKeySecret = a.KeySecret
 | 
				
			||||||
	producerConfig.LingerMs = 100
 | 
						producerConfig.LingerMs = 100
 | 
				
			||||||
	producerConfig.AllowLogLevel = "error"
 | 
						producerConfig.NoRetryStatusCodeList = []int{-1}
 | 
				
			||||||
 | 
						producerConfig.Retries = 2
 | 
				
			||||||
 | 
						producerConfig.AllowLogLevel = "err"
 | 
				
			||||||
 | 
						producerConfig.MaxIoWorkerCount = int64(runtime.NumCPU())
 | 
				
			||||||
	a.producer = producer.InitProducer(producerConfig)
 | 
						a.producer = producer.InitProducer(producerConfig)
 | 
				
			||||||
	a.callback = &Callback{}
 | 
						a.callback = &Callback{}
 | 
				
			||||||
	a.producer.Start()
 | 
						a.producer.Start()
 | 
				
			||||||
@ -62,12 +66,19 @@ func (a *alilsLogger) WriteMsg(when time.Time, msg string, level int, lable stri
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	log := producer.GenerateLog(uint32(when.Unix()), vals)
 | 
						log := producer.GenerateLog(uint32(when.Unix()), vals)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, topic := range a.Topics {
 | 
						if env == "dev" || env == "test" {
 | 
				
			||||||
		if err := a.producer.SendLog(a.Project, a.LogStore, topic, a.Source, log); err != nil {
 | 
							for _, topic := range a.Topics {
 | 
				
			||||||
			return err
 | 
								if err := a.producer.SendLogWithCallBack(a.Project, a.LogStore, topic, a.Source, log, a.callback); err != nil {
 | 
				
			||||||
 | 
									return err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							for _, topic := range a.Topics {
 | 
				
			||||||
 | 
								if err := a.producer.SendLog(a.Project, a.LogStore, topic, a.Source, log); err != nil {
 | 
				
			||||||
 | 
									return err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -16,10 +16,10 @@ func (callback *Callback) Success(result *producer.Result) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (callback *Callback) Fail(result *producer.Result) {
 | 
					func (callback *Callback) Fail(result *producer.Result) {
 | 
				
			||||||
	fmt.Println(result.IsSuccessful())
 | 
						fmt.Println("IsSuccessful", result.IsSuccessful())
 | 
				
			||||||
	fmt.Println(result.GetErrorCode())
 | 
						fmt.Println("GetErrorCode", result.GetErrorCode())
 | 
				
			||||||
	fmt.Println(result.GetErrorMessage())
 | 
						fmt.Println("GetErrorMessage", result.GetErrorMessage())
 | 
				
			||||||
	fmt.Println(result.GetReservedAttempts())
 | 
						fmt.Println("GetReservedAttempts", result.GetReservedAttempts())
 | 
				
			||||||
	fmt.Println(result.GetRequestId())
 | 
						fmt.Println("GetRequestId", result.GetRequestId())
 | 
				
			||||||
	fmt.Println(result.GetTimeStampMs())
 | 
						fmt.Println("GetTimeStampMs", result.GetTimeStampMs())
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -23,3 +23,9 @@ const (
 | 
				
			|||||||
	AdapterElasticSearch Adapter = "es"
 | 
						AdapterElasticSearch Adapter = "es"
 | 
				
			||||||
	AdapterAliLs         Adapter = "alils"
 | 
						AdapterAliLs         Adapter = "alils"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const (
 | 
				
			||||||
 | 
						DEV  = "dev"
 | 
				
			||||||
 | 
						GRAY = "gray"
 | 
				
			||||||
 | 
						PROD = "prod"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user