From f475aac387883ce86d82f00e63bd51cc4bfcdcf8 Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Fri, 27 Oct 2023 15:57:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20survey=20=E5=8C=85=E6=96=B0=E5=A2=9E=20?= =?UTF-8?q?RecordBytes=20=E5=87=BD=E6=95=B0=EF=BC=8C=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B7=B3=E8=BF=87=E6=A0=BC=E5=BC=8F=E5=8C=96=E5=B0=86=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=9B=B4=E6=8E=A5=E5=86=99=E5=85=A5=EF=BC=8C=E9=80=82?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E8=BD=AC=E5=8F=91=E8=87=B3=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E9=98=9F=E5=88=97=E7=AD=89=E5=9C=BA=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/log/survey/survey.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/utils/log/survey/survey.go b/utils/log/survey/survey.go index 1153b3d..750c261 100644 --- a/utils/log/survey/survey.go +++ b/utils/log/survey/survey.go @@ -68,6 +68,15 @@ func Record(name string, data map[string]any) { logger.writer(fmt.Sprintf("%s - %s\n", time.Now().Format(time.DateTime), super.MarshalJSON(data))) } +// RecordBytes 记录一条运营日志 +func RecordBytes(name string, data []byte) { + logger, exist := survey[name] + if !exist { + panic(fmt.Errorf("survey %s not exist", name)) + } + logger.writer(string(data)) +} + // Flush 将运营日志记录器的缓冲区数据写入到文件 // - name 为空时,将所有记录器的缓冲区数据写入到文件 func Flush(names ...string) {