gspath添加debug信息,改进glog链式操作方法

This commit is contained in:
john
2018-10-11 09:56:01 +08:00
parent 0733164af1
commit e3a491a16b
3 changed files with 9 additions and 7 deletions

View File

@ -18,10 +18,9 @@ func (l *Logger) Cat(category string) *Logger {
logger = l
}
path := l.path.Val()
if path == "" {
path = gfile.Pwd()
if path != "" {
logger.SetPath(path + gfile.Separator + category)
}
logger.SetPath(path + gfile.Separator + category)
return logger
}
@ -33,10 +32,6 @@ func (l *Logger) File(file string) *Logger {
} else {
logger = l
}
path := l.path.Val()
if path == "" {
path = gfile.Pwd()
}
logger.SetFile(file)
return logger
}

View File

@ -106,6 +106,7 @@ func (sp *SPath) Size() int {
// 添加文件监控,当文件删除时,同时也删除搜索结果缓存
func (sp *SPath) addMonitor(name, path string) {
glog.Debug("gspath.addMonitor:", name, path)
gfsnotify.Add(path, func(event *gfsnotify.Event) {
glog.Debug("gspath.monitor:", event)
if event.IsRemove() {

View File

@ -3,8 +3,14 @@ package main
import (
"gitee.com/johng/gf/g"
"gitee.com/johng/gf/g/net/ghttp"
"fmt"
"gitee.com/johng/gf/g/os/gfile"
)
func init() {
fmt.Println(gfile.MainPkgPath())
}
func main() {
s := g.Server()