Skip to content

Commit

Permalink
refactor: liking a bit more logus name as initialized logger
Browse files Browse the repository at this point in the history
  • Loading branch information
dd84ai committed Feb 11, 2024
1 parent ebac56b commit 6b068c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/logger/main.go → examples/logus/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package logger
package logus

import "github.com/darklab8/go-typelog/typelog"

Expand Down
14 changes: 7 additions & 7 deletions examples/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@ import (
"testing"
"time"

"github.com/darklab8/go-typelog/examples/logger"
"github.com/darklab8/go-typelog/examples/logus"
"github.com/darklab8/go-typelog/examples/typedlogs"
"github.com/darklab8/go-typelog/examples/types"
"github.com/darklab8/go-typelog/typelog"
)

func TestTypedLogs(t *testing.T) {
worker_id := types.WorkerID(5)
logger.Log.Info("Worker was started", typedlogs.WorkerID(worker_id))
logus.Log.Info("Worker was started", typedlogs.WorkerID(worker_id))

logger := logger.Log.WithFields(typedlogs.WorkerID(worker_id), typedlogs.TaskID("abc"))
logger := logus.Log.WithFields(typedlogs.WorkerID(worker_id), typedlogs.TaskID("abc"))
logger.Info("Worker started task")

logger.Info("Worker finished task")
}

func TestUsingInitialized(t *testing.T) {

logger.Log.Debug("123")
logus.Log.Debug("123")

logger.Log.Debug("123", typelog.TestParam(456))
logus.Log.Debug("123", typelog.TestParam(456))

logger1 := logger.Log.WithFields(typelog.Int("worker_id", 10))
logger1 := logus.Log.WithFields(typelog.Int("worker_id", 10))

logger1.Info("Worker made action1")
logger1.Info("Worker made action2")

logger2 := logger.Log.WithFields(typelog.Float64("smth", 13.54))
logger2 := logus.Log.WithFields(typelog.Float64("smth", 13.54))
logger2.Debug("try now")
logger1.Info("Worker made action1", typelog.Bool("is_check", false))
}
Expand Down

0 comments on commit 6b068c9

Please sign in to comment.