revid-cli: added key value paris to log messages

This commit is contained in:
saxon 2018-09-13 12:14:23 +09:30
parent bee7d82247
commit 852e714d13
1 changed files with 23 additions and 23 deletions

View File

@ -143,7 +143,7 @@ func main() {
err := run() err := run()
if err != nil { if err != nil {
logger.Log(smartlogger.Error, err.Error()) // TODO(kortschak): Make this "Fatal" when that exists. logger.Log(smartlogger.Error, "Failed to run revid", "error", err.Error()) // TODO(kortschak): Make this "Fatal" when that exists.
os.Exit(1) os.Exit(1)
} }
} }
@ -190,10 +190,10 @@ func handleFlags() {
if canProfile { if canProfile {
f, err := os.Create(*cpuprofile) f, err := os.Create(*cpuprofile)
if err != nil { if err != nil {
logger.Log(smartlogger.Fatal, "could not create CPU profile: ", err) logger.Log(smartlogger.Fatal, "Could not create CPU profile", "error", err.Error())
} }
if err := pprof.StartCPUProfile(f); err != nil { if err := pprof.StartCPUProfile(f); err != nil {
logger.Log(smartlogger.Fatal, "could not start CPU profile: ", err) logger.Log(smartlogger.Fatal, "Could not start CPU profile", "error", err.Error())
} }
defer pprof.StopCPUProfile() defer pprof.StopCPUProfile()
} else { } else {
@ -216,7 +216,7 @@ func handleFlags() {
config.InputCodec = revid.H264Codec config.InputCodec = revid.H264Codec
case "": case "":
default: default:
logger.Log(smartlogger.Error, "Bad input codec argument!") logger.Log(smartlogger.Error, "Bad input codec argument")
} }
switch *configFlags[outputPtr] { switch *configFlags[outputPtr] {
@ -230,7 +230,7 @@ func handleFlags() {
config.Output = revid.FfmpegRtmp config.Output = revid.FfmpegRtmp
case "": case "":
default: default:
logger.Log(smartlogger.Error, "Bad output argument!") logger.Log(smartlogger.Error, "Bad output argument")
} }
switch *configFlags[rtmpMethodPtr] { switch *configFlags[rtmpMethodPtr] {
@ -240,7 +240,7 @@ func handleFlags() {
config.RtmpMethod = revid.LibRtmp config.RtmpMethod = revid.LibRtmp
case "": case "":
default: default:
logger.Log(smartlogger.Error, "Bad rtmp method argument!") logger.Log(smartlogger.Error, "Bad rtmp method argument")
} }
switch *configFlags[packetizationPtr] { switch *configFlags[packetizationPtr] {
@ -252,7 +252,7 @@ func handleFlags() {
config.Packetization = revid.Flv config.Packetization = revid.Flv
case "": case "":
default: default:
logger.Log(smartlogger.Error, "Bad packetization argument!") logger.Log(smartlogger.Error, "Bad packetization argument")
} }
switch *configFlags[quantizationModePtr] { switch *configFlags[quantizationModePtr] {
@ -262,7 +262,7 @@ func handleFlags() {
config.QuantizationMode = revid.QuantizationOff config.QuantizationMode = revid.QuantizationOff
case "": case "":
default: default:
logger.Log(smartlogger.Error, "Bad quantization mode argument!") logger.Log(smartlogger.Error, "Bad quantization mode argument")
} }
switch *configFlags[verbosityPtr] { switch *configFlags[verbosityPtr] {
@ -272,7 +272,7 @@ func handleFlags() {
config.Verbosity = revid.Yes config.Verbosity = revid.Yes
case "": case "":
default: default:
logger.Log(smartlogger.Error, "Bad verbosity argument!") logger.Log(smartlogger.Error, "Bad verbosity argument")
} }
switch *configFlags[horizontalFlipPtr] { switch *configFlags[horizontalFlipPtr] {
@ -283,7 +283,7 @@ func handleFlags() {
case "": case "":
config.HorizontalFlip = revid.No config.HorizontalFlip = revid.No
default: default:
logger.Log(smartlogger.Error, "Bad horizontal flip option!") logger.Log(smartlogger.Error, "Bad horizontal flip option")
} }
switch *configFlags[verticalFlipPtr] { switch *configFlags[verticalFlipPtr] {
@ -294,7 +294,7 @@ func handleFlags() {
case "": case "":
config.VerticalFlip = revid.No config.VerticalFlip = revid.No
default: default:
logger.Log(smartlogger.Error, "Bad vertical flip option!") logger.Log(smartlogger.Error, "Bad vertical flip option")
} }
fpc, err := strconv.Atoi(*configFlags[framesPerClipPtr]) fpc, err := strconv.Atoi(*configFlags[framesPerClipPtr])
@ -340,7 +340,7 @@ func run() error {
for { for {
if err := send(&ns); err != nil { if err := send(&ns); err != nil {
logger.Log(smartlogger.Warning, err.Error()) logger.Log(smartlogger.Error, "Polling failed", "error", err.Error())
time.Sleep(netSendRetryTime) time.Sleep(netSendRetryTime)
continue continue
} }
@ -349,7 +349,7 @@ func run() error {
// vars changed // vars changed
vars, err := ns.Vars() vars, err := ns.Vars()
if err != nil { if err != nil {
logger.Log(smartlogger.Warning, err.Error()) logger.Log(smartlogger.Error, "netSender failed to get vars", "error", err.Error())
time.Sleep(netSendRetryTime) time.Sleep(netSendRetryTime)
continue continue
} }
@ -435,7 +435,7 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error
case "FfmpegRtmp": case "FfmpegRtmp":
config.Output = revid.FfmpegRtmp config.Output = revid.FfmpegRtmp
default: default:
logger.Log(smartlogger.Warning, "Invalid Output param: ", value) logger.Log(smartlogger.Warning, "Invalid Output param", "value", value)
continue continue
} }
case "FramesPerClip": case "FramesPerClip":
@ -443,7 +443,7 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error
if fpc > 0 && err == nil { if fpc > 0 && err == nil {
config.FramesPerClip = fpc config.FramesPerClip = fpc
} else { } else {
logger.Log(smartlogger.Warning, "Invalid FramesPerClip param: ", value) logger.Log(smartlogger.Warning, "Invalid FramesPerClip param", "value", value)
} }
case "RtmpUrl": case "RtmpUrl":
config.RtmpUrl = value config.RtmpUrl = value
@ -452,7 +452,7 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error
if asInt > 0 && err == nil { if asInt > 0 && err == nil {
config.Bitrate = value config.Bitrate = value
} else { } else {
logger.Log(smartlogger.Warning, "Invalid Bitrate param: ", value) logger.Log(smartlogger.Warning, "Invalid Bitrate param", "value", value)
} }
case "OutputFileName": case "OutputFileName":
config.OutputFileName = value config.OutputFileName = value
@ -463,21 +463,21 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error
if asInt > 0 && err == nil { if asInt > 0 && err == nil {
config.Height = value config.Height = value
} else { } else {
logger.Log(smartlogger.Warning, "Invalid Height param: ", value) logger.Log(smartlogger.Warning, "Invalid Height param", "value", value)
} }
case "Width": case "Width":
asInt, err := strconv.Atoi(value) asInt, err := strconv.Atoi(value)
if asInt > 0 && err == nil { if asInt > 0 && err == nil {
config.Width = value config.Width = value
} else { } else {
logger.Log(smartlogger.Warning, "Invalid Width param: ", value) logger.Log(smartlogger.Warning, "Invalid Width param", "value", value)
} }
case "FrameRate": case "FrameRate":
asInt, err := strconv.Atoi(value) asInt, err := strconv.Atoi(value)
if asInt > 0 && err == nil { if asInt > 0 && err == nil {
config.FrameRate = value config.FrameRate = value
} else { } else {
logger.Log(smartlogger.Warning, "Invalid FrameRate param: ", value) logger.Log(smartlogger.Warning, "Invalid FrameRate param", "value", value)
} }
case "HttpAddress": case "HttpAddress":
config.HttpAddress = value config.HttpAddress = value
@ -486,7 +486,7 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error
if asInt > 0 && err == nil { if asInt > 0 && err == nil {
config.Quantization = value config.Quantization = value
} else { } else {
logger.Log(smartlogger.Warning, "Invalid Quantization param: ", value) logger.Log(smartlogger.Warning, "Invalid Quantization param", "value", value)
} }
case "Timeout": case "Timeout":
asInt, err := strconv.Atoi(value) asInt, err := strconv.Atoi(value)
@ -505,7 +505,7 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error
case "No": case "No":
config.HorizontalFlip = revid.No config.HorizontalFlip = revid.No
default: default:
logger.Log(smartlogger.Warning, "Invalid HorizontalFlip param: ", value) logger.Log(smartlogger.Warning, "Invalid HorizontalFlip param", "value", value)
} }
case "VerticalFlip": case "VerticalFlip":
switch value { switch value {
@ -514,11 +514,11 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error
case "No": case "No":
config.VerticalFlip = revid.No config.VerticalFlip = revid.No
default: default:
logger.Log(smartlogger.Warning, "Invalid VerticalFlip param: ", value) logger.Log(smartlogger.Warning, "Invalid VerticalFlip param", "value", value)
} }
default: default:
if unicode.IsUpper(rune(key[0])) { if unicode.IsUpper(rune(key[0])) {
logger.Log(smartlogger.Warning, "Unexpected param: ", key) logger.Log(smartlogger.Warning, "Unexpected param", "value", key)
} // else system params are lower case } // else system params are lower case
} }
} }