Use logrus.

This commit is contained in:
Naoki Kosaka
2021-09-14 21:22:38 +09:00
parent 56bf2f093e
commit 7c33331c40
13 changed files with 115 additions and 48 deletions

View File

@ -5,12 +5,12 @@ import (
"errors"
"fmt"
"net/url"
"os"
"strconv"
"github.com/RichardKnop/machinery/v1"
"github.com/RichardKnop/machinery/v1/config"
"github.com/go-redis/redis"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
)
@ -37,13 +37,13 @@ func NewRelayConfig() (*RelayConfig, error) {
iconURL, err := url.ParseRequestURI(viper.GetString("RELAY_ICON"))
if err != nil {
fmt.Fprintln(os.Stderr, "RELAY_ICON: INVALID OR EMPTY. THIS COLUMN IS DISABLED.")
logrus.Warn("RELAY_ICON: INVALID OR EMPTY. THIS COLUMN IS DISABLED.")
iconURL = nil
}
imageURL, err := url.ParseRequestURI(viper.GetString("RELAY_IMAGE"))
if err != nil {
fmt.Fprintln(os.Stderr, "RELAY_IMAGE: INVALID OR EMPTY. THIS COLUMN IS DISABLED.")
logrus.Warn("RELAY_IMAGE: INVALID OR EMPTY. THIS COLUMN IS DISABLED.")
imageURL = nil
}

View File

@ -1,10 +1,10 @@
package models
import (
"fmt"
"strings"
"github.com/go-redis/redis"
"github.com/sirupsen/logrus"
)
// Config : Enum for RelayConfig
@ -50,7 +50,7 @@ func (config *RelayState) ListenNotify(c chan<- bool) {
cNotify := c != nil
go func() {
for range ch {
fmt.Println("Config refreshed from state changed notify.")
logrus.Info("Config refreshed from state changed notify.")
config.Load()
if cNotify {
c <- true

View File

@ -5,11 +5,10 @@ import (
"crypto/x509"
"encoding/pem"
"errors"
"fmt"
"io/ioutil"
"os"
"github.com/go-redis/redis"
"github.com/sirupsen/logrus"
)
func ReadPublicKeyRSAFromString(pemString string) (*rsa.PublicKey, error) {
@ -20,7 +19,7 @@ func ReadPublicKeyRSAFromString(pemString string) (*rsa.PublicKey, error) {
}()
keyInterface, err := x509.ParsePKIXPublicKey(decoded.Bytes)
if err != nil {
fmt.Fprintln(os.Stderr, err)
logrus.Error(err)
return nil, err
}
pub := keyInterface.(*rsa.PublicKey)