Use logrus.
This commit is contained in:
@ -2,10 +2,10 @@ package control
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
@ -126,18 +126,18 @@ func exportConfig(cmd *cobra.Command, args []string) {
|
||||
func importConfig(cmd *cobra.Command, args []string) {
|
||||
file, err := os.Open(cmd.Flag("json").Value.String())
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
logrus.Error(err)
|
||||
return
|
||||
}
|
||||
jsonData, err := ioutil.ReadAll(file)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
logrus.Error(err)
|
||||
return
|
||||
}
|
||||
var data models.RelayState
|
||||
err = json.Unmarshal(jsonData, &data)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
logrus.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package control
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/RichardKnop/machinery/v1"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
@ -50,7 +50,7 @@ func initConfig(cmd *cobra.Command) error {
|
||||
viper.SetConfigType("yaml")
|
||||
viper.ReadConfig(file)
|
||||
} else {
|
||||
fmt.Fprintln(os.Stderr, "Config file not exist. Use environment variables.")
|
||||
logrus.Warn("Config file not exist. Use environment variables.")
|
||||
|
||||
viper.BindEnv("ACTOR_PEM")
|
||||
viper.BindEnv("REDIS_URL")
|
||||
@ -65,8 +65,7 @@ func initConfig(cmd *cobra.Command) error {
|
||||
|
||||
globalConfig, err = models.NewRelayConfig()
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
initialize(globalConfig)
|
||||
|
@ -3,11 +3,11 @@ package control
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/RichardKnop/machinery/v1/tasks"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
@ -83,7 +83,7 @@ func pushRegisterJob(inboxURL string, body []byte) {
|
||||
}
|
||||
_, err := machineryServer.SendTask(job)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
logrus.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user