Skip to content

Commit

Permalink
chore: rename fields to utils for server utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
PThorpe92 committed Feb 3, 2025
1 parent 87ca2b4 commit 94c3eff
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
20 changes: 10 additions & 10 deletions backend/src/handlers/fields.go → backend/src/handlers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,42 @@ import (
"strconv"
"strings"

log "github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
)

// sLog is a wrapper around the log.Fields map and is implemented by the handleError method, this struct is not intended to be accessed directly and was created to make adding key/values and logging more efficient.
type sLog struct{ f log.Fields }
type sLog struct{ f logrus.Fields }

func (slog sLog) info(args ...interface{}) {
log.WithFields(slog.f).Info(args...)
logrus.WithFields(slog.f).Info(args...)
}

func (slog sLog) infof(format string, args ...interface{}) {
log.WithFields(slog.f).Infof(format, args...)
logrus.WithFields(slog.f).Infof(format, args...)
}

func (slog sLog) debug(args ...interface{}) {
log.WithFields(slog.f).Debug(args...)
logrus.WithFields(slog.f).Debug(args...)
}

func (slog sLog) debugf(format string, args ...interface{}) {
log.WithFields(slog.f).Debugf(format, args...)
logrus.WithFields(slog.f).Debugf(format, args...)
}

func (slog sLog) warn(args ...interface{}) {
log.WithFields(slog.f).Warn(args...)
logrus.WithFields(slog.f).Warn(args...)
}

func (slog sLog) warnf(format string, args ...interface{}) {
log.WithFields(slog.f).Warnf(format, args...)
logrus.WithFields(slog.f).Warnf(format, args...)
}

func (slog sLog) error(args ...interface{}) {
log.WithFields(slog.f).Error(args...)
logrus.WithFields(slog.f).Error(args...)
}

func (slog sLog) errorf(format string, args ...interface{}) {
log.WithFields(slog.f).Errorf(format, args...)
logrus.WithFields(slog.f).Errorf(format, args...)
}

func (slog *sLog) add(key string, value interface{}) {
Expand Down
5 changes: 4 additions & 1 deletion backend/tasks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func main() {
if err != nil {
log.Error("error loading .env file, using default env variables")
}
dev := os.Getenv("APP_ENV") == "dev"
initLogging()
runner := newJobRunner()
scheduler, err := gocron.NewScheduler()
Expand Down Expand Up @@ -45,7 +46,9 @@ func main() {
hour = 1
}
}
runner.execute()
if !dev {
runner.execute()
}
scheduler.Start()
shutdown := make(chan os.Signal, 1)
signal.Notify(shutdown, syscall.SIGINT, syscall.SIGTERM)
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ services:
context: .
dockerfile: ./backend/tasks/dev.Dockerfile
environment:
- APP_ENV=dev
- LOG_LEVEL=debug
- NATS_URL=nats:4222
- NATS_USER=unlocked
Expand Down

0 comments on commit 94c3eff

Please sign in to comment.