From 30b584f0bdaf7133377229177f45ec7e157fafd1 Mon Sep 17 00:00:00 2001 From: yuxh Date: Mon, 13 Mar 2023 20:58:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20topic=20=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + funtion.go | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 6eac045..d19dc6e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ out gen runtime +/vendor \ No newline at end of file diff --git a/funtion.go b/funtion.go index 0ed5cbb..e877203 100644 --- a/funtion.go +++ b/funtion.go @@ -70,13 +70,18 @@ func GenAliConfig(level Level) *AliLSConfig { endpoint = "cn-hongkong.log.aliyuncs.com" } source := os.Getenv("GRLOG_SOURCE") + appName := os.Getenv("GRLOG_APP_NAME") + topic := os.Getenv("GRLOG_TOPIC") + if topic == "" { + topic = appName + } c := &AliLSConfig{ Project: project, Endpoint: endpoint, KeyID: "LTAI5tMA7iMGFfuc3xSRVCGQ", KeySecret: "z98EpzmYmgiVLKizxP7pMF4BPbHfPV", - LogStore: os.Getenv("GRLOG_APP_NAME"), - Topics: []string{os.Getenv("GRLOG_TOPIC")}, + LogStore: appName, + Topics: []string{topic}, Source: source, Level: level, FlushWhen: 0,