Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
Set logging preferences via command line flags. Closes #20
Gabe Kangasc36f995c6791
diff --git a/core/chat/server.go b/core/chat/server.goindex 366f4a1db4..110780bcb4 100644--- a/core/chat/server.go+++ b/core/chat/server.go@@ -95,7 +95,7 @@ func (s *server) onConnection(ws *websocket.Conn) {func (s *server) Listen() {http.Handle(s.pattern, websocket.Handler(s.onConnection))- log.Printf("Starting the websocket listener on: %s", s.pattern)+ log.Tracef("Starting the websocket listener on: %s", s.pattern)for {select {@@ -121,7 +121,7 @@ func (s *server) Listen() {fmt.Println("PING?", ping)case err := <-s.errCh:- log.Println("Error:", err.Error())+ log.Error("Error:", err.Error())case <-s.doneCh:returndiff --git a/core/core.go b/core/core.goindex 3fd4d6190f..3469f06271 100644--- a/core/core.go+++ b/core/core.go@@ -24,17 +24,17 @@ func Start() error {resetDirectories()if err := setupStats(); err != nil {- log.Println("failed to setup the stats")+ log.Error("failed to setup the stats")return err}if err := setupStorage(); err != nil {- log.Println("failed to setup the storage")+ log.Error("failed to setup the storage")return err}if err := createInitialOfflineState(); err != nil {- log.Println("failed to create the initial offline state")+ log.Error("failed to create the initial offline state")return err}@@ -57,7 +57,7 @@ func createInitialOfflineState() error {}func resetDirectories() {- log.Println("Resetting file directories to a clean slate.")+ log.Trace("Resetting file directories to a clean slate.")// Wipe the public, web-accessible hls data directoryos.RemoveAll(config.Config.PublicHLSPath)diff --git a/core/ffmpeg/thumbnailGenerator.go b/core/ffmpeg/thumbnailGenerator.goindex 5c7ec054c0..cd5ecde130 100644--- a/core/ffmpeg/thumbnailGenerator.go+++ b/core/ffmpeg/thumbnailGenerator.go@@ -29,7 +29,7 @@ func StartThumbnailGenerator(chunkPath string, variantIndex int) {}case <-quit://TODO: evaluate if this is ever stopped- log.Println("thumbnail generator has stopped")+ log.Debug("thumbnail generator has stopped")ticker.Stop()return}diff --git a/core/ffmpeg/transcoder.go b/core/ffmpeg/transcoder.goindex 9ab5c2a459..cae4bd5d3e 100644--- a/core/ffmpeg/transcoder.go+++ b/core/ffmpeg/transcoder.go@@ -65,7 +65,7 @@ func (v *VideoSize) getString() string {func (t *Transcoder) Start() {command := t.getString()- log.Printf("Video transcoder started with %d stream variants.", len(t.variants))+ log.Tracef("Video transcoder started with %d stream variants.", len(t.variants))_, err := exec.Command("sh", "-c", command).Output()if err != nil {diff --git a/core/playlist/monitor.go b/core/playlist/monitor.goindex de7869bc83..a010ba420e 100644--- a/core/playlist/monitor.go+++ b/core/playlist/monitor.go@@ -76,7 +76,7 @@ func StartVideoContentMonitor(storage models.ChunkStorageProvider) error {} else if filepath.Ext(event.Path) == ".ts" {segment, err := getSegmentFromPath(event.Path)if err != nil {- log.Println("failed to get the segment from path")+ log.Error("failed to get the segment from path")panic(err)}diff --git a/core/rtmp/handler.go b/core/rtmp/handler.goindex 450a701335..035ba44e01 100644--- a/core/rtmp/handler.go+++ b/core/rtmp/handler.go@@ -49,7 +49,7 @@ func (h *Handler) OnCreateStream(timestamp uint32, cmd *rtmpmsg.NetConnectionCre//OnPublish handles the "OnPublish" of the rtmp servicefunc (h *Handler) OnPublish(timestamp uint32, cmd *rtmpmsg.NetStreamPublish) error {// log.Printf("OnPublish: %#v", cmd)- log.Println("Incoming stream connected.")+ log.Trace("Incoming stream connected.")if cmd.PublishingName != config.Config.VideoSettings.StreamingKey {return errors.New("invalid streaming key; rejecting incoming stream")diff --git a/core/rtmp/rtmp.go b/core/rtmp/rtmp.goindex 31f3ea701c..f0a39ccb3e 100644--- a/core/rtmp/rtmp.go+++ b/core/rtmp/rtmp.go@@ -45,7 +45,7 @@ func Start() {},})- log.Printf("RTMP server is listening for incoming stream on port: %d", port)+ log.Infof("RTMP server is listening for incoming stream on port: %d", port)if err := srv.Serve(listener); err != nil {log.Panicf("Failed to serve the rtmp service: %+v", err)}diff --git a/core/stats.go b/core/stats.goindex fad5d1ccfb..f210461db6 100644--- a/core/stats.go+++ b/core/stats.go@@ -88,7 +88,7 @@ func SetClientActive(clientID string) {//RemoveClient removes a client from the active clients recordfunc RemoveClient(clientID string) {- log.Println("Removing the client:", clientID)+ log.Trace("Removing the client:", clientID)delete(_stats.Clients, clientID)}diff --git a/core/storageproviders/ipfsStorage.go b/core/storageproviders/ipfsStorage.goindex 5642628c20..320c8b7b91 100644--- a/core/storageproviders/ipfsStorage.go+++ b/core/storageproviders/ipfsStorage.go@@ -44,7 +44,7 @@ type IPFSStorage struct {//Setup sets up the ipfs storage for saving the video to ipfsfunc (s *IPFSStorage) Setup() error {- log.Println("Setting up IPFS for external storage of video. Please wait..")+ log.Trace("Setting up IPFS for external storage of video. Please wait..")s.gateway = ownconfig.Config.IPFS.Gateway@@ -267,9 +267,9 @@ func (s *IPFSStorage) createIPFSInstance() (*icore.CoreAPI, *core.IpfsNode, erro}func (s *IPFSStorage) startIPFSNode() { //} icore.CoreAPI {- defer log.Println("IPFS node exited")+ defer log.Debug("IPFS node exited")- log.Println("IPFS node is running")+ log.Trace("IPFS node is running")bootstrapNodes := []string{// IPFS Bootstrapper nodes.diff --git a/core/storageproviders/s3Storage.go b/core/storageproviders/s3Storage.goindex f29c79483f..499e7f04c7 100644--- a/core/storageproviders/s3Storage.go+++ b/core/storageproviders/s3Storage.go@@ -30,7 +30,7 @@ type S3Storage struct {//Setup sets up the s3 storage for saving the video to s3func (s *S3Storage) Setup() error {- log.Println("Setting up S3 for external storage of video...")+ log.Trace("Setting up S3 for external storage of video...")s.s3Endpoint = config.Config.S3.Endpoints.s3Region = config.Config.S3.Region@@ -62,9 +62,9 @@ func (s *S3Storage) Save(filePath string, retryCount int) (string, error) {})if err != nil {- log.Errorln("error uploading:", err.Error())+ log.Trace("error uploading:", err.Error())if retryCount < 4 {- log.Println("Retrying...")+ log.Trace("Retrying...")return s.Save(filePath, retryCount+1)}}diff --git a/main.go b/main.goindex 473625acbd..292a74e2bb 100644--- a/main.go+++ b/main.go@@ -23,10 +23,13 @@ var ()func main() {- log.Println(getVersion())+ configureLogging()++ log.Infoln(getVersion())configFile := flag.String("configFile", "config.yaml", "Config File full path. Defaults to current folder")enableDebugOptions := flag.Bool("enableDebugFeatures", false, "Enable additional debugging options.")+ enableVerboseLogging := flag.Bool("enableVerboseLogging", false, "Enable additional logging.")flag.Parse()@@ -34,23 +37,36 @@ func main() {logrus.SetReportCaller(true)}+ if *enableVerboseLogging {+ log.SetLevel(log.TraceLevel)+ } else {+ log.SetLevel(log.InfoLevel)+ }+if err := config.Load(*configFile, getVersion()); err != nil {panic(err)}// starts the coreif err := core.Start(); err != nil {- log.Println("failed to start the core package")+ log.Error("failed to start the core package")panic(err)}if err := router.Start(); err != nil {- log.Println("failed to start/run the router")+ log.Error("failed to start/run the router")panic(err)}+}//getVersion gets the version stringfunc getVersion() string {return fmt.Sprintf("Owncast v%s-%s (%s)", BuildVersion, BuildType, GitCommit)}++func configureLogging() {+ log.SetFormatter(&log.TextFormatter{+ FullTimestamp: true,+ })+}diff --git a/router/router.go b/router/router.goindex a7dd6ae89f..ac5821c2ec 100644--- a/router/router.go+++ b/router/router.go@@ -34,7 +34,7 @@ func Start() error {port := config.Config.WebServerPort- log.Printf("Starting public web server on port: %d", port)+ log.Infof("Web server running on port: %d", port)return http.ListenAndServe(fmt.Sprintf(":%d", port), nil)}