3 Star 2 Fork 1

Gitee 极速下载/Go-Logger

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/phachon/go-logger
克隆/下载
console_test.go 1.97 KB
一键复制 编辑 原始数据 按行查看 历史
phachon 提交于 2019-12-15 11:20 . update go mod
package go_logger
import (
"testing"
"time"
)
func TestNewAdapterConsole(t *testing.T) {
NewAdapterConsole()
}
func TestAdapterConsole_Init(t *testing.T) {
consoleAdapter := NewAdapterConsole()
consoleConfig := &ConsoleConfig{}
consoleAdapter.Init(consoleConfig)
}
func TestAdapterConsole_Name(t *testing.T) {
consoleAdapter := NewAdapterConsole()
if consoleAdapter.Name() != CONSOLE_ADAPTER_NAME {
t.Error("consoleAdapter name error")
}
}
func TestAdapterConsole_WriteColor(t *testing.T) {
consoleAdapter := NewAdapterConsole()
consoleConfig := &ConsoleConfig{
Color: true,
}
consoleAdapter.Init(consoleConfig)
loggerMsg := &loggerMessage{
Timestamp: time.Now().Unix(),
TimestampFormat: time.Now().Format("2006-01-02 15:04:05"),
Millisecond: time.Now().UnixNano() / 1e6,
MillisecondFormat: time.Now().Format("2006-01-02 15:04:05.999"),
Level: LOGGER_LEVEL_DEBUG,
LevelString: "debug",
Body: "logger console adapter test color",
File: "console_test.go",
Line: 50,
Function: "TestAdapterConsole_WriteIsColor",
}
err := consoleAdapter.Write(loggerMsg)
if err != nil {
t.Error(err.Error())
}
}
func TestAdapterConsole_WriteJsonFormat(t *testing.T) {
consoleAdapter := NewAdapterConsole()
consoleConfig := &ConsoleConfig{
JsonFormat: true,
}
consoleAdapter.Init(consoleConfig)
loggerMsg := &loggerMessage{
Timestamp: time.Now().Unix(),
TimestampFormat: time.Now().Format("2006-01-02 15:04:05"),
Millisecond: time.Now().UnixNano() / 1e6,
MillisecondFormat: time.Now().Format("2006-01-02 15:04:05.999"),
Level: LOGGER_LEVEL_DEBUG,
LevelString: "debug",
Body: "logger console adapter test jsonFormat",
File: "console_test.go",
Line: 77,
Function: "TestAdapterConsole_WriteJsonFormat",
}
err := consoleAdapter.Write(loggerMsg)
if err != nil {
t.Error(err.Error())
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors/Go-Logger.git
git@gitee.com:mirrors/Go-Logger.git
mirrors
Go-Logger
Go-Logger
master

搜索帮助