@@ -2,6 +2,7 @@ package streamer
22
33import (
44 "fmt"
5+ "log/slog"
56 "os"
67 "os/exec"
78 "path/filepath"
@@ -11,7 +12,6 @@ import (
1112
1213 "github.com/google/uuid"
1314 "github.com/natefinch/lumberjack"
14- "github.com/sirupsen/logrus"
1515
1616 "github.com/Roverr/hotstreak"
1717)
@@ -56,7 +56,7 @@ func NewStream(
5656 path := fmt .Sprintf ("%s/%s" , storingDirectory , id )
5757 err := os .MkdirAll (path , os .ModePerm )
5858 if err != nil {
59- logrus .Error (err )
59+ slog .Error ("error creating directory" , "error" , err )
6060 return nil , ""
6161 }
6262 process := NewProcess (keepFiles , audio )
@@ -95,7 +95,7 @@ func NewStream(
9595 Running : false ,
9696 WaitTimeOut : waitTimeOut ,
9797 }
98- logrus . Debugf ( "%s store path created | Stream " , stream .StorePath )
98+ slog . Debug ( "stream store path created" , "path " , stream .StorePath )
9999 return & stream , id
100100}
101101
@@ -111,13 +111,10 @@ func (strm *Stream) Start() *sync.WaitGroup {
111111 indexPath := fmt .Sprintf ("%s/index.m3u8" , strm .StorePath )
112112 // Run the transcoding, resolve stream if it errors out
113113 go func () {
114- logrus . Debugf ( "%s is starting FFMPEG process | Stream " , strm .ID )
114+ slog . Debug ( " starting FFMPEG process" , "id " , strm .ID )
115115 if err := strm .CMD .Run (); err != nil {
116116 once .Do (func () {
117- logrus .Errorf ("%s process could not start. | Stream\n Error: %s" ,
118- strm .ID ,
119- err ,
120- )
117+ slog .Error ("process could not start" , "id" , strm .ID , "error" , err )
121118 strm .Running = false
122119 strm .Mux .Unlock ()
123120 wg .Done ()
@@ -133,10 +130,7 @@ func (strm *Stream) Start() *sync.WaitGroup {
133130 continue
134131 }
135132 once .Do (func () {
136- logrus .Debugf ("%s - %s successfully started - index.m3u8 found | Stream" ,
137- strm .ID ,
138- strm .OriginalURI ,
139- )
133+ slog .Debug ("successfully started" , "id" , strm .ID , "uri" , strm .OriginalURI )
140134 strm .Running = true
141135 strm .Mux .Unlock ()
142136 wg .Done ()
@@ -148,10 +142,7 @@ func (strm *Stream) Start() *sync.WaitGroup {
148142 go func () {
149143 <- time .After (strm .WaitTimeOut )
150144 once .Do (func () {
151- logrus .Errorf (
152- "%s process starting timed out | Stream" ,
153- strm .ID ,
154- )
145+ slog .Error ("process starting timed out" , "id" , strm .ID )
155146 strm .Running = false
156147 strm .Mux .Unlock ()
157148 wg .Done ()
@@ -188,9 +179,9 @@ func (strm *Stream) Stop() error {
188179 strm .Running = false
189180 if ! strm .KeepFiles {
190181 defer func () {
191- logrus . Debugf ( "%s directory is being removed | Stream " , strm .StorePath )
182+ slog . Debug ( " directory is being removed" , "path " , strm .StorePath )
192183 if err := os .RemoveAll (strm .StorePath ); err != nil {
193- logrus .Error (err )
184+ slog .Error ("error removing directory" , "error" , err )
194185 }
195186 }()
196187 }
0 commit comments