Skip to content

Commit

Permalink
Add more debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mikekatica committed Apr 23, 2024
1 parent d862d13 commit 20edf65
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion subtitleparser/subtitle_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package subtitleparser

import (
"os"
"strings"
"time"

"github.com/golang/glog"
Expand Down Expand Up @@ -46,6 +47,10 @@ type SubtitleTrackHandler struct {
Subtitles map[int64]SubtitleTrack
}

func indent(n int) string {
return strings.Repeat(" ", n)
}

func (p *SubtitleTrackHandler) HandleMasterBegin(id mkvparse.ElementID, info mkvparse.ElementInfo) (bool, error) {
glog.Infof("MasterBegin: Got element ID of %v", id)
if id == mkvparse.TrackEntryElement {
Expand All @@ -71,7 +76,7 @@ func (p *SubtitleTrackHandler) HandleMasterEnd(id mkvparse.ElementID, info mkvpa
}

func (p *SubtitleTrackHandler) HandleString(id mkvparse.ElementID, value string, info mkvparse.ElementInfo) error {

glog.V(4).Infof("%s- %v: %q\n", indent(info.Level), mkvparse.NameForElementID(id), value)
switch id {
case mkvparse.LanguageElement:
glog.V(4).Infof("Found a language for the track of %v", value)
Expand All @@ -89,6 +94,8 @@ func (p *SubtitleTrackHandler) HandleString(id mkvparse.ElementID, value string,
}

func (p *SubtitleTrackHandler) HandleInteger(id mkvparse.ElementID, value int64, info mkvparse.ElementInfo) error {
glog.V(4).Infof("%s- %v: %q\n", indent(info.Level), mkvparse.NameForElementID(id), value)
glog.V(4).Infof("Found a language for the track of %v", value)
switch id {
case mkvparse.TrackUIDElement:
p.currentTrackUID = value
Expand All @@ -105,14 +112,22 @@ func (p *SubtitleTrackHandler) HandleInteger(id mkvparse.ElementID, value int64,
}

func (p *SubtitleTrackHandler) HandleFloat(id mkvparse.ElementID, value float64, info mkvparse.ElementInfo) error {
glog.V(4).Infof("%s- %v: %v\n", indent(info.Level), mkvparse.NameForElementID(id), value)
return nil
}

func (p *SubtitleTrackHandler) HandleDate(id mkvparse.ElementID, value time.Time, info mkvparse.ElementInfo) error {
glog.V(4).Infof("%s- %v: %v\n", indent(info.Level), mkvparse.NameForElementID(id), value)
return nil
}

func (p *SubtitleTrackHandler) HandleBinary(id mkvparse.ElementID, value []byte, info mkvparse.ElementInfo) error {
switch id {
case mkvparse.SeekIDElement:
glog.V(4).Infof("%s- %v: %x\n", indent(info.Level), mkvparse.NameForElementID(id), value)
default:
glog.V(4).Infof("%s- %v: <binary> (%d)\n", indent(info.Level), mkvparse.NameForElementID(id), info.Size)
}
return nil
}

Expand Down

0 comments on commit 20edf65

Please sign in to comment.