Merged in remove-logging-pkg-prefix (pull request #393)

revid: no longer prepending package name before log messagges

Approved-by: Trek Hopton <trek.hopton@gmail.com>
This commit is contained in:
Saxon Milton 2020-03-29 00:28:45 +00:00
commit f9dc1d0139
4 changed files with 76 additions and 80 deletions

View File

@ -47,7 +47,7 @@ func (r *Revid) setupAudio() error {
case codecutil.ADPCM:
mts.Meta.Add("codec", "adpcm")
default:
r.cfg.Logger.Log(logger.Fatal, pkg+"no audio codec set in config")
r.cfg.Logger.Log(logger.Fatal, "no audio codec set in config")
}
r.input = alsa.New(r.cfg.Logger)

View File

@ -34,8 +34,6 @@ import (
"bitbucket.org/ausocean/utils/logger"
)
const pkg = "config: "
type Logger interface {
SetLevel(int8)
Log(level int8, message string, params ...interface{})
@ -390,7 +388,7 @@ func (c *Config) Validate() error {
case OutputFile, OutputHTTP, OutputRTP:
case OutputRTMP:
if c.RTMPURL == "" {
c.Logger.Log(logger.Info, pkg+"no RTMP URL: falling back to HTTP")
c.Logger.Log(logger.Info, "no RTMP URL: falling back to HTTP")
c.Outputs[i] = OutputHTTP
}
default:
@ -469,7 +467,7 @@ func (c *Config) Validate() error {
}
func (c *Config) LogInvalidField(name string, def interface{}) {
c.Logger.Log(logger.Info, pkg+name+" bad or unset, defaulting", name, def)
c.Logger.Log(logger.Info, name+" bad or unset, defaulting", name, def)
}
// stringInSlice returns true if want is in slice.

View File

@ -64,8 +64,6 @@ const (
rtmpConnectionTimeout = 10
)
const pkg = "revid: "
type Logger interface {
SetLevel(int8)
Log(level int8, message string, params ...interface{})
@ -140,7 +138,7 @@ func (r *Revid) handleErrors() {
for {
err := <-r.err
if err != nil {
r.cfg.Logger.Log(logger.Error, pkg+"async error", "error", err.Error())
r.cfg.Logger.Log(logger.Error, "async error", "error", err.Error())
}
}
}
@ -277,7 +275,7 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.
r.cfg.Logger.Log(logger.Debug, "using RTP output")
w, err := newRtpSender(r.cfg.RTPAddress, r.cfg.Logger.Log, r.cfg.FrameRate, r.bitrate.Report)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"rtp connect error", "error", err.Error())
r.cfg.Logger.Log(logger.Warning, "rtp connect error", "error", err.Error())
}
mtsSenders = append(mtsSenders, w)
case config.OutputFile:
@ -302,7 +300,7 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.
r.bitrate.Report,
)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"rtmp connect error", "error", err.Error())
r.cfg.Logger.Log(logger.Warning, "rtmp connect error", "error", err.Error())
}
flvSenders = append(flvSenders, w)
}
@ -400,7 +398,7 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.
r.cfg.Logger.Log(logger.Debug, "configuring input device")
err := r.input.Set(r.cfg)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"errors from configuring input device", "errors", err)
r.cfg.Logger.Log(logger.Warning, "errors from configuring input device", "errors", err)
}
r.cfg.Logger.Log(logger.Info, "input device configured")
@ -440,14 +438,14 @@ func (r *Revid) setLexer(c uint8, isRTSP bool) {
// Start is safe for concurrent use.
func (r *Revid) Start() error {
if r.IsRunning() {
r.cfg.Logger.Log(logger.Warning, pkg+"start called, but revid already running")
r.cfg.Logger.Log(logger.Warning, "start called, but revid already running")
return nil
}
r.mu.Lock()
defer r.mu.Unlock()
r.cfg.Logger.Log(logger.Debug, pkg+"resetting revid")
r.cfg.Logger.Log(logger.Debug, "resetting revid")
err := r.reset(r.cfg)
if err != nil {
r.Stop()
@ -475,7 +473,7 @@ func (r *Revid) Start() error {
// Stop is safe for concurrent use.
func (r *Revid) Stop() {
if !r.IsRunning() {
r.cfg.Logger.Log(logger.Warning, pkg+"stop called but revid isn't running")
r.cfg.Logger.Log(logger.Warning, "stop called but revid isn't running")
return
}
@ -485,7 +483,7 @@ func (r *Revid) Stop() {
r.cfg.Logger.Log(logger.Debug, "stopping input")
err := r.input.Stop()
if err != nil {
r.cfg.Logger.Log(logger.Error, pkg+"could not stop input", "error", err.Error())
r.cfg.Logger.Log(logger.Error, "could not stop input", "error", err.Error())
} else {
r.cfg.Logger.Log(logger.Info, "input stopped")
}
@ -493,7 +491,7 @@ func (r *Revid) Stop() {
r.cfg.Logger.Log(logger.Debug, "closing pipeline")
err = r.encoders.Close()
if err != nil {
r.cfg.Logger.Log(logger.Error, pkg+"failed to close pipeline", "error", err.Error())
r.cfg.Logger.Log(logger.Error, "failed to close pipeline", "error", err.Error())
} else {
r.cfg.Logger.Log(logger.Info, "pipeline closed")
}
@ -501,7 +499,7 @@ func (r *Revid) Stop() {
for _, filter := range r.filters {
err = filter.Close()
if err != nil {
r.cfg.Logger.Log(logger.Error, pkg+"failed to close filters", "error", err.Error())
r.cfg.Logger.Log(logger.Error, "failed to close filters", "error", err.Error())
} else {
r.cfg.Logger.Log(logger.Info, "filters closed")
}
@ -559,21 +557,21 @@ func (r *Revid) Update(vars map[string]string) error {
case "Input":
v, ok := map[string]uint8{"raspivid": config.InputRaspivid, "rtsp": config.InputRTSP, "v4l": config.InputV4L, "file": config.InputFile}[strings.ToLower(value)]
if !ok {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid input var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid input var", "value", value)
break
}
r.cfg.Input = v
case "Saturation":
s, err := strconv.Atoi(value)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid saturation param", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid saturation param", "value", value)
break
}
r.cfg.Saturation = int(s)
case "Brightness":
b, err := strconv.Atoi(value)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid brightness param", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid brightness param", "value", value)
break
}
r.cfg.Brightness = uint(b)
@ -588,7 +586,7 @@ func (r *Revid) Update(vars map[string]string) error {
case "MJPEG":
r.cfg.InputCodec = codecutil.MJPEG
default:
r.cfg.Logger.Log(logger.Warning, pkg+"invalid InputCodec variable value", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid InputCodec variable value", "value", value)
}
case "Outputs":
outputs := strings.Split(value, ",")
@ -605,7 +603,7 @@ func (r *Revid) Update(vars map[string]string) error {
case "Rtp":
r.cfg.Outputs[i] = config.OutputRTP
default:
r.cfg.Logger.Log(logger.Warning, pkg+"invalid outputs param", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid outputs param", "value", value)
continue
}
}
@ -621,7 +619,7 @@ func (r *Revid) Update(vars map[string]string) error {
case "rtp":
r.cfg.Outputs[0] = config.OutputRTP
default:
r.cfg.Logger.Log(logger.Warning, pkg+"invalid output param", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid output param", "value", value)
continue
}
@ -632,7 +630,7 @@ func (r *Revid) Update(vars map[string]string) error {
case "Bitrate":
v, err := strconv.Atoi(value)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid framerate param", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid framerate param", "value", value)
break
}
r.cfg.Bitrate = uint(v)
@ -643,28 +641,28 @@ func (r *Revid) Update(vars map[string]string) error {
case "Height":
h, err := strconv.Atoi(value)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid height param", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid height param", "value", value)
break
}
r.cfg.Height = uint(h)
case "Width":
w, err := strconv.Atoi(value)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid width param", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid width param", "value", value)
break
}
r.cfg.Width = uint(w)
case "FrameRate":
v, err := strconv.Atoi(value)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid framerate param", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid framerate param", "value", value)
break
}
r.cfg.FrameRate = uint(v)
case "Rotation":
v, err := strconv.Atoi(value)
if err != nil || v > 359 {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid rotation param", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid rotation param", "value", value)
break
}
r.cfg.Rotation = uint(v)
@ -673,14 +671,14 @@ func (r *Revid) Update(vars map[string]string) error {
case "Quantization":
v, err := strconv.Atoi(value)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid quantization param", "value", v)
r.cfg.Logger.Log(logger.Warning, "invalid quantization param", "value", v)
break
}
r.cfg.Quantization = uint(v)
case "MinFrames":
v, err := strconv.Atoi(value)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid MinFrames param", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid MinFrames param", "value", value)
break
}
r.cfg.MinFrames = uint(v)
@ -688,7 +686,7 @@ func (r *Revid) Update(vars map[string]string) error {
case "ClipDuration":
v, err := strconv.Atoi(value)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid ClipDuration param", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid ClipDuration param", "value", value)
break
}
r.cfg.ClipDuration = time.Duration(v) * time.Second
@ -700,7 +698,7 @@ func (r *Revid) Update(vars map[string]string) error {
case "false":
r.cfg.HorizontalFlip = false
default:
r.cfg.Logger.Log(logger.Warning, pkg+"invalid HorizontalFlip param", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid HorizontalFlip param", "value", value)
}
case "VerticalFlip":
switch strings.ToLower(value) {
@ -709,7 +707,7 @@ func (r *Revid) Update(vars map[string]string) error {
case "false":
r.cfg.VerticalFlip = false
default:
r.cfg.Logger.Log(logger.Warning, pkg+"invalid VerticalFlip param", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid VerticalFlip param", "value", value)
}
case "Filters":
filters := strings.Split(value, ",")
@ -718,21 +716,21 @@ func (r *Revid) Update(vars map[string]string) error {
for i, filter := range filters {
v, ok := m[filter]
if !ok {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid Filters param", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid Filters param", "value", value)
}
r.cfg.Filters[i] = v
}
case "PSITime":
v, err := strconv.Atoi(value)
if err != nil || v < 0 {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid PSITime var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid PSITime var", "value", value)
break
}
r.cfg.PSITime = v
case "BurstPeriod":
v, err := strconv.Atoi(value)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid BurstPeriod param", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid BurstPeriod param", "value", value)
break
}
r.cfg.BurstPeriod = uint(v)
@ -749,54 +747,54 @@ func (r *Revid) Update(vars map[string]string) error {
case "Fatal":
r.cfg.LogLevel = logger.Fatal
default:
r.cfg.Logger.Log(logger.Warning, pkg+"invalid Logging param", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid Logging param", "value", value)
}
case "RTMPRBMaxElements":
v, err := strconv.Atoi(value)
if err != nil || v < 0 {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid RTMPRBMaxElements var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid RTMPRBMaxElements var", "value", value)
break
}
r.cfg.RBMaxElements = v
case "RTMPRBCapacity":
v, err := strconv.Atoi(value)
if err != nil || v < 0 {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid RTMPRBCapacity var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid RTMPRBCapacity var", "value", value)
break
}
r.cfg.RBCapacity = v
case "RTMPRBWriteTimeout":
v, err := strconv.Atoi(value)
if err != nil || v <= 0 {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid RTMPRBWriteTimeout var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid RTMPRBWriteTimeout var", "value", value)
break
}
r.cfg.RBWriteTimeout = v
case "MTSRBMaxElements":
v, err := strconv.Atoi(value)
if err != nil || v < 0 {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid MTSRBMaxElements var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid MTSRBMaxElements var", "value", value)
break
}
r.cfg.RBMaxElements = v
case "MTSRBCapacity":
v, err := strconv.Atoi(value)
if err != nil || v < 0 {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid MTSRBCapacity var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid MTSRBCapacity var", "value", value)
break
}
r.cfg.RBCapacity = v
case "MTSRBWriteTimeout":
v, err := strconv.Atoi(value)
if err != nil || v <= 0 {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid MTSRBWriteTimeout var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid MTSRBWriteTimeout var", "value", value)
break
}
r.cfg.RBWriteTimeout = v
case "CBR":
v, ok := map[string]bool{"true": true, "false": false}[strings.ToLower(value)]
if !ok {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid CBR var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid CBR var", "value", value)
break
}
r.cfg.CBR = v
@ -805,91 +803,91 @@ func (r *Revid) Update(vars map[string]string) error {
case "VBRQuality":
v, ok := map[string]config.Quality{"standard": config.QualityStandard, "fair": config.QualityFair, "good": config.QualityGood, "great": config.QualityGreat, "excellent": config.QualityExcellent}[strings.ToLower(value)]
if !ok {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid VBRQuality var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid VBRQuality var", "value", value)
break
}
r.cfg.VBRQuality = v
case "VBRBitrate":
v, err := strconv.Atoi(value)
if err != nil || v <= 0 {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid VBRBitrate var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid VBRBitrate var", "value", value)
break
}
r.cfg.VBRBitrate = v
case "CameraChan":
v, err := strconv.Atoi(value)
if err != nil || (v != 1 && v != 2) {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid CameraChan var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid CameraChan var", "value", value)
break
}
r.cfg.CameraChan = v
case "MinFPS":
v, err := strconv.ParseFloat(value, 64)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid MinFPS var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid MinFPS var", "value", value)
break
}
r.cfg.MinFPS = v
case "MotionMinArea":
v, err := strconv.ParseFloat(value, 64)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid MotionMinArea var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid MotionMinArea var", "value", value)
break
}
r.cfg.MotionMinArea = v
case "MotionThreshold":
v, err := strconv.ParseFloat(value, 64)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid MotionThreshold var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid MotionThreshold var", "value", value)
break
}
r.cfg.MotionThreshold = v
case "MotionKernel":
v, err := strconv.Atoi(value)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid MotionKernel var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid MotionKernel var", "value", value)
break
}
r.cfg.MotionKernel = uint(v)
case "MotionHistory":
v, err := strconv.Atoi(value)
if err != nil || v <= 0 {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid MotionHistory var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid MotionHistory var", "value", value)
break
}
r.cfg.MotionHistory = uint(v)
case "MotionPadding":
v, err := strconv.Atoi(value)
if err != nil || v <= 0 {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid MotionPadding var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid MotionPadding var", "value", value)
break
}
r.cfg.MotionPadding = uint(v)
case "MotionPixels":
v, err := strconv.Atoi(value)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid MotionPixels var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid MotionPixels var", "value", value)
break
}
r.cfg.MotionPixels = v
case "MotionDownscaling":
v, err := strconv.Atoi(value)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid MotionDownscaling var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid MotionDownscaling var", "value", value)
break
}
r.cfg.MotionDownscaling = v
case "MotionInterval":
v, err := strconv.Atoi(value)
if err != nil || v < 0 {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid MotionInterval var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid MotionInterval var", "value", value)
break
}
r.cfg.MotionInterval = v
case "FileFPS":
v, err := strconv.Atoi(value)
if err != nil {
r.cfg.Logger.Log(logger.Warning, pkg+"invalid FileFPS var", "value", value)
r.cfg.Logger.Log(logger.Warning, "invalid FileFPS var", "value", value)
break
}
r.cfg.FileFPS = v
@ -901,7 +899,7 @@ func (r *Revid) Update(vars map[string]string) error {
}
}
r.cfg.Logger.Log(logger.Info, "finished reconfig")
r.cfg.Logger.Log(logger.Debug, pkg+"config changed", "config", r.cfg)
r.cfg.Logger.Log(logger.Debug, "config changed", "config", r.cfg)
return nil
}
@ -920,13 +918,13 @@ func (r *Revid) processFrom(in device.AVDevice, delay time.Duration) {
// Lex data from input device, in, until finished or an error is encountered.
// For a continuous source e.g. a camera or microphone, we should remain
// in this call indefinitely unless in.Stop() is called and an io.EOF is forced.
r.cfg.Logger.Log(logger.Debug, pkg+"lexing")
r.cfg.Logger.Log(logger.Debug, "lexing")
err = r.lexTo(r.filters[0], in, delay)
switch err {
case nil, io.EOF:
r.cfg.Logger.Log(logger.Info, "end of file")
case io.ErrUnexpectedEOF:
r.cfg.Logger.Log(logger.Info, pkg+"unexpected EOF from input")
r.cfg.Logger.Log(logger.Info, "unexpected EOF from input")
default:
r.err <- err
}

View File

@ -127,18 +127,18 @@ func extractMeta(r string, log func(lvl int8, msg string, args ...interface{}))
// Extract time from reply
t, err := dec.Int("ts")
if err != nil {
log(logger.Warning, pkg+"No timestamp in reply")
log(logger.Warning, "No timestamp in reply")
} else {
log(logger.Debug, fmt.Sprintf("%v got timestamp: %v", pkg, t))
log(logger.Debug, fmt.Sprintf("got timestamp: %v", t))
mts.RealTime.Set(time.Unix(int64(t), 0))
}
// Extract location from reply
g, err := dec.String("ll")
if err != nil {
log(logger.Debug, pkg+"No location in reply")
log(logger.Debug, "No location in reply")
} else {
log(logger.Debug, fmt.Sprintf("%v got location: %v", pkg, g))
log(logger.Debug, fmt.Sprintf("got location: %v", g))
mts.Meta.Add("loc", g)
}
@ -206,7 +206,7 @@ func (s *mtsSender) output() {
for {
select {
case <-s.done:
s.log(logger.Info, pkg+"terminating sender output routine")
s.log(logger.Info, "terminating sender output routine")
defer s.wg.Done()
return
default:
@ -218,10 +218,10 @@ func (s *mtsSender) output() {
case nil, io.EOF:
continue
case vring.ErrNextTimeout:
s.log(logger.Debug, pkg+"ring buffer read timeout")
s.log(logger.Debug, "ring buffer read timeout")
continue
default:
s.log(logger.Error, pkg+"unexpected error", "error", err.Error())
s.log(logger.Error, "unexpected error", "error", err.Error())
continue
}
}
@ -231,7 +231,7 @@ func (s *mtsSender) output() {
elem = nil
continue
}
s.log(logger.Debug, pkg+"writing")
s.log(logger.Debug, "writing")
_, err = s.dst.Write(elem.Bytes())
if err != nil {
s.log(logger.Debug, "failed write, repairing MTS", "error", err)
@ -267,7 +267,7 @@ func (s *mtsSender) Write(d []byte) (int, error) {
s.ring.Flush()
}
if err != nil {
s.log(logger.Warning, pkg+"ringBuffer write error", "error", err.Error(), "n", n, "size", len(s.buf))
s.log(logger.Warning, "ringBuffer write error", "error", err.Error(), "n", n, "size", len(s.buf))
}
s.buf = s.buf[:0]
}
@ -306,7 +306,7 @@ func newRtmpSender(url string, timeout uint, retries int, rb *vring.Buffer, log
}
log(logger.Error, "dial error", "error", err)
if n < retries-1 {
log(logger.Info, pkg+"retrying dial")
log(logger.Info, "retrying dial")
}
}
s := &rtmpSender{
@ -330,7 +330,7 @@ func (s *rtmpSender) output() {
for {
select {
case <-s.done:
s.log(logger.Info, pkg+"terminating sender output routine")
s.log(logger.Info, "terminating sender output routine")
defer s.wg.Done()
return
default:
@ -342,18 +342,18 @@ func (s *rtmpSender) output() {
case nil, io.EOF:
continue
case vring.ErrNextTimeout:
s.log(logger.Debug, pkg+"ring buffer read timeout")
s.log(logger.Debug, "ring buffer read timeout")
continue
default:
s.log(logger.Error, pkg+"unexpected error", "error", err.Error())
s.log(logger.Error, "unexpected error", "error", err.Error())
continue
}
}
if s.conn == nil {
s.log(logger.Warning, pkg+"no rtmp connection, re-dialing")
s.log(logger.Warning, "no rtmp connection, re-dialing")
err := s.restart()
if err != nil {
s.log(logger.Warning, pkg+"could not restart connection", "error", err)
s.log(logger.Warning, "could not restart connection", "error", err)
continue
}
}
@ -364,10 +364,10 @@ func (s *rtmpSender) output() {
case nil, rtmp.ErrInvalidFlvTag:
s.log(logger.Debug, "good write to conn")
default:
s.log(logger.Warning, pkg+"send error, re-dialing", "error", err)
s.log(logger.Warning, "send error, re-dialing", "error", err)
err = s.restart()
if err != nil {
s.log(logger.Warning, pkg+"could not restart connection", "error", err)
s.log(logger.Warning, "could not restart connection", "error", err)
}
continue
}
@ -385,7 +385,7 @@ func (s *rtmpSender) Write(d []byte) (int, error) {
s.ring.Flush()
s.log(logger.Debug, "good ring buffer write", "len", len(d))
} else {
s.log(logger.Warning, pkg+"ring buffer write error", "error", err.Error())
s.log(logger.Warning, "ring buffer write error", "error", err.Error())
}
s.report(len(d))
return len(d), nil
@ -402,7 +402,7 @@ func (s *rtmpSender) restart() error {
}
s.log(logger.Error, "dial error", "error", err)
if n < s.retries-1 {
s.log(logger.Info, pkg+"retry rtmp connection")
s.log(logger.Info, "retry rtmp connection")
}
}
return err
@ -454,7 +454,7 @@ func (s *rtpSender) Write(d []byte) (int, error) {
copy(s.data, d)
_, err := s.encoder.Write(s.data)
if err != nil {
s.log(logger.Warning, pkg+"rtpSender: write error", err.Error())
s.log(logger.Warning, "rtpSender: write error", err.Error())
}
s.report(len(d))
return len(d), nil