From e42b5e7914ee1d1657d1eb8f22be47f6a77b0d2f Mon Sep 17 00:00:00 2001
From: yanghui <yanghui@aiotlink.com>
Date: 星期四, 22 四月 2021 19:57:54 +0800
Subject: [PATCH] empty implementation to make complier happy

---
 logc.go |   82 ++++++++++++++++++++++++++++-------------
 1 files changed, 56 insertions(+), 26 deletions(-)

diff --git a/logc.go b/logc.go
index ed24bcc..118e012 100644
--- a/logc.go
+++ b/logc.go
@@ -2,6 +2,8 @@
 
 import (
 	"basic.com/valib/bhomebus.git"
+	"bytes"
+	"net/url"
 
 	"encoding/json"
 	"fmt"
@@ -18,12 +20,13 @@
 )
 
 const (
-	TypeManual = iota + 1
-	TypeLoginOut
-	TypePollInfo
-	TypeStackInfo
-	TypeWarnInfo
-	TypeRunInfo
+	TypeManual = iota + 1  //浜哄伐鎿嶄綔鏃ュ織,绯荤粺鍗囩骇,鎽勫儚鏈轰慨鏀�,绠楁硶淇敼...
+	TypeLoginOut //鐧诲綍鐧诲嚭鏃ュ織
+	TypePollInfo //杞贰鎽勫儚鏈哄強鍏跺搴旂殑绠楁硶
+	TypeStackInfo //鏁版嵁鏍堝鐞嗘儏鍐�
+	TypeWarnInfo //鏁呴殰淇℃伅
+	TypeRunInfo //杩愯鎯呭喌,gpu,mem,cpu
+	TypeSysInfo //绯荤粺鍙傛暟鍙樻洿,ip,server name,寮�鍏虫満淇℃伅
 )
 
 type LogInfo struct {
@@ -41,35 +44,55 @@
 var (
 	msgChan chan []byte
 	bhSock *bhomebus.Socket
+	pubFn func(nodes []bhomebus.NetNode, topic string, data []byte, milliseconds int) int
 	ProcName string
 	ProcID string
 )
 
-func Init(sock *bhomebus.Socket, procId string, procName string) {
+func InitBySock(sock *bhomebus.Socket, procId string, procName string) bool {
 	msgChan = make(chan []byte, 100)
 	ProcName = procName
 	ProcID = procId
 	bhSock = sock
+	if bhSock == nil {
+		return false
+	}
 
 	go saveLoop()
+
+	return true
 }
 
-func Save(level int, logType int,template string, v ...interface{}) {
-	cache(level, logType, "", "", template, v)
-}
-
-func SaveManual(level int, logType int, userID string, userName string, template string, v ...interface{}) {
-	cache(level, logType, userID, userName, template, v)
-}
-
-func cache(level int, logType int, userID string, userName string, template string, fmtArgs []interface{}) {
-	// Format with Sprint, Sprintf, or neither.
-	msg := template
-	if msg == "" && len(fmtArgs) > 0 {
-		msg = fmt.Sprint(fmtArgs...)
-	} else if msg != "" && len(fmtArgs) > 0 {
-		msg = fmt.Sprintf(template, fmtArgs...)
+func InitByPubFn(fn func(nodes []bhomebus.NetNode, topic string, data []byte, milliseconds int) int,
+				procId string, procName string) bool {
+	msgChan = make(chan []byte, 100)
+	ProcName = procName
+	ProcID = procId
+	pubFn = fn
+	if pubFn == nil {
+		return false
 	}
+
+	go saveLoop()
+
+	return true
+}
+
+func Save(level int, logType int, v ...interface{}) {
+	cache(level, logType, "", "", v)
+}
+
+func SaveManual(level int, logType int, userID string, userName string, v ...interface{}) {
+	cache(level, logType, userID, userName, v)
+}
+
+func cache(level int, logType int, userID string, userName string, fmtArgs []interface{}) {
+	// Format with Sprint, Sprintf, or neither.
+	msg := ""
+	if len(fmtArgs) > 0 {
+		msg = fmt.Sprint(fmtArgs...)
+	}
+	fmt.Println(msg)
 
 	log := LogInfo {
 		ID:        uuid.NewV4().String(),
@@ -101,14 +124,21 @@
 		select {
 		case data := <- msgChan:
 			var nodes []bhomebus.NetNode
-			nodes = append(nodes, bhomebus.NetNode{
-				Key: 8,
-			})
-			bhSock.PubTimeout(nodes, LogSaveTopic, data, 1000)
+			nodes = append(nodes, bhomebus.NetNode{})
+			if bhSock != nil {
+				bhSock.PubTimeout(nodes, LogSaveTopic, data, 1000)
+			} else if pubFn != nil {
+				pubFn(nodes, LogSaveTopic, data, 1000)
+			} else {
+				fmt.Println("bhSock nil and pubFn nil")
+			}
+
 		default:
 			time.Sleep(10*time.Millisecond)
 		}
 	}
 }
 
+func Log(userName, method, path, contentType string, body *bytes.Buffer, values url.Values) {
 
+}

--
Gitblit v1.8.0