Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion base/branding.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var (
BrandNameLower = "ucloud"
BrandAPIURL = "https://api.ucloud.cn/"
BrandUmountURL = "https://docs.ucloud.cn/storage_cdn/udisk/userguide/umount"
BrandLogURL = "https://das-rpt.ucloud.cn/log"
BrandAuthURL = "https://accountv2.ucloud.cn/authentication"
BrandAccountURL = "https://accountv2.ucloud.cn"
BrandRegisterURL = "https://passport.ucloud.cn/#register"
Expand Down
40 changes: 0 additions & 40 deletions base/log.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package base

import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
"runtime"
"strings"
"sync"
"time"
Expand All @@ -15,21 +12,12 @@ import (
log "github.com/sirupsen/logrus"

"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/version"
)

// DefaultDasURL location of das server
var DefaultDasURL string

func init() {
DefaultDasURL = fmt.Sprintf("%s", BrandLogURL)
}

// Logger 日志
var logger *log.Logger
var mu sync.Mutex
var out = Cxt.GetWriter()
var tracer = Tracer{DefaultDasURL}

func initConfigDir() {
if _, err := os.Stat(GetLogFileDir()); os.IsNotExist(err) {
Expand Down Expand Up @@ -160,7 +148,6 @@ func UploadLogs(logs []string, level string, goID int64) {
line := fmt.Sprintf("time=%s level=%s goroutine_id=%d msg=%s", time.Now().Format(time.RFC3339Nano), level, goID, log)
lines = append(lines, line)
}
tracer.Send(lines)
}

// LogRotateHook rotate log file
Expand Down Expand Up @@ -270,30 +257,3 @@ func (t Tracer) wrapLogs(log []string) ([]byte, error) {
}
return marshaled, nil
}

// Send logs to server
func (t Tracer) Send(logs []string) error {
body, err := t.wrapLogs(logs)
if err != nil {
return err
}
for i := 0; i < len(body); i++ {
body[i] = ^body[i]
}

client := &http.Client{}
ua := fmt.Sprintf("GO/%s GO-SDK/%s %s", runtime.Version(), version.Version, UserAgent)
req, err := http.NewRequest("POST", t.DasUrl, bytes.NewReader(body))
req.Header.Add("Origin", "https://sdk.ucloud.cn")
req.Header.Add("User-Agent", ua)
resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return fmt.Errorf("send logs failed: status %d %s", resp.StatusCode, resp.Status)
}

return nil
}
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/ucloud/ucloud-sdk-go v0.22.17 h1:EFn+GxVKS5Tj8hIPie3qL6Zgk25fmWcHqJ06K8wl+Qo=
github.com/ucloud/ucloud-sdk-go v0.22.17/go.mod h1:dyLmFHmUfgb4RZKYQP9IArlvQ2pxzFthfhwxRzOEPIw=
github.com/ucloud/ucloud-sdk-go v0.22.25 h1:ceKeH7WFnpUt9nJSubn+mnxS1iKGrk/Q+HLwa0iYwmQ=
github.com/ucloud/ucloud-sdk-go v0.22.25/go.mod h1:dyLmFHmUfgb4RZKYQP9IArlvQ2pxzFthfhwxRzOEPIw=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
Expand Down