Continue to standardize on logging
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/websocket"
|
"golang.org/x/net/websocket"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,11 +25,11 @@ type Client struct {
|
|||||||
func NewClient(ws *websocket.Conn, server *Server) *Client {
|
func NewClient(ws *websocket.Conn, server *Server) *Client {
|
||||||
|
|
||||||
if ws == nil {
|
if ws == nil {
|
||||||
panic("ws cannot be nil")
|
log.Panicln("ws cannot be nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
if server == nil {
|
if server == nil {
|
||||||
panic("server cannot be nil")
|
log.Panicln("server cannot be nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
ch := make(chan *ChatMessage, channelBufSize)
|
ch := make(chan *ChatMessage, channelBufSize)
|
||||||
|
|||||||
29
config.go
29
config.go
@@ -3,9 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
|
||||||
"path"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
@@ -69,7 +66,7 @@ func getConfig() Config {
|
|||||||
var config Config
|
var config Config
|
||||||
err = yaml.Unmarshal(yamlFile, &config)
|
err = yaml.Unmarshal(yamlFile, &config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
log.Panicln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fmt.Printf("%+v\n", config)
|
// fmt.Printf("%+v\n", config)
|
||||||
@@ -79,37 +76,37 @@ func getConfig() Config {
|
|||||||
|
|
||||||
func checkConfig(config Config) {
|
func checkConfig(config Config) {
|
||||||
if config.S3.Enabled && config.IPFS.Enabled {
|
if config.S3.Enabled && config.IPFS.Enabled {
|
||||||
panic("S3 and IPFS support cannot be enabled at the same time. Choose one.")
|
log.Panicln("S3 and IPFS support cannot be enabled at the same time. Choose one.")
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.S3.Enabled {
|
if config.S3.Enabled {
|
||||||
if config.S3.AccessKey == "" || config.S3.Secret == "" {
|
if config.S3.AccessKey == "" || config.S3.Secret == "" {
|
||||||
panic("S3 support requires an access key and secret.")
|
log.Panicln("S3 support requires an access key and secret.")
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.S3.Region == "" || config.S3.Endpoint == "" {
|
if config.S3.Region == "" || config.S3.Endpoint == "" {
|
||||||
panic("S3 support requires a region and endpoint.")
|
log.Panicln("S3 support requires a region and endpoint.")
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.S3.Bucket == "" {
|
if config.S3.Bucket == "" {
|
||||||
panic("S3 support requires a bucket created for storing public video segments.")
|
log.Panicln("S3 support requires a bucket created for storing public video segments.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !fileExists(config.PrivateHLSPath) {
|
// if !fileExists(config.PrivateHLSPath) {
|
||||||
os.MkdirAll(path.Join(config.PrivateHLSPath, strconv.Itoa(0)), 0777)
|
// os.MkdirAll(path.Join(config.PrivateHLSPath, strconv.Itoa(0)), 0777)
|
||||||
}
|
// }
|
||||||
|
|
||||||
if !fileExists(config.PublicHLSPath) {
|
// if !fileExists(config.PublicHLSPath) {
|
||||||
os.MkdirAll(path.Join(config.PublicHLSPath, strconv.Itoa(0)), 0777)
|
// os.MkdirAll(path.Join(config.PublicHLSPath, strconv.Itoa(0)), 0777)
|
||||||
}
|
// }
|
||||||
|
|
||||||
if !fileExists(config.FFMpegPath) {
|
if !fileExists(config.FFMpegPath) {
|
||||||
panic(fmt.Sprintf("ffmpeg does not exist at %s.", config.FFMpegPath))
|
log.Panicln(fmt.Sprintf("ffmpeg does not exist at %s.", config.FFMpegPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.VideoSettings.EncoderPreset == "" {
|
if config.VideoSettings.EncoderPreset == "" {
|
||||||
panic("A video encoder preset is required to be set in the config file.")
|
log.Panicln("A video encoder preset is required to be set in the config file.")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ func (s *IPFSStorage) Save(filePath string, retryCount int) string {
|
|||||||
defer someFile.Close()
|
defer someFile.Close()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("Could not get File: %s", err))
|
log.Panicln(fmt.Errorf("Could not get File: %s", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
opts := []options.UnixfsAddOption{
|
opts := []options.UnixfsAddOption{
|
||||||
@@ -70,7 +70,7 @@ func (s *IPFSStorage) Save(filePath string, retryCount int) string {
|
|||||||
cidFile, err := (*s.ipfs).Unixfs().Add(s.ctx, someFile, opts...)
|
cidFile, err := (*s.ipfs).Unixfs().Add(s.ctx, someFile, opts...)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("Could not add File: %s", err))
|
log.Panicln(fmt.Errorf("Could not add File: %s", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
// fmt.Printf("Added file to IPFS with CID %s\n", cidFile.String())
|
// fmt.Printf("Added file to IPFS with CID %s\n", cidFile.String())
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ func (s S3Storage) connectAWS() *session.Session {
|
|||||||
creds := credentials.NewStaticCredentials(s.s3AccessKey, s.s3Secret, "")
|
creds := credentials.NewStaticCredentials(s.s3AccessKey, s.s3Secret, "")
|
||||||
_, err := creds.Get()
|
_, err := creds.Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
log.Panicln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sess, err := session.NewSession(
|
sess, err := session.NewSession(
|
||||||
@@ -105,7 +105,7 @@ func (s S3Storage) connectAWS() *session.Session {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
log.Panicln(err)
|
||||||
}
|
}
|
||||||
return sess
|
return sess
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user