当前位置: 首页>>代码示例>>Golang>>正文


Golang kmgLog.Log函数代码示例

本文整理汇总了Golang中github.com/bronze1man/kmg/kmgLog.Log函数的典型用法代码示例。如果您正苦于以下问题:Golang Log函数的具体用法?Golang Log怎么用?Golang Log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: UploadDir

//upload a dir
func (obj *BulkUpyun) UploadDir(upyun_path, local_path string) {
	obj.Tm.AddTask(kmgTask.TaskFunc(func() {
		kmgLog.Log("upyun", "upload dir: "+upyun_path, nil)

		dir, err := os.Open(local_path)
		if err != nil {
			kmgLog.Log("upyunError", err.Error(), err)
			return
		}
		file_list, err := dir.Readdir(0)
		if err != nil {
			kmgLog.Log("upyunError", err.Error(), err)
			return
		}
		err = obj.UpYun.MkDir(upyun_path, true)
		if err != nil {
			kmgLog.Log("upyunError", err.Error(), err)
			return
		}
		for _, file_info := range file_list {
			file_name := file_info.Name()
			this_local_path := local_path + "/" + file_name
			this_upyun_path := upyun_path + "/" + file_name
			if file_info.IsDir() {
				obj.UploadDir(this_upyun_path, this_local_path)
			} else {
				obj.UploadFile(this_upyun_path, this_local_path)
			}
		}
		return
	}))
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:33,代码来源:bulk_upyun.go

示例2: DownloadDir

//resursive download a dir
func (obj *BulkUpyun) DownloadDir(upyun_path string, file_path string) {
	obj.Tm.AddTask(kmgTask.TaskFunc(func() {
		kmgLog.Log("upyun", "download dir: "+upyun_path, nil)
		file_list, err := obj.UpYun.ReadDir(upyun_path)
		file_mode := os.FileMode(0777)
		if err != nil {
			kmgLog.Log("upyunError", err.Error(), err)
			return
		}
		for _, file_info := range file_list {
			file_type := file_info.Type
			file_name := file_info.Name
			this_local_path := file_path + "/" + file_name
			this_upyun_path := upyun_path + "/" + file_name
			if file_type == "folder" {
				err := os.MkdirAll(this_local_path, file_mode)
				if err != nil {
					kmgLog.Log("upyunError", "os.MkdirAll fail!"+err.Error(), err)
					return
				}
				obj.DownloadDir(this_upyun_path, this_local_path)
			} else if file_type == "file" {
				obj.DownloadFile(this_upyun_path, this_local_path)
			} else {
				kmgLog.Log("upyunError", "unknow file type2:"+file_type, err)
				return
			}
		}
		return
	}))
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:32,代码来源:bulk_upyun.go

示例3: ServeHTTP

// http-json-api v1
// 1.数据传输使用psk加密,明文不泄漏信息
// 2.使用json序列化信息
// 3.只有部分api
func (s *generateServer_Demo) ServeHTTP(w http.ResponseWriter, req *http.Request) {
	b1, err := kmgHttp.RequestReadAllBody(req)
	if err != nil {
		http.Error(w, "error 1", 400)
		kmgLog.Log("InfoServerError", err.Error(), kmgHttp.NewLogStruct(req))
		return
	}

	//解密
	b1, err = kmgCrypto.CompressAndEncryptBytesDecode(kmgRpc_Demo_encryptKey, b1)
	if err != nil {
		http.Error(w, "error 2", 400)
		kmgLog.Log("InfoServerError", err.Error(), kmgHttp.NewLogStruct(req))
		return
	}
	outBuf, err := s.handleApiV1(b1)
	if err != nil {
		kmgLog.Log("InfoServerError", err.Error(), kmgHttp.NewLogStruct(req))
		outBuf = append([]byte{kmgRpc_Demo_ResponseCodeError}, err.Error()...)
	} else {
		outBuf = append([]byte{kmgRpc_Demo_ResponseCodeSuccess}, outBuf...)
	}
	//加密
	outBuf = kmgCrypto.CompressAndEncryptBytesEncode(kmgRpc_Demo_encryptKey, outBuf)
	w.WriteHeader(200)
	w.Header().Set("Content-type", "image/jpeg")
	w.Write(outBuf)
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:32,代码来源:generated.go

示例4: deleteDir

//we need to know when is finish delete all file in it ,so we can delete the dir
func (obj *BulkUpyun) deleteDir(upyun_path string, finish_wg *sync.WaitGroup) {
	obj.Tm.AddTask(kmgTask.TaskFunc(func() {
		wg := &sync.WaitGroup{}
		defer obj.Tm.AddTaskNewThread(kmgTask.TaskFunc(func() {
			wg.Wait()
			wg.Add(1)
			obj.deleteFile(upyun_path, wg)
			wg.Wait()
			finish_wg.Done()
		}))
		kmgLog.Log("upyun", "delete dir: "+upyun_path, nil)
		file_list, err := obj.UpYun.ReadDir(upyun_path)
		if err != nil {
			kmgLog.Log("upyunError", err.Error(), err)
			return
		}
		for _, file_info := range file_list {
			file_type := file_info.Type
			file_name := file_info.Name
			this_upyun_path := upyun_path + "/" + file_name
			if file_type == "folder" {
				wg.Add(1)
				obj.deleteDir(this_upyun_path, wg)
			} else if file_type == "file" {
				wg.Add(1)
				obj.deleteFile(this_upyun_path, wg)
			} else {
				kmgLog.Log("upyunError", "unknow file type2:"+file_type, nil)
				return
			}
		}
		return
	}))
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:35,代码来源:bulk_upyun.go

示例5: ServeHTTP

// http-json-api v1
// 1.数据传输使用psk加密,明文不泄漏信息
// 2.使用json序列化信息
// 3.只有部分api
func (s *generateServer_ServiceRpc) ServeHTTP(w http.ResponseWriter, req *http.Request) {
	b1, err := kmgHttp.RequestReadAllBody(req)
	if err != nil {
		http.Error(w, "error 1", 400)
		kmgLog.Log("InfoServerError", err.Error(), kmgHttp.NewLogStruct(req))
		return
	}
	if s.psk != nil {
		//解密
		b1, err = kmgCrypto.CompressAndEncryptBytesDecodeV2(s.psk, b1)
		if err != nil {
			http.Error(w, "error 2", 400)
			kmgLog.Log("InfoServerError", err.Error(), kmgHttp.NewLogStruct(req))
			return
		}
	}
	outBuf, err := s.handleApiV1(b1, w, req)
	if err != nil {
		kmgLog.Log("InfoServerError", err.Error(), kmgHttp.NewLogStruct(req))
		outBuf = append([]byte{1}, err.Error()...) // error
	} else {
		outBuf = append([]byte{2}, outBuf...) // success
	}
	if s.psk != nil {
		//加密
		outBuf = kmgCrypto.CompressAndEncryptBytesEncodeV2(s.psk, outBuf)
	}
	w.WriteHeader(200)
	w.Header().Set("Content-type", "image/jpeg")
	w.Write(outBuf)
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:35,代码来源:rpc_AUTO.go

示例6: httpLog

func httpLog(req httpLogRequest) {
	errStr := ""
	if req.Err != nil {
		errStr = req.Err.Error()
	}
	kmgLog.Log("apiAccess", errStr, req)
	if errStr != "" {
		kmgLog.Log("apiError", errStr, req)
	}
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:10,代码来源:JsonHttpHandler.go

示例7: deleteFile

//delete a file
func (obj *BulkUpyun) deleteFile(upyun_path string, finish_wg *sync.WaitGroup) {
	obj.Tm.AddTask(kmgTask.TaskFunc(func() {
		defer finish_wg.Done()
		kmgLog.Log("upyun", "delete file: "+upyun_path, nil)
		err := obj.UpYun.DeleteFile(upyun_path)
		if err != nil {
			kmgLog.Log("upyunError", "delete file failed!:"+upyun_path+":"+err.Error(), nil)
			return
		}
		return
	}))
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:13,代码来源:bulk_upyun.go

示例8: EasyPush

func (c *Client) EasyPush(config *JpushConfig) (err error) {
	if c.IsActive == false {
		kmgLog.Log("jpush", "Jpush Client is not active,please checkout your configure", c.name, c.IsIosProduct, c.IsActive, config)
		return
	}
	if config.Badge == "" {
		config.Badge = "1"
	}
	nb := jpush.NewNoticeBuilder()
	nb.SetPlatform(jpush.AllPlatform())
	if config.Alias == "" || config.Tag == "" {
		nb.SetAudience(jpush.AllAudience())
	} else {
		au := &jpush.Audience{}
		if config.Alias != "" {
			au.SetAlias([]string{config.Alias})
		}
		if config.Tag != "" {
			au.SetTag([]string{config.Tag})
		}
		nb.SetAudience(au)
	}
	//Android配置
	notice := jpush.NewNoticeAndroid()
	notice.Alert = config.Content
	nb.SetNotice(notice)

	//iOS配置
	iosNotice := jpush.NewNoticeIos()
	iosNotice.Sound = "default"
	iosNotice.Badge = "1"
	iosNotice.Alert = config.Content
	nb.SetNotice(iosNotice)

	op := jpush.NewOptions()
	op.SetApns_production(c.IsIosProduct)
	nb.SetOptions(op)
	ret, err := c.c.Send(nb)
	if err != nil {
		return err
	}
	if ret.Error.Code == 0 {
		kmgLog.Log("jpush", "Push success", c.name, config.Content)
		return nil
	}
	if ret.Error.Code == 1011 {
		kmgLog.Log("jpush", "Not Found User", c.name, config)
		return NotFoundUser
	}
	return fmt.Errorf("code:%d err: %s", ret.Error.Code, ret.Error.Message)
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:51,代码来源:kmgJpush.go

示例9: SendMessage

func SendMessage(massage Massege) (err error) {
	massegeApiUrl := "https://api.submail.cn/message/xsend"
	resp, e := http.PostForm(massegeApiUrl, url.Values{
		//		"appid":     {EmailConfig.Appid},
		//		"signature": {EmailConfig.Signature},
		"appid":     {"10111"},
		"signature": {"142a3e0d66c4dda1e918487b1952b26c"},
		"to":        {massage.To},
		"project":   {massage.ProjectId},
	})
	if e != nil {
		return e
	}
	defer resp.Body.Close()
	body, e := ioutil.ReadAll(resp.Body)
	if e != nil {
		return e
	}
	kmgLog.Log("Submail", string(body), massage)
	data := kmgJson.MustUnmarshalToMapDeleteBOM(body)
	if data["status"] == "error" {
		return errors.New(kmgStrconv.InterfaceToString(data["msg"]))
	}
	return nil
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:25,代码来源:kmgSubmail.go

示例10: LogError

func LogError(err error) {
	s := ""
	if err != nil {
		s = err.Error()
	}
	kmgLog.Log("error", s)
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:7,代码来源:error.go

示例11: XSendMessage

func XSendMessage(message Message) (err error) {
	subMessageUrl := "https://api.submail.cn/message/xsend.json"
	kmgDebug.Println(message.Vars)
	response, err := http.PostForm(subMessageUrl, url.Values{
		"appid":     {MessageConfig.Appid},
		"signature": {MessageConfig.Signature},
		"to":        {message.To},
		"project":   {kmgStrconv.InterfaceToString(message.Project)},
		"vars":      {message.Vars},
	})
	defer response.Body.Close()
	if err != nil {
		return err
	}
	body, err := ioutil.ReadAll(response.Body)
	if err != nil {
		return err
	}
	kmgLog.Log("SubMessage", string(body), message)
	data := kmgJson.MustUnmarshalToMapDeleteBOM(body)
	if data["status"] == "error" {
		return errors.New(kmgStrconv.InterfaceToString(data["msg"]))
	}
	return nil

}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:26,代码来源:kmgSubMessage.go

示例12: returnOutput

func (handler *JsonHttpHandler) returnOutput(w http.ResponseWriter, output *JsonHttpOutput) {
	w.Header().Set("Content-Type", "text/json; charset=utf-8")
	err := json.NewEncoder(w).Encode(output)
	if err != nil {
		kmgLog.Log("apiError", "[JsonHttpHandler.returnOutput] json.NewEncoder(w).Encode(output)"+err.Error(), nil)
	}
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:7,代码来源:JsonHttpHandler.go

示例13: mustNotifyActionV2

func (ot *OverseaTrade) mustNotifyActionV2(ctx *kmgHttp.Context, f func(info OverseaTradeTransaction)) {
	kmgLog.Log("Alipay", "Oversea PayNotifyAction", ctx.GetInMap())
	var err error
	ctx.MustPost()
	info := OverseaTradeTransaction{}
	//info.NotifyId = ctx.MustInStr("notify_id") 这两项没有什么意义.
	//info.NotifyTime = kmgTime.MustFromMysqlFormatInLocation(ctx.MustInStr("notify_time"), kmgTime.BeijingZone)
	info.OutTradeNo = ctx.MustInStr("out_trade_no")

	info.Currency = ctx.MustInStr("currency")
	info.TotalFee, err = kmgStrconv.ParseFloat64(ctx.MustInStr("total_fee"))
	if err != nil {
		panic(err)
	}
	info.TradeStatus = OverseaTradeStatus(ctx.MustInStr("trade_status"))
	info.TradeNo = ctx.MustInStr("trade_no")
	err = ot.md5Verify(ctx.GetInMap())
	if err != nil {
		panic(err)
	}
	err = ot.VerifyNotify(ctx.MustInStr("notify_id"))
	if err != nil {
		panic(err)
	}
	// 向支付宝询问这个订单的情况
	oInfo := ot.MustSingleTransactionQuery(info.OutTradeNo)
	if oInfo.TradeStatus != info.TradeStatus {
		panic("两次查询订单状态不一致")
	}
	info.Subject = oInfo.Subject
	f(info)
	ctx.WriteString("success")
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:33,代码来源:Oversea.go

示例14: Ping

func Ping(address string) Echo {
	p := fastping.NewPinger()
	p.MaxRTT = MaxRtt
	ra, err := net.ResolveIPAddr("ip4:icmp", address)
	handleErr(err)
	p.AddIPAddr(ra)
	echo := Echo{
		Address: address,
	}
	p.OnRecv = func(addr *net.IPAddr, rtt time.Duration) {
		echo.Rtt = rtt
		echo.Status = EchoStatusSuccess
	}
	p.OnIdle = func() {
		if echo.Status == EchoStatusSuccess {
			return
		}
		echo.Status = EchoStatusFail
		echo.Rtt = time.Duration(1e9)
	}
	err = p.Run()
	handleErr(err)
	if echo.Rtt == 0 && echo.Status == EchoStatusSuccess {
		kmgLog.Log("error", "[kmgPing.Ping] echo.Rtt==0 && echo.Status==EchoStatusSuccess", address)
	}
	return echo
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:27,代码来源:kmgPing.go

示例15: UploadFile

//批量上传接口
//upload a file
func (obj *BulkUpyun) UploadFile(upyun_path, local_path string) {
	obj.Tm.AddTask(kmgTask.TaskFunc(func() {
		kmgLog.Log("upyun", "upload file: "+upyun_path, nil)
		file, err := os.Open(local_path)
		if err != nil {
			kmgLog.Log("upyunError", err.Error(), err)
			return
		}
		defer file.Close()
		err = obj.UpYun.WriteFile(upyun_path, file, true)
		if err != nil {
			kmgLog.Log("upyunError", err.Error(), err)
			return
		}
		return
	}))
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:19,代码来源:bulk_upyun.go


注:本文中的github.com/bronze1man/kmg/kmgLog.Log函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。