add logx.Alert

This commit is contained in:
kevin
2020-10-17 19:11:01 +08:00
parent d2ed14002c
commit 695ea69bfc
4 changed files with 15 additions and 2 deletions

View File

@@ -43,6 +43,7 @@ const (
consoleMode = "console"
volumeMode = "volume"
levelAlert = "alert"
levelInfo = "info"
levelError = "error"
levelSevere = "severe"
@@ -121,6 +122,10 @@ func SetUp(c LogConf) error {
}
}
func Alert(v string) {
output(errorLog, levelAlert, v)
}
func Close() error {
if writeConsole {
return nil

View File

@@ -84,6 +84,14 @@ func TestFileLineConsoleMode(t *testing.T) {
assert.True(t, writer.Contains(fmt.Sprintf("%s:%d", file, line+1)))
}
func TestStructedLogAlert(t *testing.T) {
doTestStructedLog(t, levelAlert, func(writer io.WriteCloser) {
errorLog = writer
}, func(v ...interface{}) {
Alert(fmt.Sprint(v...))
})
}
func TestStructedLogInfo(t *testing.T) {
doTestStructedLog(t, levelInfo, func(writer io.WriteCloser) {
infoLog = writer