Skip to content

Commit

Permalink
Add logging tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Lekuruu committed Oct 11, 2024
1 parent 1fdeebe commit 4a1b1ae
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions common/logging_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package common

import (
"testing"
"time"
)

type TestStruct struct {
String string
Integer int
Time time.Time
List []string
}

func TestLogging(t *testing.T) {
t.Parallel()

logger := CreateLogger("test", QUIET)
logger.Debug("debug message")
logger.Info("info message")
logger.Warning("warn message")
logger.Error("error message")

logger.Debugf("debug message %s", "formatted")
logger.Infof("info message %s", "formatted")
logger.Warningf("warn message %s", "formatted")
logger.Errorf("error message %s", "formatted")

test := &TestStruct{
String: "test",
Integer: 1,
Time: time.Now(),
List: []string{"a", "b", "c"},
}

formatted := FormatStruct(test)
logger.Debug(formatted)

bytesData := []byte{0x01, 0x02, 0x03, 0x04}
formatted = FormatBytes(bytesData)
logger.Debug(formatted)
}

0 comments on commit 4a1b1ae

Please sign in to comment.