本文整理汇总了Golang中golanger/com/log.Debug函数的典型用法代码示例。如果您正苦于以下问题:Golang Debug函数的具体用法?Golang Debug怎么用?Golang Debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Debug函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: checkHtmlDoWrite
func (p *Page) checkHtmlDoWrite(tplFi, htmlFi os.FileInfo, htmlErr error) bool {
var doWrite bool
log.Debug("<Page.checkHtmlDoWrite> ", "p.Config.AutoGenerateHtmlCycleTime:", p.Config.AutoGenerateHtmlCycleTime)
if p.Config.AutoGenerateHtmlCycleTime <= 0 {
doWrite = true
} else {
if htmlErr != nil {
doWrite = true
} else {
log.Debug("<Page.checkHtmlDoWrite> ", "tplFi.ModTime().Unix():", tplFi.ModTime().Unix())
log.Debug("<Page.checkHtmlDoWrite> ", "htmlFi.ModTime().Unix():", htmlFi.ModTime().Unix())
switch {
case tplFi.ModTime().Unix() >= htmlFi.ModTime().Unix():
doWrite = true
case time.Now().Unix()-htmlFi.ModTime().Unix() >= p.Config.AutoGenerateHtmlCycleTime:
doWrite = true
default:
globalTplCache := p.site.GetTemplateCache("globalTpl")
log.Debug("<Page.checkHtmlDoWrite> ", `globalTplCache.ModTime:`, globalTplCache.ModTime)
if globalTplCache.ModTime > 0 && globalTplCache.ModTime >= htmlFi.ModTime().Unix() {
doWrite = true
}
}
}
}
return doWrite
}
开发者ID:wenhaokl,项目名称:framework,代码行数:29,代码来源:page.go
示例2: filterDoMethod
func (p *Page) filterDoMethod(tpc reflect.Type, vpc reflect.Value, action string, rvr reflect.Value, rvw reflect.Value) {
log.Debug("<Page.filterDoMethod> ", "action:", action)
if aarv := p.callMethod(tpc, vpc, action, rvr, rvw); len(aarv) == 1 {
if ma, tok := aarv[0].Interface().([]map[string]string); tok {
log.Debug("<Page.filterDoMethod> ", "FilterMap:", ma)
for _, filter := range ma {
doFilter := false
doMethod := false
doParam := false
method, mok := filter["_FILTER"]
if mok {
filterType, found := filter[p.CurrentAction]
if !found && filter["_ALL"] == "allow" {
doFilter = true
} else if found && filterType == "allow" {
doFilter = true
}
}
if doFilter {
if rm, ok := filter["_METHOD"]; !ok {
doMethod = true
} else {
reqMethods := strings.Split(rm, ",")
for _, v := range reqMethods {
r := rvr.Interface().(*http.Request)
if r.Method == strings.ToUpper(v) {
doMethod = true
break
}
}
}
if rmp, ok := filter["_PARAM"]; !ok {
doParam = true
} else {
reqParams := strings.Split(rmp, ",")
for _, v := range reqParams {
_, vgok := p.GET[v]
_, vpok := p.POST[v]
if vgok || vpok {
doParam = true
break
}
}
}
if doMethod && doParam {
p.callMethod(tpc, vpc, "Filter_"+method, rvr, rvw)
}
}
}
}
}
}
开发者ID:wenhaokl,项目名称:framework,代码行数:56,代码来源:page.go
示例3: initModule
func (p *Page) initModule(w http.ResponseWriter, r *http.Request) {
if p.site.supportSession {
switch p.Config.SessionType {
case "file":
p.SESSION = p.FileSession.Get(w, r)
case "memory":
p.SESSION = p.MemorySession.Get(w, r)
default:
p.SESSION = p.MemorySession.Get(w, r)
}
var ok bool
p.ONCE_SESSION, ok = p.SESSION["__ONCE"]
if ok {
log.Debug("<Page.Init> ", `p.SESSION["__ONCE"] to set:`, p.ONCE_SESSION)
delete(p.SESSION, "__ONCE")
log.Debug("<Page.Init> ", `p.SESSION["__ONCE"] to delete:`, p.SESSION["__ONCE"])
}
}
if p.site.supportCookieSession {
p.COOKIE_SESSION = p.CookieSession.Get(r)
}
if p.site.supportI18n {
p.LANG = func() map[string]string {
log.Debug("<Page.Init> ", `p.TARGET_LANG: `, p.TARGET_LANG)
if p.TARGET_LANG == "" {
p.TARGET_LANG = strings.TrimSpace(r.Header.Get("Accept-Language"))
if i := strings.Index(p.TARGET_LANG, ","); i != -1 {
p.TARGET_LANG = p.TARGET_LANG[:i]
}
}
return p.I18n.Lang(p.TARGET_LANG)
}()
}
if p.site.base.header != nil || len(p.site.base.header) > 0 {
log.Debug("<Page.Init> ", "p.site.base.header:", p.site.base.header)
for t, s := range p.site.base.header {
for _, v := range s {
w.Header().Add(t, v)
}
}
}
}
开发者ID:wenhaokl,项目名称:framework,代码行数:48,代码来源:page.go
示例4: handleRoute
func (p *Page) handleRoute(i interface{}) {
http.HandleFunc(p.site.Root, func(w http.ResponseWriter, r *http.Request) {
p.site.base.mutex.Lock()
if p.Config.Reload() {
p.reset(true)
}
if p.UrlManage.Manage() {
newUrl := p.UrlManage.ReWrite(w, r)
if newUrl == "redirect" {
p.site.base.mutex.Unlock()
return
} else {
r.URL, _ = url.Parse(newUrl)
}
}
if p.site.supportI18n {
if err := p.I18n.Setup(p.Config.DefaultLocalePath, p.Config.DefaultLanguage); err != nil {
log.Panic("<Page.handleRoute> ", "I18n(Setup):", err)
}
}
p.setCurrentInfo(r.URL.Path)
p.Template = p.CurrentController + p.currentFileName
p.site.base.mutex.Unlock()
log.Debug("<Page.handleRoute> ", "p.Template:", p.Template)
if !p.loadGeneratedHtml(w, r) {
p.routeController(i, w, r)
}
})
}
开发者ID:wenhaokl,项目名称:framework,代码行数:33,代码来源:page.go
示例5: readFiles
func readFiles(files ...string) []byte {
lfs := len(files)
chContent := make(chan []byte, lfs)
for _, file := range files {
go func(chContent chan []byte, configPath string) {
chContent <- format(configPath)
}(chContent, file)
}
bytess := make([][]byte, 0, lfs)
for i := 1; i <= lfs; i++ {
content := <-chContent
if len(content) != 0 {
bytess = append(bytess, content)
}
}
buf := bytes.NewBufferString(`{`)
buf.Write(bytes.Join(bytess, []byte(`,`)))
buf.WriteString(`}`)
var contentBuf bytes.Buffer
err := json.Compact(&contentBuf, buf.Bytes())
if err != nil {
log.Debug("<readFiles> jsonData: ", buf.String())
log.Fatal("<readFiles> error: ", err)
}
return contentBuf.Bytes()
}
开发者ID:golangers,项目名称:config,代码行数:33,代码来源:config.go
示例6: loadGeneratedHtml
func (p *Page) loadGeneratedHtml(w http.ResponseWriter, r *http.Request) (b bool) {
log.Debug("<Page.loadGeneratedHtml> ", "p.Config.SupportTemplate:", p.Config.SupportTemplate)
log.Debug("<Page.loadGeneratedHtml> ", "p.Config.LoadStaticHtmlWithLogic:", p.Config.LoadStaticHtmlWithLogic)
log.Debug("<Page.loadGeneratedHtml> ", "p.Config.AutoGenerateHtml:", p.Config.AutoGenerateHtml)
if p.Config.SupportTemplate && !p.Config.LoadStaticHtmlWithLogic && p.Config.AutoGenerateHtml {
tplFi, tplErr := os.Stat(p.Config.TemplateDirectory + p.Config.ThemeDirectory + p.Template)
if tplErr != nil {
log.Error("<Page.loadGeneratedHtml> ", tplErr)
} else {
p.site.base.rmutex.RLock()
tmplCache := p.site.GetTemplateCache(p.Template)
p.site.base.rmutex.RUnlock()
if tplFi.ModTime().Unix() > tmplCache.ModTime {
return false
}
}
htmlFile := ""
assetsHtmlDir := p.Config.AssetsDirectory + p.Config.HtmlDirectory
if strings.HasPrefix(p.Template, p.Config.IndexDirectory) {
htmlFile = assetsHtmlDir + strings.Replace(p.Template, p.Config.IndexDirectory, "", 1)
} else {
htmlFile = assetsHtmlDir + p.Template
}
if r.URL.RawQuery != "" {
htmlFile += "?" + r.URL.RawQuery
}
if htmlFi, htmlErr := os.Stat(htmlFile); htmlErr == nil {
if p.checkHtmlDoWrite(tplFi, htmlFi, htmlErr) {
}
htmlContent, err := ioutil.ReadFile(htmlFile)
if err == nil {
w.Header().Add("Content-Length", strconv.FormatInt(htmlFi.Size(), 10))
w.Header().Add("Last-Modified", htmlFi.ModTime().UTC().Format("Mon, 02 Jan 2006 15:04:05 GMT"))
w.Write(htmlContent)
return true
}
}
}
return
}
开发者ID:wenhaokl,项目名称:framework,代码行数:46,代码来源:page.go
示例7: setCurrentInfo
func (p *Page) setCurrentInfo(path string) {
urlPath, fileName := filepath.Split(path)
if urlPath == p.site.Root {
urlPath = p.site.Root + p.Config.IndexDirectory
}
if fileName == "" {
fileName = p.Config.IndexPage
}
p.currentPath = urlPath
log.Debug("<Page.setCurrentInfo> ", "p.currentPath:", p.currentPath)
p.currentFileName = fileName
log.Debug("<Page.setCurrentInfo> ", "p.currentFileName:", p.currentFileName)
p.CurrentController = urlPath[len(p.site.Root):]
log.Debug("<Page.setCurrentInfo> ", "p.CurrentController:", p.CurrentController)
p.CurrentAction = strings.Replace(strings.Title(strings.Replace(p.currentFileName[:len(p.currentFileName)-len(filepath.Ext(p.currentFileName))], "_", " ", -1)), " ", "", -1)
log.Debug("<Page.setCurrentInfo> ", "p.CurrentAction:", p.CurrentAction)
}
开发者ID:wenhaokl,项目名称:framework,代码行数:19,代码来源:page.go
示例8: handleRootStatic
func (p *Page) handleRootStatic(files string) {
aFile := strings.Split(files, ",")
for _, file := range aFile {
http.HandleFunc(p.site.Root+file, func(w http.ResponseWriter, r *http.Request) {
staticPath := p.Config.AssetsDirectory + file
log.Debug("<Page.handleRootStatic> ", "staticPath:", staticPath)
http.ServeFile(w, r, staticPath)
})
}
}
开发者ID:wenhaokl,项目名称:framework,代码行数:10,代码来源:page.go
示例9: setStaticDocument
func (p *Page) setStaticDocument() {
fileNameNoExt := p.currentFileName[:len(p.currentFileName)-len(filepath.Ext(p.currentFileName))]
cssFi, cssErr := os.Stat(p.Config.StaticCssDirectory + p.currentPath)
jsFi, jsErr := os.Stat(p.Config.StaticJsDirectory + p.currentPath)
imgFi, imgErr := os.Stat(p.Config.StaticImgDirectory + p.currentPath)
if cssErr == nil && cssFi.IsDir() {
cssPath := strings.Trim(p.currentPath, "/")
DcssPath := p.Config.StaticCssDirectory + cssPath + "/"
p.Document.Css[cssPath] = p.site.Root + DcssPath[len(p.Config.AssetsDirectory):]
log.Debug("<Page.setStaticDocument> ", "p.Document.Css["+cssPath+"]:", p.Document.Css[cssPath])
_, errgcss := os.Stat(DcssPath + "global.css")
_, errcss := os.Stat(DcssPath + fileNameNoExt + ".css")
if errgcss == nil {
p.Document.GlobalIndexCssFile = p.Document.Css[cssPath] + "global.css"
log.Debug("<Page.setStaticDocument> ", "p.Document.GlobalIndexCssFile:", p.Document.GlobalIndexCssFile)
}
if errcss == nil {
p.Document.IndexCssFile = p.Document.Css[cssPath] + fileNameNoExt + ".css"
log.Debug("<Page.setStaticDocument> ", "p.Document.IndexCssFile:", p.Document.IndexCssFile)
}
}
if jsErr == nil && jsFi.IsDir() {
jsPath := strings.Trim(p.currentPath, "/")
DjsPath := p.Config.StaticJsDirectory + jsPath + "/"
p.Document.Js[jsPath] = p.site.Root + DjsPath[len(p.Config.AssetsDirectory):]
log.Debug("<Page.setStaticDocument> ", "p.Document.Js["+jsPath+"]:", p.Document.Js[jsPath])
_, errgjs := os.Stat(DjsPath + "global.js")
_, errjs := os.Stat(DjsPath + fileNameNoExt + ".js")
if errgjs == nil {
p.Document.GlobalIndexJsFile = p.Document.Js[jsPath] + "global.js"
log.Debug("<Page.setStaticDocument> ", "p.Document.GlobalIndexJsFile:", p.Document.GlobalIndexJsFile)
}
if errjs == nil {
p.Document.IndexJsFile = p.Document.Js[jsPath] + fileNameNoExt + ".js"
log.Debug("<Page.setStaticDocument> ", "p.Document.IndexJsFile:", p.Document.IndexJsFile)
}
}
if imgErr == nil && imgFi.IsDir() {
imgPath := strings.Trim(p.currentPath, "/")
DimgPath := p.Config.StaticImgDirectory + imgPath + "/"
p.Document.Img[imgPath] = p.site.Root + DimgPath[len(p.Config.AssetsDirectory):]
log.Debug("<Page.setStaticDocument> ", "p.Document.Img["+imgPath+"]:", p.Document.Img[imgPath])
}
}
开发者ID:wenhaokl,项目名称:framework,代码行数:54,代码来源:page.go
示例10: load
func (c *Config) load(data []byte) {
err := json.Unmarshal(data, c)
if err != nil {
log.Debug("<Config.Load> jsonData: ", string(data))
log.Fatal("<Config.Load> error: ", err)
}
c.UploadDirectory = c.AssetsDirectory + c.StaticDirectory + c.UploadDirectory
c.ThemeDirectory = c.ThemeDirectory + c.Theme + "/"
c.StaticCssDirectory = c.AssetsDirectory + c.StaticDirectory + c.ThemeDirectory + c.StaticCssDirectory
c.StaticJsDirectory = c.AssetsDirectory + c.StaticDirectory + c.ThemeDirectory + c.StaticJsDirectory
c.StaticImgDirectory = c.AssetsDirectory + c.StaticDirectory + c.ThemeDirectory + c.StaticImgDirectory
}
开发者ID:wenhaokl,项目名称:framework,代码行数:13,代码来源:config.go
示例11: Load
func (c *Config) Load(i interface{}) *Config {
mu.RLock()
data := c.data
mu.RUnlock()
err := json.Unmarshal(data, i)
if err != nil {
log.Debug("<Config.Load> jsonData: ", c.String())
log.Fatal("<Config.Load> error: ", err)
}
return c
}
开发者ID:golangers,项目名称:config,代码行数:13,代码来源:config.go
示例12: Lang
func (i *I18nManager) Lang(lang string) map[string]string {
lang = strings.ToLower(lang)
err := i.Load(lang)
if err != nil {
lang = i.defaultLanguage
log.Debug("<I18nManager.Lang> ", `Load error: `, err)
}
i.rmutex.RLock()
msgs := i.languages[lang]
i.rmutex.RUnlock()
return msgs
}
开发者ID:golangers,项目名称:i18n,代码行数:14,代码来源:i18n.go
示例13: Data
func Data(data string) *Config {
data = `{` + data + `}`
var buf bytes.Buffer
err := json.Compact(&buf, []byte(data))
if err != nil {
log.Debug("<Data> jsonData: ", data)
log.Fatal("<Data> error: ", err)
}
return &Config{
dataType: "data",
data: buf.Bytes(),
}
}
开发者ID:golangers,项目名称:config,代码行数:14,代码来源:config.go
示例14: handleStatic
func (p *Page) handleStatic() {
http.HandleFunc(p.Document.Static, func(w http.ResponseWriter, r *http.Request) {
if p.UrlManage.Manage() {
newUrl := p.UrlManage.ReWrite(w, r)
if newUrl == "redirect" {
p.site.base.mutex.Unlock()
return
} else {
r.URL, _ = url.Parse(newUrl)
}
}
staticPath := p.Config.AssetsDirectory + p.Config.StaticDirectory + r.URL.Path[len(p.Document.Static):]
log.Debug("<Page.handleStatic> ", "staticPath:", staticPath)
http.ServeFile(w, r, staticPath)
})
}
开发者ID:wenhaokl,项目名称:framework,代码行数:17,代码来源:page.go
示例15: callMethod
func (p *Page) callMethod(tpc reflect.Type, vpc reflect.Value, action string, rvr reflect.Value, rvw reflect.Value) []reflect.Value {
arv := []reflect.Value{}
if rm, ok := tpc.MethodByName(action); ok {
mt := rm.Type
log.Debug("<Page.callMethod> ", mt.String()+".NumIn():", mt.NumIn())
switch mt.NumIn() {
case 2:
if mt.In(1) == rvr.Type() {
arv = vpc.MethodByName(action).Call([]reflect.Value{rvr})
} else {
arv = vpc.MethodByName(action).Call([]reflect.Value{rvw})
}
case 3:
arv = vpc.MethodByName(action).Call([]reflect.Value{rvw, rvr})
default:
arv = vpc.MethodByName(action).Call([]reflect.Value{})
}
}
return arv
}
开发者ID:wenhaokl,项目名称:framework,代码行数:21,代码来源:page.go
示例16: handleStaticHtml
func (p *Page) handleStaticHtml() {
StaticHtmlDir := p.Config.SiteRoot + p.Config.HtmlDirectory
http.HandleFunc(StaticHtmlDir, func(w http.ResponseWriter, r *http.Request) {
if p.UrlManage.Manage() {
newUrl := p.UrlManage.ReWrite(w, r)
if newUrl == "redirect" {
p.site.base.mutex.Unlock()
return
} else {
r.URL, _ = url.Parse(newUrl)
}
}
staticPath := p.Config.AssetsDirectory + p.Config.HtmlDirectory + r.URL.Path[len(StaticHtmlDir):]
if r.URL.RawQuery != "" {
staticPath += "?" + r.URL.RawQuery
}
log.Debug("<Page.handleStatic> ", "staticPath:", staticPath)
http.ServeFile(w, r, staticPath)
})
}
开发者ID:wenhaokl,项目名称:framework,代码行数:22,代码来源:page.go
示例17: reset
func (p *Page) reset(update bool) {
p.setLog(p.Config.SupportLog, p.Config.LogWriteTo, p.Config.LogLevel)
p.setUrlManage(p.Config.SupportUrlManage, p.Config.SupportUrlManageWithCache, p.Config.UrlManageRule)
if update {
if p.site.supportSession != p.Config.SupportSession {
p.site.supportSession = p.Config.SupportSession
}
if p.site.supportCookieSession != p.Config.SupportCookieSession {
p.site.supportCookieSession = p.Config.SupportCookieSession
}
if p.site.supportI18n != p.Config.SupportI18n {
p.site.supportI18n = p.Config.SupportI18n
}
if p.Document.Theme != p.Config.Theme {
p.Document.Theme = p.Config.Theme
}
if p.Document.Static != p.Config.SiteRoot+p.Config.StaticDirectory {
p.Document.Static = p.Config.SiteRoot + p.Config.StaticDirectory
}
if p.site.Root == p.Config.SiteRoot {
return
} else {
log.Info("<Page.reset> ", "p.Config.SiteRoot be changed:", p.Config.SiteRoot)
p.SetDefaultController(p.GetController(p.Config.IndexDirectory))
p.UpdateController(p.site.Root, p.Config.SiteRoot, p.DefaultController)
p.site.Root = p.Config.SiteRoot
}
} else {
p.site.supportSession = p.Config.SupportSession
p.site.supportCookieSession = p.Config.SupportCookieSession
p.site.supportI18n = p.Config.SupportI18n
p.Document.Theme = p.Config.Theme
p.site.Root = p.Config.SiteRoot
p.Document.Static = p.site.Root + p.Config.StaticDirectory
p.SetDefaultController(p.GetController(p.Config.IndexDirectory))
p.RegisterController(p.site.Root, p.DefaultController)
p.site.globalTemplate = template.New("globalTpl").Funcs(p.site.templateFunc)
}
if globalCssFi, err := os.Stat(p.Config.StaticCssDirectory + "/global/"); err == nil && globalCssFi.IsDir() {
DcssPath := p.Config.StaticCssDirectory + "global/"
p.Document.Css["global"] = p.site.Root + DcssPath[len(p.Config.AssetsDirectory):]
log.Debug("<Page.reset> ", `p.Document.Css["global"]:`, p.Document.Css["global"])
if _, err := os.Stat(DcssPath + "global.css"); err == nil {
p.Document.GlobalCssFile = p.Document.Css["global"] + "global.css"
}
}
if globalJsFi, err := os.Stat(p.Config.StaticJsDirectory + "/global/"); err == nil && globalJsFi.IsDir() {
DjsPath := p.Config.StaticJsDirectory + "global/"
p.Document.Js["global"] = p.site.Root + DjsPath[len(p.Config.AssetsDirectory):]
log.Debug("<Page.reset> ", `p.Document.Js["global"]:`, p.Document.GlobalCssFile)
if _, err := os.Stat(DjsPath + "global.js"); err == nil {
p.Document.GlobalJsFile = p.Document.Js["global"] + "global.js"
}
}
if globalImgFi, err := os.Stat(p.Config.StaticImgDirectory + "/global/"); err == nil && globalImgFi.IsDir() {
DimgPath := p.Config.StaticImgDirectory + "global/"
p.Document.Img["global"] = p.site.Root + DimgPath[len(p.Config.AssetsDirectory):]
log.Debug("<Page.reset> ", `p.Document.Img["global"]:`, p.Document.Img["global"])
}
if globalTplFi, err := os.Stat(p.Config.TemplateDirectory + p.Config.ThemeDirectory + p.Config.TemplateGlobalDirectory); err != nil {
log.Error("<Page.reset> ", err)
} else {
p.setGlobalTpl(globalTplFi.ModTime().Unix(), false)
}
}
开发者ID:wenhaokl,项目名称:framework,代码行数:76,代码来源:page.go
注:本文中的golanger/com/log.Debug函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论