diff --git a/lib/redis.go b/lib/redispubsub.go similarity index 82% rename from lib/redis.go rename to lib/redispubsub.go index 71a6e84..a574975 100644 --- a/lib/redis.go +++ b/lib/redispubsub.go @@ -2,9 +2,9 @@ package lib import ( "context" - "log" "os" + "github.com/fatih/color" "github.com/joho/godotenv" "github.com/redis/go-redis/v9" "goth.stack/lib/pubsub" @@ -30,7 +30,7 @@ func NewRedisClient() *redis.Client { redis_host := os.Getenv("REDIS_HOST") redis_password := os.Getenv("REDIS_PASSWORD") - log.Printf("Connecting to Redis at %s", redis_host) + LogInfo.Printf("Connecting to Redis at %s", redis_host) RedisClient = redis.NewClient(&redis.Options{ Addr: redis_host, Password: redis_password, @@ -45,7 +45,7 @@ func (m *RedisPubSubMessage) ReceiveMessage(ctx context.Context) (*pubsub.Messag if err != nil { return nil, err } - + LogInfo.Printf("[PUBSUB/REDIS] Received message: %s", msg.Payload) return &pubsub.Message{Payload: msg.Payload}, nil } @@ -55,6 +55,7 @@ func (ps *RedisPubSub) SubscribeToChannel(channel string) (pubsub.PubSubMessage, if err != nil { return nil, err } + LogInfo.Printf("[PUBSUB/REDIS] Subscribed to channel %s", channel) return &RedisPubSubMessage{pubsub: pubsub}, nil } @@ -64,5 +65,6 @@ func (r *RedisPubSub) PublishToChannel(channel string, message string) error { if err != nil { return err } + color.Cyan("[PUBSUB/REDIS] Publishing message to channel %s: %s", channel, message) return nil }