本文整理汇总了Golang中github.com/gotips/log.Debugf函数的典型用法代码示例。如果您正苦于以下问题:Golang Debugf函数的具体用法?Golang Debugf怎么用?Golang Debugf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Debugf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: execLevelExamples
func execLevelExamples() {
// 默认日志级别 debug
log.Printf("default log level: %s", log.GetLevel())
log.Tracef("IsTraceEnabled? %t", log.IsTraceEnabled())
log.Debugf("IsDebugEnabled? %t", log.IsDebugEnabled())
log.Infof("IsInfoEnabled? %t", log.IsInfoEnabled())
// trace 级别
log.SetLevel(log.Ltrace)
log.Tracef(msgFmt, 1)
// info 级别
log.SetLevel(log.Linfo)
log.Debugf(msgFmt, 2)
log.Infof(msgFmt, 2)
// warn 级别
log.SetLevel(log.Lwarn)
log.Infof(msgFmt, 3)
log.Warnf(msgFmt, 3)
// error 级别
log.SetLevel(log.Lerror)
log.Warnf(msgFmt, 4)
log.Errorf(msgFmt, 4)
// 恢复默认级别,防止影响其他测试
// debug 级别
log.SetLevel(log.Ldebug)
log.Tracef(msgFmt, 5)
log.Debugf(msgFmt, 5)
}
示例2: RefreshAccessToken
// RefreshAccessToken 定时刷新 access_token
func RefreshAccessToken(appId, appSecret string) {
// 内部变量,外部不可以调用
var _token = &accessToken{}
AccessToken = func() string {
_token.mutex.RLock()
defer _token.mutex.RUnlock()
return _token.AccessToken
}
go func() {
url := fmt.Sprintf(tokenURL, appId, appSecret)
tick := time.Tick(refreshTimeout)
for {
new := refresh(url)
log.Debugf("old access token %+v", _token)
log.Debugf("new access token %+v", new)
_token.mutex.Lock()
_token.AccessToken = new.AccessToken
_token.ExpiresIn = new.ExpiresIn
_token.mutex.Unlock()
<-tick // 等待下一个时钟周期到来
}
}()
}
示例3: echoMsgVoice
func echoMsgVoice(m *weixin.RecvVoice) weixin.ReplyMsg {
log.Debugf("%+v", m)
// echo message
ret := &weixin.ReplyVoice{
ToUserName: m.FromUserName,
FromUserName: m.ToUserName,
CreateTime: m.CreateTime,
MediaId: m.MediaId,
}
log.Debugf("%+v", ret)
return ret
}
示例4: EventDefaultHandler
// EventDefaultHandler 注册默认处理器
func EventDefaultHandler(m *weixin.Message) weixin.ReplyMsg {
log.Debugf("%+v", m)
// echo message
ret := &weixin.ReplyText{
ToUserName: m.FromUserName,
FromUserName: m.ToUserName,
CreateTime: m.CreateTime,
Content: fmt.Sprintf("Event=%s", m.Event),
}
log.Debugf("replay message: %+v", ret)
return ret
}
示例5: echoMsgText
func echoMsgText(m *weixin.RecvText) weixin.ReplyMsg {
log.Debugf("receive message: %+v", m)
// echo message
ret := &weixin.ReplyText{
ToUserName: m.FromUserName,
FromUserName: m.ToUserName,
CreateTime: m.CreateTime,
Content: m.FromUserName + ", " + m.Content,
}
log.Debugf("replay message: %+v", ret)
return ret
}
示例6: echoMsgLocation
func echoMsgLocation(m *weixin.RecvLocation) weixin.ReplyMsg {
log.Debugf("%+v", m)
// echo message
ret := &weixin.ReplyText{
ToUserName: m.FromUserName,
FromUserName: m.ToUserName,
CreateTime: m.CreateTime,
Content: weixin.AccessToken(),
}
log.Debugf("replay message: %+v", ret)
return ret
}
示例7: EventViewHandler
// EventViewHandler 注册点击菜单跳转链接时的事件处理器
func EventViewHandler(m *weixin.EventView) weixin.ReplyMsg {
log.Debugf("%+v", m)
// echo message 貌似用户收不到回复的消息???
ret := &weixin.ReplyText{
ToUserName: m.FromUserName,
FromUserName: m.ToUserName,
CreateTime: m.CreateTime,
Content: fmt.Sprintf("Event=%s, EventKey=%s", m.Event, m.EventKey),
}
log.Debugf("replay message: %+v", ret)
return ret
}
示例8: EventSubscribeHandler
// EventSubscribeHandler 注册关注事件处理器
func EventSubscribeHandler(m *weixin.EventSubscribe) weixin.ReplyMsg {
log.Debugf("%+v", m)
// echo message
ret := &weixin.ReplyText{
ToUserName: m.FromUserName,
FromUserName: m.ToUserName,
CreateTime: m.CreateTime,
Content: fmt.Sprintf("Event=%s, EventKey=%s, Ticket=%s", m.Event, m.EventKey, m.Ticket),
}
log.Debugf("replay message: %+v", ret)
return ret
}
示例9: EventTemplateSendJobFinishHandler
// EventTemplateSendJobFinishHandler 模版消息发送结果通知事件
func EventTemplateSendJobFinishHandler(m *weixin.EventTemplateSendJobFinish) weixin.ReplyMsg {
log.Debugf("%+v", m)
// echo message
ret := &weixin.ReplyText{
ToUserName: m.FromUserName,
FromUserName: m.ToUserName,
CreateTime: m.CreateTime,
Content: fmt.Sprintf("Event=%s, MsgID=%d, Status=%s", m.Event, m.MsgID, m.Status),
}
log.Debugf("replay message: %+v", ret)
return ret
}
示例10: echoMsgImage
func echoMsgImage(m *weixin.RecvImage) weixin.ReplyMsg {
log.Debugf("%+v", m)
// echo message
ret := &weixin.ReplyImage{
ToUserName: m.FromUserName,
FromUserName: m.ToUserName,
CreateTime: m.CreateTime,
PicUrl: m.PicUrl,
MediaId: m.MediaId,
}
log.Debugf("%+v", ret)
return ret
}
示例11: EventLocationHandler
// EventLocationHandler 注册上报地理位置事件处理器
func EventLocationHandler(m *weixin.EventLocation) weixin.ReplyMsg {
log.Debugf("%+v", m)
// echo message
ret := &weixin.ReplyText{
ToUserName: m.FromUserName,
FromUserName: m.ToUserName,
CreateTime: m.CreateTime,
Content: fmt.Sprintf("Latitude=%.6f, Longitude=%.6f, Precision=%.6f",
m.Latitude, m.Longitude, m.Precision),
}
log.Debugf("replay message: %+v", ret)
return ret
}
示例12: echoMsgLink
func echoMsgLink(m *weixin.RecvLink) weixin.ReplyMsg {
log.Debugf("%+v", m)
// 回复图文消息
return nil
}
示例13: main
func main() {
addr := ":3080"
weixin.Initialize(originId, appId, appSecret, token, encodingAESKey)
weixin.RecvTextHandler = echoMsgText // 注册文本消息处理器
weixin.RecvImageHandler = echoMsgImage // 注册图片消息处理器
weixin.RecvVoiceHandler = echoMsgVoice // 注册语音消息处理器
weixin.RecvVideoHandler = echoMsgVideo // 注册视频消息处理器
weixin.RecvShortVideoHandler = echoMsgShortVideo // 注册小视频消息处理器
weixin.RecvLocationHandler = echoMsgLocation // 注册位置消息处理器
weixin.RecvLinkHandler = echoMsgLink // 注册链接消息处理器
weixin.RecvDefaultHandler = defaultHandler // 注册默认处理器
weixin.EventSubscribeHandler = EventSubscribeHandler // 注册关注事件处理器
weixin.EventUnsubscribeHandler = EventUnsubscribeHandler // 注册取消关注事件处理器
weixin.EventLocationHandler = EventLocationHandler // 注册上报地理位置事件处理器
weixin.EventClickHandler = EventClickHandler // 注册点击自定义菜单事件处理器
weixin.EventViewHandler = EventViewHandler // 注册点击菜单跳转链接时的事件处理器
// 模版消息发送结果通知事件
weixin.EventTemplateSendJobFinishHandler = EventTemplateSendJobFinishHandler
weixin.EventDefaultHandler = EventDefaultHandler // 注册默认处理器
http.HandleFunc("/weixin", weixin.HandleAccess)
http.Handle("/", http.FileServer(http.Dir("examples/static")))
// http.Handle("/admin/", http.StripPrefix("/admin/", http.FileServer(http.Dir("admin"))))
log.Debugf("server is running at %s", addr)
http.ListenAndServe(addr, nil)
}
示例14: echoMsgShortVideo
func echoMsgShortVideo(m *weixin.RecvVideo) weixin.ReplyMsg {
log.Debugf("%+v", m)
// MediaId ???
ret := &weixin.ReplyVideo{
ToUserName: m.FromUserName,
FromUserName: m.ToUserName,
CreateTime: m.CreateTime,
MediaId: m.ThumbMediaId,
Title: "shortvideo",
Description: "thist is a test desc...",
}
log.Debugf("%+v", ret)
return ret
}
示例15: parseBody
func parseBody(encryptType, timestamp, nonce, msgSignature string, body []byte) (msg *Message, err error) {
msg = &Message{}
// 如果报文被加密了,先要验签解密
if encryptType == "aes" {
encMsg := &EncMessage{}
// 解析加密的 xml
err = xml.Unmarshal(body, encMsg)
if err != nil {
return nil, err
}
msg.ToUserName = encMsg.ToUserName
msg.Encrypt = encMsg.Encrypt
if !CheckSignature(Token, timestamp, nonce, encMsg.Encrypt, msgSignature) {
return nil, errors.New("check signature error")
}
body, err = DecryptMsg(encMsg.Encrypt, EncodingAESKey, AppId)
if err != nil {
return nil, err
}
log.Debugf("receive: %s", body)
}
// 解析 xml
err = xml.Unmarshal(body, msg)
if err != nil {
return nil, err
}
return msg, nil
}