@@ -2,6 +2,7 @@ package streamer
2
2
3
3
import (
4
4
"fmt"
5
+ "log/slog"
5
6
"os"
6
7
"os/exec"
7
8
"path/filepath"
@@ -11,7 +12,6 @@ import (
11
12
12
13
"github.com/google/uuid"
13
14
"github.com/natefinch/lumberjack"
14
- "github.com/sirupsen/logrus"
15
15
16
16
"github.com/Roverr/hotstreak"
17
17
)
@@ -56,7 +56,7 @@ func NewStream(
56
56
path := fmt .Sprintf ("%s/%s" , storingDirectory , id )
57
57
err := os .MkdirAll (path , os .ModePerm )
58
58
if err != nil {
59
- logrus .Error (err )
59
+ slog .Error ("error creating directory" , "error" , err )
60
60
return nil , ""
61
61
}
62
62
process := NewProcess (keepFiles , audio )
@@ -95,7 +95,7 @@ func NewStream(
95
95
Running : false ,
96
96
WaitTimeOut : waitTimeOut ,
97
97
}
98
- logrus . Debugf ( "%s store path created | Stream " , stream .StorePath )
98
+ slog . Debug ( "stream store path created" , "path " , stream .StorePath )
99
99
return & stream , id
100
100
}
101
101
@@ -111,13 +111,10 @@ func (strm *Stream) Start() *sync.WaitGroup {
111
111
indexPath := fmt .Sprintf ("%s/index.m3u8" , strm .StorePath )
112
112
// Run the transcoding, resolve stream if it errors out
113
113
go func () {
114
- logrus . Debugf ( "%s is starting FFMPEG process | Stream " , strm .ID )
114
+ slog . Debug ( " starting FFMPEG process" , "id " , strm .ID )
115
115
if err := strm .CMD .Run (); err != nil {
116
116
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 )
121
118
strm .Running = false
122
119
strm .Mux .Unlock ()
123
120
wg .Done ()
@@ -133,10 +130,7 @@ func (strm *Stream) Start() *sync.WaitGroup {
133
130
continue
134
131
}
135
132
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 )
140
134
strm .Running = true
141
135
strm .Mux .Unlock ()
142
136
wg .Done ()
@@ -148,10 +142,7 @@ func (strm *Stream) Start() *sync.WaitGroup {
148
142
go func () {
149
143
<- time .After (strm .WaitTimeOut )
150
144
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 )
155
146
strm .Running = false
156
147
strm .Mux .Unlock ()
157
148
wg .Done ()
@@ -188,9 +179,9 @@ func (strm *Stream) Stop() error {
188
179
strm .Running = false
189
180
if ! strm .KeepFiles {
190
181
defer func () {
191
- logrus . Debugf ( "%s directory is being removed | Stream " , strm .StorePath )
182
+ slog . Debug ( " directory is being removed" , "path " , strm .StorePath )
192
183
if err := os .RemoveAll (strm .StorePath ); err != nil {
193
- logrus .Error (err )
184
+ slog .Error ("error removing directory" , "error" , err )
194
185
}
195
186
}()
196
187
}
0 commit comments