Documentation ¶
Index ¶
- Constants
- Variables
- func AppendFile(filePath string, b []byte) error
- func CWD() string
- func ConfigFile(fielname string) string
- func CreateDir(path string) error
- func CreateFile(filePath string, b []byte) error
- func Ellipsis(text string, length int) string
- func Exist(path string) bool
- func GetCache() *cache.Cache
- func GetCacheToken() string
- func GetDeviceDir(deviceTypeId int64) (string, error)
- func GetDeviceTypeId(deviceDir string) (int64, error)
- func GetLocation() (*time.Location, error)
- func GetPingMsg(devIp string) (bool, string)
- func GetSessionId() *http.Cookie
- func GetToken() error
- func HasChinese(str string) bool
- func InStrArray(s string, ss []string) bool
- func InitConfig()
- func IsGBK(data []byte) bool
- func IsPortInUse(host string, port int64) error
- func ListDir(dirPth string, suffix string) ([]string, error)
- func OpenFile(filePath string) ([]byte, error)
- func Request(method, url, data string, auth bool) []byte
- func ResizePng(imgPath, imgName string) error
- func RfreshToken() error
- func SetCacheToken(token string)
- func SetSessionId(cookies []*http.Cookie)
- func SyncServices(path, data string) (interface{}, error)
- func UpTime() time.Duration
- func UpTimeString() string
- type Cli
- type DateTime
- type Device
- type GormLogger
- type Req
- type Restful
- type Server
- type StringArray
- type Time
- type Token
Constants ¶
View Source
const ( DateLayout = "2006-01-02" DateTimeLayout = "2006-01-02 15:04:05" TimeLayout = "15:04:05" BuildTimeLayout = "2006.0102.150405" TimestampLayout = "20060102150405" )
日期格式
Variables ¶
View Source
var Config = struct { Host string `default:"" env:"host"` Appid string `default:"" env:"appid"` Appsecret string `default:"" env:"appsecret"` DB string `default:"" env:"db"` Dir struct { Names string `default:"" env:"DirNames"` Codes string `default:"" env:"DirCodes"` } Exts string `default:"" env:"exts"` Imgexts string `default:"" env:"imagexts"` Root string `default:"" env:"root"` Outdir string `default:"" env:"outdir"` Timeout int64 `default:"" env:"timeout"` Timeover int64 `default:"" env:"timeover"` Isresizeimg bool `default:"false" env:"isresizeimg"` Devicesize int `default:"5" env:"devicesize"` Ftp struct { Ip string `default:"" env:"FtpIp"` Username string `default:"" env:"FtpUsername"` Password string `default:"" env:"FtpPassword"` } Device struct { Timetype string `default:"m" env:"DeviceTimetype"` Timeduration int64 `default:"3" env:"DeviceTimeduration"` } Data struct { Timetype string `default:"h" env:"DataTimetype"` Timeduration int64 `default:"1" env:"DataTimeduration"` } Restful struct { Timetype string `default:"m" env:"RestfulTimetype"` Timeduration int64 `default:"3" env:"RestfulTimeduration"` } System struct { Timetype string `default:"m" env:"SystemTimetype"` Timeduration int64 `default:"3" env:"SystemTimeduration"` } Web struct { Account string `default:"" env:"WebAccount"` Password string `default:"" env:"WebPassword"` Indir string `default:"" env:"WebIndir"` } Android struct { Account string `default:"" env:"AndroidAccount"` Password string `default:"" env:"AndroidPassword"` Indir string `default:"" env:"AndroidIndir"` } Faultmsg struct { Device string `default:"" env:"FaultmsgDevice"` Plugin string `default:"" env:"FaultmsgPlugin"` Logsync string `default:"" env:"FaultmsgLogsync"` } Log struct { Overtime int64 `default:"15" env:"LogOvertime"` Synctime int64 `default:"5" env:"LogSynctime"` } }{}
View Source
var (
DefaultGormLogger = GormLogger{log.New(os.Stdout, "[ORM] ", 0)}
)
View Source
var LogFormatter = func(values ...interface{}) (messages []interface{}) { if len(values) > 1 { var ( sql string formattedValues []string level = values[0] currentTime = time.Now().Format("2006/01/02 15:04:05") ) messages = []interface{}{currentTime} if level == "sql" { messages = append(messages, fmt.Sprintf("[%.2fms]", float64(values[2].(time.Duration).Nanoseconds()/1e4)/100.0)) for _, value := range values[4].([]interface{}) { indirectValue := reflect.Indirect(reflect.ValueOf(value)) if indirectValue.IsValid() { value = indirectValue.Interface() if t, ok := value.(time.Time); ok { formattedValues = append(formattedValues, fmt.Sprintf("'%v'", t.Format("2006-01-02 15:04:05"))) } else if b, ok := value.([]byte); ok { if str := string(b); isPrintable(str) { formattedValues = append(formattedValues, fmt.Sprintf("'%v'", str)) } else { formattedValues = append(formattedValues, "'<binary>'") } } else if r, ok := value.(driver.Valuer); ok { if value, err := r.Value(); err == nil && value != nil { formattedValues = append(formattedValues, fmt.Sprintf("'%v'", value)) } else { formattedValues = append(formattedValues, "NULL") } } else { formattedValues = append(formattedValues, fmt.Sprintf("'%v'", value)) } } else { formattedValues = append(formattedValues, "NULL") } } if numericPlaceHolderRegexp.MatchString(values[3].(string)) { sql = values[3].(string) for index, value := range formattedValues { placeholder := fmt.Sprintf(`\$%d([^\d]|$)`, index+1) sql = regexp.MustCompile(placeholder).ReplaceAllString(sql, value+"$1") } } else { formattedValuesLength := len(formattedValues) for index, value := range sqlRegexp.Split(values[3].(string), -1) { sql += value if index < formattedValuesLength { sql += formattedValues[index] } } } messages = append(messages, sql) messages = append(messages, fmt.Sprintf("\r\n%v", strconv.FormatInt(values[5].(int64), 10)+" rows affected or returned")) } else { messages = append(messages, values[2:]...) } } return }
View Source
var StartTime = time.Now()
Functions ¶
func ConfigFile ¶
func CreateFile ¶
func GetCacheToken ¶
func GetCacheToken() string
func GetPingMsg ¶
func GetSessionId ¶
func GetToken ¶
func GetToken() error
http://fyxt.t.chindeo.com/platform/application/login http://fyxt.t.chindeo.com/platform/report/device
func HasChinese ¶
func InStrArray ¶
func InitConfig ¶
func InitConfig()
func IsPortInUse ¶
func RfreshToken ¶
func RfreshToken() error
http://fyxt.t.chindeo.com/platform/application/update_token http://fyxt.t.chindeo.com/platform/report/device
func SetCacheToken ¶
func SetCacheToken(token string)
func SetSessionId ¶
func SyncServices ¶
http://fyxt.t.chindeo.com/platform/report/device 发送设备日志信息 http://fyxt.t.chindeo.com/platform/report/service 提交服务监控信息
func UpTimeString ¶
func UpTimeString() string
Types ¶
type Cli ¶
type Cli struct { IP string //IP地址 Username string //用户名 Password string //密码 Port int //端口号 LastResult string //最近一次Run的结果 // contains filtered or unexported fields }
type Device ¶
type Device struct { IsError int64 `json:"is_error" ` DevStatus int64 `json:"device_status"` DevCode string `json:"device_code"` LogAt Time `json:"log_at"` }
func GetDevices ¶
type GormLogger ¶
Logger default logger
func (GormLogger) Print ¶
func (logger GormLogger) Print(values ...interface{})
Print format & print log
type Restful ¶
func GetRestfuls ¶
type Server ¶
type Server struct { Id int64 `json:"id"` Ip string `json:"ip"` Port int64 `json:"port"` Account string `json:"account"` Pwd string `json:"pwd"` ServiceTypeId int64 `json:"service_type_id"` ServiceName string `json:"service_name"` ServiceTitle string `json:"service_title"` }
func GetServices ¶
type StringArray ¶
type StringArray string
func (StringArray) MarshalJSON ¶
func (r StringArray) MarshalJSON() ([]byte, error)
type Time ¶
func (*Time) UnmarshalJSON ¶
returns time.Now() no matter what!
Source Files ¶
Click to show internal directories.
Click to hide internal directories.