Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exportable custom plain logger #1171

Merged
merged 3 commits into from
Jan 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Change the log directory to current directory
  • Loading branch information
chenyarong committed Dec 28, 2023
commit 622a45474d193b72d1dae9191061c774a8794543
18 changes: 6 additions & 12 deletions pkg/logger/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,15 @@ import (
)

func TestMustPlainLogger(t *testing.T) {
opt := &option.Options{
AbsLogDir: "/tmp",
}
opt := &option.Options{AbsLogDir: "."}
defer func() {
if rv := recover(); rv != nil {
t.Errorf("mustPlainLogger() panic: %v", rv)
}
}()

MustNewPlainLogger(opt, "test.log", 1)
_, err := os.Stat("/tmp/test.log")
_, err := os.Stat("test.log")
if err == nil {
return
}
Expand All @@ -46,17 +44,15 @@ func TestMustPlainLogger(t *testing.T) {
}

func TestMustPlainLoggerPanic(t *testing.T) {
opt := &option.Options{
AbsLogDir: "/",
}
opt := &option.Options{AbsLogDir: "."}
defer func() {
if rv := recover(); rv != nil {
t.Logf("mustPlainLogger() panic: %v", rv)
}
}()

MustNewPlainLogger(opt, "test.log", 1)
_, err := os.Stat("/test.log")
MustNewPlainLogger(opt, "test.log", 0)
_, err := os.Stat("test.log")
if err == nil {
return
}
Expand All @@ -67,9 +63,7 @@ func TestMustPlainLoggerPanic(t *testing.T) {
}

func TestMustPlainLoggerWrite(t *testing.T) {
opt := &option.Options{
AbsLogDir: "/tmp/",
}
opt := &option.Options{AbsLogDir: "."}
defer func() {
if rv := recover(); rv != nil {
t.Errorf("mustPlainLogger() panic: %v", rv)
Expand Down
Loading