本文整理匯總了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
}