Browse Source

更新配置文件的统一化,并修改zap的level为info

SliverHorn 4 years ago
parent
commit
373c774f58
3 changed files with 30 additions and 37 deletions
  1. 13 20
      server/config.yaml
  2. 14 14
      server/config/config.go
  3. 3 3
      server/utils/email.go

+ 13 - 20
server/config.yaml

@@ -84,33 +84,26 @@ captcha:
   img-width: 240
   img-height: 80
 
-# logger configuration
-log:
-  prefix: '[GIN-VUE-ADMIN]'
-  log-file: true
-  stdout: 'DEBUG'
-  file: 'DEBUG'
-
 # zap logger configuration
 zap:
   # 可使用 "debug", "info", "warn", "error", "dpanic", "panic", "fatal",
-  level: 'debug'
+  level: 'info'
   # console: 控制台, json: json格式输出
   format: 'console'
   prefix: '[GIN-VUE-ADMIN]'
   director: 'log'
-  link_name: 'latest_log'
-  show_line: true
+  link-name: 'latest_log'
+  show-line: true
   # LowercaseLevelEncoder:小写, LowercaseColorLevelEncoder:小写带颜色,CapitalLevelEncoder: 大写, CapitalColorLevelEncoder: 大写带颜色,
-  encode_level: 'LowercaseColorLevelEncoder'
-  stacktrace_key: 'stacktrace'
-  log_in_console: true
+  encode-level: 'LowercaseColorLevelEncoder'
+  stacktrace-key: 'stacktrace'
+  log-in-console: true
 
 email:
-  email_from: '[email protected]'
-  email_nick_name: 'test'
-  email_secret: 'xxx'
-  email_to: '[email protected]'
-  email_host: 'smtp.163.com'
-  email_port: 465
-  email_isSSL: true
+  email-from: '[email protected]'
+  email-nickname: 'test'
+  email-secret: 'xxx'
+  email-to: '[email protected]'
+  email-host: 'smtp.163.com'
+  email-port: 465
+  email-isSSL: true

+ 14 - 14
server/config/config.go

@@ -79,8 +79,8 @@ type Redis struct {
 }
 
 type LocalUpload struct {
-	Local      bool   `mapstructure:"local" json:"local" yaml:"local"`
-	FilePath   string `mapstructure:"file-path" json:"filePath" yaml:"file-path"`
+	Local    bool   `mapstructure:"local" json:"local" yaml:"local"`
+	FilePath string `mapstructure:"file-path" json:"filePath" yaml:"file-path"`
 }
 
 type Qiniu struct {
@@ -101,19 +101,19 @@ type Zap struct {
 	Format        string `mapstructure:"format" json:"format" yaml:"format"`
 	Prefix        string `mapstructure:"prefix" json:"prefix" yaml:"prefix"`
 	Director      string `mapstructure:"director" json:"director"  yaml:"director"`
-	LinkName      string `mapstructure:"link_name" json:"linkName" yaml:"link_name"`
-	ShowLine      bool   `mapstructure:"show_line" json:"showLine" yaml:"showLine"`
-	EncodeLevel   string `mapstructure:"encode_level" json:"encodeLevel" yaml:"encode_level"`
-	StacktraceKey string `mapstructure:"stacktrace_key" json:"stacktraceKey" yaml:"stacktrace_key"`
-	LogInConsole  bool   `mapstructure:"log_in_console" json:"logInConsole" yaml:"log_in_console"`
+	LinkName      string `mapstructure:"link-name" json:"linkName" yaml:"link-name"`
+	ShowLine      bool   `mapstructure:"show-line" json:"showLine" yaml:"showLine"`
+	EncodeLevel   string `mapstructure:"encode-level" json:"encodeLevel" yaml:"encode-level"`
+	StacktraceKey string `mapstructure:"stacktrace-key" json:"stacktraceKey" yaml:"stacktrace-key"`
+	LogInConsole  bool   `mapstructure:"log-in-console" json:"logInConsole" yaml:"log-in-console"`
 }
 
 type Email struct {
-	EmailFrom         string `mapstructure:"email_from" json:"emailFrom" yaml:"email_from"`
-	EmailNickName         string `mapstructure:"email_nick_name" json:"emailNickName" yaml:"email_nick_name"`
-	EmailSecret         string `mapstructure:"email_secret" json:"emailSecret" yaml:"email_secret"`
-	EmailTo         string `mapstructure:"email_to" json:"emailTo" yaml:"email_to"`
-	EmailHost         string `mapstructure:"email_host" json:"emailHost" yaml:"email_host"`
-	EmailPort         int `mapstructure:"email_port" json:"emailPort" yaml:"email_port"`
-	EmailIsSSL         bool `mapstructure:"email_isSSL" json:"emailIsSSL" yaml:"email_isSSL"`
+	EmailFrom     string `mapstructure:"email-from" json:"emailFrom" yaml:"email-from"`
+	EmailNickname string `mapstructure:"email-nickname" json:"emailNickname" yaml:"email-nickname"`
+	EmailSecret   string `mapstructure:"email-secret" json:"emailSecret" yaml:"email-secret"`
+	EmailTo       string `mapstructure:"email-to" json:"emailTo" yaml:"email-to"`
+	EmailHost     string `mapstructure:"email-host" json:"emailHost" yaml:"email-host"`
+	EmailPort     int    `mapstructure:"email-port" json:"emailPort" yaml:"email-port"`
+	EmailIsSSL    bool   `mapstructure:"email-is-ssl" json:"emailIsSSL" yaml:"email-is-ssl"`
 }

+ 3 - 3
server/utils/email.go

@@ -23,7 +23,7 @@ func EmailTest(subject string, body string) error {
 
 func send(to []string, subject string, body string) error {
 	from := global.GVA_CONFIG.Email.EmailFrom
-	nickName := global.GVA_CONFIG.Email.EmailNickName
+	nickname := global.GVA_CONFIG.Email.EmailNickname
 	secret := global.GVA_CONFIG.Email.EmailSecret
 	host := global.GVA_CONFIG.Email.EmailHost
 	port := global.GVA_CONFIG.Email.EmailPort
@@ -31,8 +31,8 @@ func send(to []string, subject string, body string) error {
 
 	auth := smtp.PlainAuth("", from, secret, host)
 	e := email.NewEmail()
-	if nickName != "" {
-		e.From = fmt.Sprintf("%s <%s>", nickName, from)
+	if nickname != "" {
+		e.From = fmt.Sprintf("%s <%s>", nickname, from)
 	} else {
 		e.From = from
 	}