mirror of
https://gitee.com/johng/gf
synced 2026-06-07 10:22:11 +08:00
add more inernal logging points for core components
This commit is contained in:
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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`)
|
||||
}
|
||||
|
||||
@ -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"), "")
|
||||
})
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user