Skip to content

Commit

Permalink
refactor: to latest logus
Browse files Browse the repository at this point in the history
  • Loading branch information
dd84ai committed Jan 27, 2024
1 parent 7b61ebb commit fdf55e9
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/darklab8/darklab_goutils
go 1.21.1

require (
github.com/darklab8/logusgo v0.1.1
github.com/darklab8/logusgo v0.2.0
github.com/stretchr/testify v1.8.4
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ github.com/darklab8/logusgo v0.1.0 h1:765nud9EQA07/jSfAeJwaV+LFL3F1lHbXB+KutchvQ
github.com/darklab8/logusgo v0.1.0/go.mod h1:ZUSny1j/Y9T6JclwS83sugazFyQqNNe6jbWQ361MpyM=
github.com/darklab8/logusgo v0.1.1 h1:GZdmrAM4PwuHHhopXLKeqJYUDCeRPOABZEx3T+yPBqs=
github.com/darklab8/logusgo v0.1.1/go.mod h1:ZUSny1j/Y9T6JclwS83sugazFyQqNNe6jbWQ361MpyM=
github.com/darklab8/logusgo v0.2.0 h1:LHjm5pBWAhPwRTPxcznNYIETM0FML6IfG7dWn1Hx+l8=
github.com/darklab8/logusgo v0.2.0/go.mod h1:ZUSny1j/Y9T6JclwS83sugazFyQqNNe6jbWQ361MpyM=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
5 changes: 3 additions & 2 deletions goutils/utils/utils_logus/logus.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package utils_logus

import (
"fmt"
"log/slog"

"github.com/darklab8/darklab_goutils/goutils/utils/utils_types"
"github.com/darklab8/logusgo/logcore"
Expand All @@ -11,13 +12,13 @@ var Log *logcore.Logger = logcore.NewLogger("goutils")

func Regex(value utils_types.RegExp) logcore.SlogParam {
return func(c *logcore.SlogGroup) {
c.Params["regexp"] = fmt.Sprintf("%v", value)
c.Append(slog.String("regexp", fmt.Sprintf("%v", value)))
}
}

func FilePath(value utils_types.FilePath) logcore.SlogParam {
return func(c *logcore.SlogGroup) {
c.Params["filepath"] = fmt.Sprintf("%v", value)
c.Append(slog.String("filepath", fmt.Sprintf("%v", value)))
}
}

Expand Down
3 changes: 2 additions & 1 deletion goutils/worker/logus.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package worker

import (
"fmt"
"log/slog"
"strings"

"github.com/darklab8/darklab_goutils/goutils/utils"
Expand All @@ -11,6 +12,6 @@ import (
func LogusStatusCodes(tasks []ITask) logcore.SlogParam {
str_status_codes := utils.CompL(tasks, func(x ITask) string { return fmt.Sprintf("%d", x.GetStatusCode()) })
return func(c *logcore.SlogGroup) {
c.Params["status_codes"] = strings.Join(str_status_codes, ",")
c.Append(slog.String("status_codes", strings.Join(str_status_codes, ",")))
}
}
8 changes: 4 additions & 4 deletions goutils/worker/worker_logus/logus.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package worker_logus

import (
"strconv"
"log/slog"

"github.com/darklab8/darklab_goutils/goutils/worker/worker_types"
"github.com/darklab8/logusgo/logcore"
Expand All @@ -11,18 +11,18 @@ var Log *logcore.Logger = logcore.NewLogger("worker")

func WorkerID(value worker_types.WorkerID) logcore.SlogParam {
return func(c *logcore.SlogGroup) {
c.Params["worker_id"] = strconv.Itoa(int(value))
c.Append(slog.Int("worker_id", int(value)))
}
}

func TaskID(value worker_types.TaskID) logcore.SlogParam {
return func(c *logcore.SlogGroup) {
c.Params["task_id"] = strconv.Itoa(int(value))
c.Append(slog.Int("task_id", int(value)))
}
}

func StatusCode(value worker_types.TaskStatusCode) logcore.SlogParam {
return func(c *logcore.SlogGroup) {
c.Params["status_code"] = strconv.Itoa(int(value))
c.Append(slog.Int("status_code", int(value)))
}
}
4 changes: 2 additions & 2 deletions goutils/worker/worker_tests/worker_temp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package worker_tests

import (
"fmt"
"strconv"
"log/slog"
"testing"
"time"

Expand Down Expand Up @@ -38,7 +38,7 @@ func (data *TaskTest) RunTask(worker_id worker_types.WorkerID) error {

func TaskResult(value worker_types.TaskID) logcore.SlogParam {
return func(c *logcore.SlogGroup) {
c.Params["task_result"] = strconv.Itoa(int(value))
c.Append(slog.Int("task_result", int(value)))
}
}

Expand Down

0 comments on commit fdf55e9

Please sign in to comment.