github.com/angenalZZZ/gofunc@v0.0.0-20210507121333-48ff1be3917b/log/log_test.go (about)

     1  package log
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/angenalZZZ/gofunc/configfile"
     6  	"testing"
     7  )
     8  
     9  func TestYamlFileConfig(t *testing.T) {
    10  	// 配置文件
    11  	filename := "log.yaml"
    12  	logCfg := new(AConfig)
    13  	if err := configfile.YamlTo(filename, logCfg); err != nil {
    14  		t.Fatal(err)
    15  	}
    16  
    17  	// 初始化配置
    18  	Log = Init(logCfg.Log)
    19  
    20  	// 写日志
    21  	Log.Debug().Msgf("Yaml File: %s, %d:%d", filename)
    22  	Log.Info().Str("Config", fmt.Sprintf("%+v", logCfg.Log)).Send()
    23  	Log.Info().Timestamp().Msg("Test finish.\n ok!")
    24  }