浏览代码

add ignore file for log files

runningwater 5 年之前
父节点
当前提交
0f8cd8a8e6
共有 5 个文件被更改,包括 7 次插入8 次删除
  1. 2 1
      .gitignore
  2. 2 2
      conf/conf.go
  3. 0 1
      conf/conf_test.go
  4. 0 0
      config.yaml
  5. 3 4
      log_file.go

+ 2 - 1
.gitignore

@@ -42,5 +42,6 @@ Temporary Items
 *.out
 
 # Dependency directories (remove the comment below to include it)
-# vendor/
+vendor/
 
+*.log

+ 2 - 2
conf/conf.go

@@ -26,8 +26,8 @@ func LoadConfig(logger *l4g.Logger) {
     if err != nil {
         panic(err)
     }
-    viper.AddConfigPath(path + "/conf")
-    logger.Debug("配置文件路径为 %s", path+"/conf")
+    viper.AddConfigPath(path)
+    logger.Debug("配置文件路径为 %s", path)
     viper.SetConfigName("config")
     viper.SetConfigType("yaml")
 

+ 0 - 1
conf/conf_test.go

@@ -6,7 +6,6 @@ import (
 )
 
 func TestGetInfo(t *testing.T) {
-    LoadConfig()
     fmt.Println("name: ", GetInfo().Database.Dbname)
     fmt.Println("host: ", GetInfo().Database.Host)
     fmt.Println("user: ", GetInfo().Database.User)

conf/config.yaml → config.yaml


+ 3 - 4
log_file.go

@@ -7,13 +7,12 @@ import (
     "strings"
 )
 
-
-func initLogger() * l4g.Logger {
+func initLogger() *l4g.Logger {
     log := l4g.Logger{}
     filenameOnly := GetCurFilename()
     logFileName := filenameOnly + ".log"
-    log.AddFilter("stdout",l4g.DEBUG,l4g.NewConsoleLogWriter())
-    log.AddFilter("file",l4g.DEBUG,l4g.NewFileLogWriter(logFileName,false))
+    log.AddFilter("stdout", l4g.DEBUG, l4g.NewConsoleLogWriter())
+    log.AddFilter("file", l4g.DEBUG, l4g.NewFileLogWriter(logFileName, false))
     return &log
 }