Skip to content

Commit

Permalink
skip no permission region when query all uhosts in all regions (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangrzneu authored Jul 13, 2023
1 parent f68e0e1 commit 420b09d
Show file tree
Hide file tree
Showing 34 changed files with 293 additions and 281 deletions.
14 changes: 7 additions & 7 deletions ansi/code.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Package ansi reference https://github.com/sindresorhus/ansi-escapes
// Package ansi reference https://github.com/sindresorhus/ansi-escapes
package ansi

import (
Expand All @@ -9,26 +9,26 @@ const csi = "\x1b["

const sep = ";"

//CursorLeft move cursor to the left side
// CursorLeft move cursor to the left side
var CursorLeft = fmt.Sprintf("%sG", csi)

//EraseDown Erase the screen from the current line down to the bottom of the
// EraseDown Erase the screen from the current line down to the bottom of the
var EraseDown = fmt.Sprintf("%sJ", csi)

//EraseUp Erase the screen from the current line up to the top of the screen
// EraseUp Erase the screen from the current line up to the top of the screen
var EraseUp = fmt.Sprintf("%s1J", csi)

//CursorUp Move cursor up a specific amount of rows.
// CursorUp Move cursor up a specific amount of rows.
func CursorUp(count int) string {
return fmt.Sprintf("%s%dA", csi, count)
}

//CursorPrevLine Move cursor up a specific amount of rows.
// CursorPrevLine Move cursor up a specific amount of rows.
func CursorPrevLine(count int) string {
return fmt.Sprintf("%s%dF", csi, count)
}

//CursorTo Set the absolute position of the cursor. `x` `y` is the top left of the screen.
// CursorTo Set the absolute position of the cursor. `x` `y` is the top left of the screen.
func CursorTo(x, y int) string {
return fmt.Sprintf("%s%d;%dH", csi, y+1, x+1)
}
10 changes: 5 additions & 5 deletions base/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
)

//PrivateUHostClient 私有模块的uhost client 即未在官网开放的接口
// PrivateUHostClient 私有模块的uhost client 即未在官网开放的接口
type PrivateUHostClient = puhost.UHostClient

//PrivateUDBClient 私有模块的udb client 即未在官网开放的接口
// PrivateUDBClient 私有模块的udb client 即未在官网开放的接口
type PrivateUDBClient = pudb.UDBClient

//PrivateUMemClient 私有模块的umem client 即未在官网开放的接口
// PrivateUMemClient 私有模块的umem client 即未在官网开放的接口
type PrivateUMemClient = pumem.UMemClient

//PrivatePathxClient 私有模块的pathx client 即未在官网开放的接口
// PrivatePathxClient 私有模块的pathx client 即未在官网开放的接口
type PrivatePathxClient = ppathx.PathXClient

//Client aggregate client for business
// Client aggregate client for business
type Client struct {
uaccount.UAccountClient
uhost.UHostClient
Expand Down
32 changes: 16 additions & 16 deletions base/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

const DefaultDasURL = "https://das-rpt.ucloud.cn/log"

//Logger 日志
// Logger 日志
var logger *log.Logger
var mu sync.Mutex
var out = Cxt.GetWriter()
Expand Down Expand Up @@ -62,22 +62,22 @@ func logCmd() {
LogInfo(fmt.Sprintf("command: %s", strings.Join(args, " ")))
}

//GetLogger return point of logger
// GetLogger return point of logger
func GetLogger() *log.Logger {
return logger
}

//GetLogFileDir 获取日志文件路径
// GetLogFileDir 获取日志文件路径
func GetLogFileDir() string {
return GetHomePath() + fmt.Sprintf("/%s", ConfigPath)
}

//GetLogFilePath 获取日志文件路径
// GetLogFilePath 获取日志文件路径
func GetLogFilePath() string {
return GetHomePath() + fmt.Sprintf("/%s/cli.log", ConfigPath)
}

//LogInfo 记录日志
// LogInfo 记录日志
func LogInfo(logs ...string) {
_, ok := os.LookupEnv("COMP_LINE")
if ok {
Expand All @@ -94,7 +94,7 @@ func LogInfo(logs ...string) {
}
}

//LogPrint 记录日志
// LogPrint 记录日志
func LogPrint(logs ...string) {
_, ok := os.LookupEnv("COMP_LINE")
if ok {
Expand All @@ -112,7 +112,7 @@ func LogPrint(logs ...string) {
}
}

//LogWarn 记录日志
// LogWarn 记录日志
func LogWarn(logs ...string) {
_, ok := os.LookupEnv("COMP_LINE")
if ok {
Expand All @@ -130,7 +130,7 @@ func LogWarn(logs ...string) {
}
}

//LogError 记录日志
// LogError 记录日志
func LogError(logs ...string) {
_, ok := os.LookupEnv("COMP_LINE")
if ok {
Expand All @@ -148,7 +148,7 @@ func LogError(logs ...string) {
}
}

//UploadLogs send logs to das server
// UploadLogs send logs to das server
func UploadLogs(logs []string, level string, goID int64) {
var lines []string
for _, log := range logs {
Expand All @@ -158,20 +158,20 @@ func UploadLogs(logs []string, level string, goID int64) {
tracer.Send(lines)
}

//LogRotateHook rotate log file
// LogRotateHook rotate log file
type LogRotateHook struct {
MaxSize int64
Cut float32
LogFile *os.File
mux sync.Mutex
}

//Levels fires hook
// Levels fires hook
func (hook *LogRotateHook) Levels() []log.Level {
return log.AllLevels
}

//Fire do someting when hook is triggered
// Fire do someting when hook is triggered
func (hook *LogRotateHook) Fire(entry *log.Entry) error {
hook.mux.Lock()
defer hook.mux.Unlock()
Expand Down Expand Up @@ -212,7 +212,7 @@ func (hook *LogRotateHook) Fire(entry *log.Entry) error {
return nil
}

//NewLogRotateHook create a LogRotateHook
// NewLogRotateHook create a LogRotateHook
func NewLogRotateHook(file *os.File) *LogRotateHook {
return &LogRotateHook{
MaxSize: 1024 * 1024, //1MB
Expand All @@ -221,7 +221,7 @@ func NewLogRotateHook(file *os.File) *LogRotateHook {
}
}

//ToQueryMap tranform request to map
// ToQueryMap tranform request to map
func ToQueryMap(req request.Common) map[string]string {
reqMap, err := request.ToQueryMap(req)
if err != nil {
Expand All @@ -231,7 +231,7 @@ func ToQueryMap(req request.Common) map[string]string {
return reqMap
}

//Tracer upload log to server if allowed
// Tracer upload log to server if allowed
type Tracer struct {
DasUrl string
}
Expand Down Expand Up @@ -266,7 +266,7 @@ func (t Tracer) wrapLogs(log []string) ([]byte, error) {
return marshaled, nil
}

//Send logs to server
// Send logs to server
func (t Tracer) Send(logs []string) error {
body, err := t.wrapLogs(logs)
if err != nil {
Expand Down
Loading

0 comments on commit 420b09d

Please sign in to comment.