add LogErrorf/LogWarnf/LogInfof/LogDebugf for formatter logging
using fmt.Sprint instead of fmt.Sprintln for logging print
This commit is contained in:
parent
4a03e015f4
commit
925d4e8ca5
50
engine.go
50
engine.go
|
@ -185,28 +185,52 @@ func (engine *Engine) logSQL(sqlStr string, sqlArgs ...interface{}) {
|
||||||
// logging error
|
// logging error
|
||||||
func (engine *Engine) LogError(contents ...interface{}) {
|
func (engine *Engine) LogError(contents ...interface{}) {
|
||||||
if engine.ShowErr {
|
if engine.ShowErr {
|
||||||
engine.Logger.Err(fmt.Sprintln(contents...))
|
engine.Logger.Err(fmt.Sprint(contents...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// logging error
|
func (engine *Engine) LogErrorf(format string, contents ...interface{}) {
|
||||||
|
if engine.ShowErr {
|
||||||
|
engine.Logger.Err(fmt.Sprintf(format, contents...))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// logging info
|
||||||
func (engine *Engine) LogInfo(contents ...interface{}) {
|
func (engine *Engine) LogInfo(contents ...interface{}) {
|
||||||
if engine.ShowInfo {
|
if engine.ShowInfo {
|
||||||
engine.Logger.Info(fmt.Sprintln(contents...))
|
engine.Logger.Info(fmt.Sprint(contents...))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (engine *Engine) LogInfof(format string, contents ...interface{}) {
|
||||||
|
if engine.ShowErr {
|
||||||
|
engine.Logger.Info(fmt.Sprintf(format, contents...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// logging debug
|
// logging debug
|
||||||
func (engine *Engine) LogDebug(contents ...interface{}) {
|
func (engine *Engine) LogDebug(contents ...interface{}) {
|
||||||
if engine.ShowDebug {
|
if engine.ShowDebug {
|
||||||
engine.Logger.Debug(fmt.Sprintln(contents...))
|
engine.Logger.Debug(fmt.Sprint(contents...))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (engine *Engine) LogDebugf(format string, contents ...interface{}) {
|
||||||
|
if engine.ShowDebug {
|
||||||
|
engine.Logger.Debug(fmt.Sprintf(format, contents...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// logging warn
|
// logging warn
|
||||||
func (engine *Engine) LogWarn(contents ...interface{}) {
|
func (engine *Engine) LogWarn(contents ...interface{}) {
|
||||||
if engine.ShowWarn {
|
if engine.ShowWarn {
|
||||||
engine.Logger.Warning(fmt.Sprintln(contents...))
|
engine.Logger.Warning(fmt.Sprint(contents...))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (engine *Engine) LogWarnf(format string, contents ...interface{}) {
|
||||||
|
if engine.ShowWarn {
|
||||||
|
engine.Logger.Warning(fmt.Sprintf(format, contents...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1070,21 +1094,21 @@ func (engine *Engine) Sync2(beans ...interface{}) error {
|
||||||
if engine.dialect.DBType() == core.MYSQL {
|
if engine.dialect.DBType() == core.MYSQL {
|
||||||
_, err = engine.Exec(engine.dialect.ModifyColumnSql(table.Name, col))
|
_, err = engine.Exec(engine.dialect.ModifyColumnSql(table.Name, col))
|
||||||
} else {
|
} else {
|
||||||
engine.LogWarn(fmt.Sprintf("Table %s Column %s db type is %s, struct type is %s\n",
|
engine.LogWarnf("Table %s Column %s db type is %s, struct type is %s\n",
|
||||||
table.Name, col.Name, oriCol.SQLType.Name, col.SQLType.Name))
|
table.Name, col.Name, oriCol.SQLType.Name, col.SQLType.Name)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
engine.LogWarn(fmt.Sprintf("Table %s Column %s db type is %s, struct type is %s",
|
engine.LogWarnf("Table %s Column %s db type is %s, struct type is %s",
|
||||||
table.Name, col.Name, oriCol.SQLType.Name, col.SQLType.Name))
|
table.Name, col.Name, oriCol.SQLType.Name, col.SQLType.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if col.Default != oriCol.Default {
|
if col.Default != oriCol.Default {
|
||||||
engine.LogWarn(fmt.Sprintf("Table %s Column %s db default is %s, struct default is %s",
|
engine.LogWarn("Table %s Column %s db default is %s, struct default is %s",
|
||||||
table.Name, col.Name, oriCol.Default, col.Default))
|
table.Name, col.Name, oriCol.Default, col.Default)
|
||||||
}
|
}
|
||||||
if col.Nullable != oriCol.Nullable {
|
if col.Nullable != oriCol.Nullable {
|
||||||
engine.LogWarn(fmt.Sprintf("Table %s Column %s db nullable is %v, struct nullable is %v",
|
engine.LogWarn("Table %s Column %s db nullable is %v, struct nullable is %v",
|
||||||
table.Name, col.Name, oriCol.Nullable, col.Nullable))
|
table.Name, col.Name, oriCol.Nullable, col.Nullable)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
session := engine.NewSession()
|
session := engine.NewSession()
|
||||||
|
|
Loading…
Reference in New Issue