Browse Source

Write logs to localhost folder if host not found

Vova Tkach 6 years ago
parent
commit
a18ab27e0b
1 changed files with 5 additions and 0 deletions
  1. 5 0
      logger/logger.go

+ 5 - 0
logger/logger.go

@@ -70,6 +70,11 @@ func (this *Logger) write(msg *logMsg) {
 	host, _ := utils.ExtractHostPort(msg.host, false)
 	host, _ := utils.ExtractHostPort(msg.host, false)
 	logs_dir := this.wwwDir + string(os.PathSeparator) + host + string(os.PathSeparator) + "logs"
 	logs_dir := this.wwwDir + string(os.PathSeparator) + host + string(os.PathSeparator) + "logs"
 
 
+	// Try use localhost folder for logs
+	if !utils.IsDirExists(logs_dir) {
+		logs_dir = this.wwwDir + string(os.PathSeparator) + "localhost" + string(os.PathSeparator) + "logs"
+	}
+
 	// Ignore file if logs dir is not exists
 	// Ignore file if logs dir is not exists
 	if !utils.IsDirExists(logs_dir) {
 	if !utils.IsDirExists(logs_dir) {
 		this.console(msg)
 		this.console(msg)