v1.3.3 暴露两个配置方法
This commit is contained in:
		
							parent
							
								
									c653a48667
								
							
						
					
					
						commit
						ce9ab060d9
					
				
							
								
								
									
										78
									
								
								funtion.go
									
									
									
									
									
								
							
							
						
						
									
										78
									
								
								funtion.go
									
									
									
									
									
								
							| @ -45,50 +45,56 @@ var adatperSetMapper = map[Adapter]func(l *Logger, level Level) error{ | ||||
| 	}, | ||||
| 
 | ||||
| 	AdapterElasticSearch: func(l *Logger, level Level) error { | ||||
| 
 | ||||
| 		dsn := "http://es-cn-0pp1mm3hq000dnbh4.public.elasticsearch.aliyuncs.com:9200/" | ||||
| 		if os.Getenv(envkey) == "prod" || os.Getenv(envkey) == "" || os.Getenv(envkey) == "gray" { | ||||
| 			dsn = "http://es-cn-0pp1mm3hq000dnbh4.elasticsearch.aliyuncs.com:9200/" | ||||
| 		} | ||||
| 
 | ||||
| 		c := EsConfig{ | ||||
| 			Username: "elastic", | ||||
| 			Password: "Hellogaore@", | ||||
| 			Dsn:      dsn, | ||||
| 			Level:    level, | ||||
| 			Index:    os.Getenv("GRLOG_APP_NAME"), | ||||
| 		} | ||||
| 
 | ||||
| 		c := GenEsConfig(level) | ||||
| 		return l.SetLogger(logs.AdapterEs, c.String()) | ||||
| 	}, | ||||
| 
 | ||||
| 	AdapterAliLs: func(l *Logger, level Level) error { | ||||
| 
 | ||||
| 		var project string = "gaore-app-logstore" | ||||
| 		var endpoint string | ||||
| 
 | ||||
| 		if os.Getenv(envkey) == "prod" || os.Getenv(envkey) == "" || os.Getenv(envkey) == "gray" { | ||||
| 			endpoint = project + ".cn-shenzhen-intranet.log.aliyuncs.com" | ||||
| 		} else if os.Getenv(envkey) == "dev" { | ||||
| 			endpoint = project + ".cn-shenzhen.log.aliyuncs.com" | ||||
| 		} | ||||
| 
 | ||||
| 		c := AliLSConfig{ | ||||
| 			Project:   project, | ||||
| 			Endpoint:  endpoint, | ||||
| 			KeyID:     "LTAI4GCHwcqtrFD4DHRHxR4k", | ||||
| 			KeySecret: "Ln19xfVYy6OMlJeF9aBvFl4fhRUKBl", | ||||
| 			LogStore:  "gaore-app-logstore", | ||||
| 			Topics:    []string{os.Getenv("GRLOG_APP_NAME")}, | ||||
| 			Source:    "", | ||||
| 			Level:     level, | ||||
| 			FlushWhen: 0, | ||||
| 		} | ||||
| 
 | ||||
| 		c := GenAliConfig(level) | ||||
| 		return l.SetLogger(logs.AdapterAliLS, c.String()) | ||||
| 	}, | ||||
| } | ||||
| 
 | ||||
| func GenAliConfig(level Level) AliLSConfig { | ||||
| 	var project string = "gaore-app-logstore" | ||||
| 	var endpoint string | ||||
| 
 | ||||
| 	if os.Getenv(envkey) == "prod" || os.Getenv(envkey) == "" || os.Getenv(envkey) == "gray" { | ||||
| 		endpoint = project + ".cn-shenzhen-intranet.log.aliyuncs.com" | ||||
| 	} else if os.Getenv(envkey) == "dev" { | ||||
| 		endpoint = project + ".cn-shenzhen.log.aliyuncs.com" | ||||
| 	} | ||||
| 
 | ||||
| 	c := AliLSConfig{ | ||||
| 		Project:   project, | ||||
| 		Endpoint:  endpoint, | ||||
| 		KeyID:     "LTAI4GCHwcqtrFD4DHRHxR4k", | ||||
| 		KeySecret: "Ln19xfVYy6OMlJeF9aBvFl4fhRUKBl", | ||||
| 		LogStore:  "gaore-app-logstore", | ||||
| 		Topics:    []string{os.Getenv("GRLOG_APP_NAME")}, | ||||
| 		Source:    "", | ||||
| 		Level:     level, | ||||
| 		FlushWhen: 0, | ||||
| 	} | ||||
| 	return c | ||||
| } | ||||
| 
 | ||||
| func GenEsConfig(level Level) EsConfig { | ||||
| 	dsn := "http://es-cn-0pp1mm3hq000dnbh4.public.elasticsearch.aliyuncs.com:9200/" | ||||
| 	if os.Getenv(envkey) == "prod" || os.Getenv(envkey) == "" || os.Getenv(envkey) == "gray" { | ||||
| 		dsn = "http://es-cn-0pp1mm3hq000dnbh4.elasticsearch.aliyuncs.com:9200/" | ||||
| 	} | ||||
| 
 | ||||
| 	c := EsConfig{ | ||||
| 		Username: "elastic", | ||||
| 		Password: "Hellogaore@", | ||||
| 		Dsn:      dsn, | ||||
| 		Level:    level, | ||||
| 		Index:    os.Getenv("GRLOG_APP_NAME"), | ||||
| 	} | ||||
| 	return c | ||||
| } | ||||
| 
 | ||||
| var adatperDropMapper = map[Adapter]func(l *Logger) error{ | ||||
| 
 | ||||
| 	AdapterAliLs: func(l *Logger) error { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user