logger refactor

This commit is contained in:
Wenkai Yin 2016-03-29 13:33:49 +08:00
parent f10769d5ba
commit 0812d2870c
3 changed files with 6 additions and 6 deletions

View File

@ -16,9 +16,10 @@
package dao package dao
import ( import (
"log"
"net" "net"
"github.com/vmware/harbor/utils/log"
"os" "os"
"strings" "strings"
"time" "time"
@ -88,7 +89,7 @@ func InitDB() {
c.Close() c.Close()
ch <- 1 ch <- 1
} else { } else {
log.Printf("failed to connect to db, retry after 2 seconds...") log.Info("failed to connect to db, retry after 2 seconds...")
time.Sleep(2 * time.Second) time.Sleep(2 * time.Second)
} }
} }

View File

@ -16,7 +16,6 @@
package dao package dao
import ( import (
"fmt"
"os" "os"
"testing" "testing"
"time" "time"
@ -127,7 +126,7 @@ func TestMain(m *testing.M) {
} }
dbPassword := os.Getenv("DB_PWD") dbPassword := os.Getenv("DB_PWD")
fmt.Printf("DB_HOST: %s, DB_USR: %s, DB_PORT: %s, DB_PWD: %s\n", dbHost, dbUser, dbPort, dbPassword) log.Infof("DB_HOST: %s, DB_USR: %s, DB_PORT: %s, DB_PWD: %s\n", dbHost, dbUser, dbPort, dbPassword)
os.Setenv("MYSQL_PORT_3306_TCP_ADDR", dbHost) os.Setenv("MYSQL_PORT_3306_TCP_ADDR", dbHost)
os.Setenv("MYSQL_PORT_3306_TCP_PORT", dbPort) os.Setenv("MYSQL_PORT_3306_TCP_PORT", dbPort)

View File

@ -22,8 +22,8 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm" "github.com/astaxie/beego/orm"
"github.com/vmware/harbor/utils/log"
) )
//TODO:transaction, return err //TODO:transaction, return err
@ -70,7 +70,7 @@ func AddProject(project models.Project) error {
func IsProjectPublic(projectName string) bool { func IsProjectPublic(projectName string) bool {
project, err := GetProjectByName(projectName) project, err := GetProjectByName(projectName)
if err != nil { if err != nil {
beego.Error("Error occurred in GetProjectByName:", err) log.Errorf("Error occurred in GetProjectByName: %v", err)
return false return false
} }
if project == nil { if project == nil {