add more inernal logging points for core components

This commit is contained in:
John
2020-02-24 21:09:19 +08:00
parent c70bc7c96a
commit 42fd583bfd
21 changed files with 83 additions and 44 deletions

View File

@ -30,6 +30,9 @@ func init() {
}
builtInVarMap["gfVersion"] = gf.VERSION
builtInVarMap["goVersion"] = runtime.Version()
intlog.Printf("build variables: %+v", builtInVarMap)
} else {
intlog.Print("no build variables")
}
}

View File

@ -6,7 +6,10 @@
package gcfg
import "github.com/gogf/gf/container/gmap"
import (
"github.com/gogf/gf/container/gmap"
"github.com/gogf/gf/internal/intlog"
)
var (
// Customized configuration content.
@ -41,9 +44,9 @@ func GetContent(file ...string) string {
return configs.Get(name)
}
// RemoveConfig removes the global configuration with specified <file>.
// RemoveContent removes the global configuration with specified <file>.
// If <name> is not passed, it removes configuration of the default group name.
func RemoveConfig(file ...string) {
func RemoveContent(file ...string) {
name := DEFAULT_CONFIG_FILE
if len(file) > 0 {
name = file[0]
@ -57,6 +60,8 @@ func RemoveConfig(file ...string) {
configs.Remove(name)
}
})
intlog.Printf(`RemoveContent: %s`, name)
}
// ClearContent removes all global configuration contents.
@ -68,4 +73,6 @@ func ClearContent() {
v.(*Config).jsons.Clear()
}
})
intlog.Print(`RemoveConfig`)
}

View File

@ -428,7 +428,7 @@ func TestCfg_Config(t *testing.T) {
gtest.Assert(gcfg.GetContent("config.yml"), "gf")
gcfg.SetContent("gf1", "config.yml")
gtest.Assert(gcfg.GetContent("config.yml"), "gf1")
gcfg.RemoveConfig("config.yml")
gcfg.RemoveContent("config.yml")
gcfg.ClearContent()
gtest.Assert(gcfg.GetContent("name"), "")
})

View File

@ -11,6 +11,7 @@ import (
"errors"
"fmt"
"github.com/gogf/gf/container/gset"
"github.com/gogf/gf/internal/intlog"
"time"
"github.com/fsnotify/fsnotify"
@ -94,6 +95,7 @@ func New() (*Watcher, error) {
if watcher, err := fsnotify.NewWatcher(); err == nil {
w.watcher = watcher
} else {
intlog.Printf("New watcher failed: %v", err)
return nil, err
}
w.startWatchLoop()

View File

@ -43,6 +43,8 @@ func (w *Watcher) AddOnce(name, path string, callbackFunc func(event *Event), re
if fileIsDir(subPath) {
if err := w.watcher.Add(subPath); err != nil {
intlog.Error(err)
} else {
intlog.Printf("watcher adds monitor for: %s", subPath)
}
}
}
@ -85,6 +87,8 @@ func (w *Watcher) addWithCallbackFunc(name, path string, callbackFunc func(event
// Add the path to underlying monitor.
if err := w.watcher.Add(path); err != nil {
intlog.Error(err)
} else {
intlog.Printf("watcher adds monitor for: %s", path)
}
// Add the callback to global callback map.
callbackIdMap.Set(callback.Id, callback)

View File

@ -100,6 +100,8 @@ func (w *Watcher) startEventLoop() {
// We need no worry about the repeat adding.
if err := w.watcher.Add(event.Path); err != nil {
intlog.Error(err)
} else {
intlog.Printf("fake remove event, watcher re-adds monitor for: %s", event.Path)
}
// Change the event to RENAME, which means it renames itself to its origin name.
event.Op = RENAME
@ -114,6 +116,8 @@ func (w *Watcher) startEventLoop() {
// We need no worry about the repeat adding.
if err := w.watcher.Add(event.Path); err != nil {
intlog.Error(err)
} else {
intlog.Printf("fake rename event, watcher re-adds monitor for: %s", event.Path)
}
// Change the event to CHMOD.
event.Op = CHMOD
@ -130,6 +134,8 @@ func (w *Watcher) startEventLoop() {
if fileIsDir(subPath) {
if err := w.watcher.Add(subPath); err != nil {
intlog.Error(err)
} else {
intlog.Printf("folder creation event, watcher adds monitor for: %s", subPath)
}
}
}
@ -137,6 +143,8 @@ func (w *Watcher) startEventLoop() {
// If it's a file, it directly adds it to monitor.
if err := w.watcher.Add(event.Path); err != nil {
intlog.Error(err)
} else {
intlog.Printf("file creation event, watcher adds monitor for: %s", event.Path)
}
}

View File

@ -57,7 +57,7 @@ func (l *Logger) SetConfig(config Config) error {
return err
}
}
intlog.Print(l.config)
intlog.Printf("SetConfig: %+v", l.config)
return nil
}

View File

@ -8,6 +8,7 @@ package gres
import (
"fmt"
"github.com/gogf/gf/internal/intlog"
"os"
"path/filepath"
"strings"
@ -41,6 +42,7 @@ func New() *Resource {
func (r *Resource) Add(content string, prefix ...string) error {
files, err := UnpackContent(content)
if err != nil {
intlog.Printf("Add resource files failed: %v", err)
return err
}
namePrefix := ""
@ -51,6 +53,7 @@ func (r *Resource) Add(content string, prefix ...string) error {
files[i].resource = r
r.tree.Set(namePrefix+files[i].file.Name, files[i])
}
intlog.Printf("Add %d files to resource manager", r.tree.Size())
return nil
}

View File

@ -30,7 +30,6 @@ type Config struct {
// SetConfig sets the configuration for view.
func (view *View) SetConfig(config Config) error {
intlog.Printf("%+v", config)
var err error
if len(config.Paths) > 0 {
for _, v := range config.Paths {
@ -52,6 +51,8 @@ func (view *View) SetConfig(config Config) error {
// Clear global template object cache.
// It's just cache, do not hesitate clearing it.
templates.Clear()
intlog.Printf("SetConfig: %+v", view.config)
return nil
}