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()
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)
}
}
@ -190,10 +190,10 @@ func handleFlags() {
if canProfile {
f, err := os.Create(*cpuprofile)
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 {
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()
} else {
@ -216,7 +216,7 @@ func handleFlags() {
config.InputCodec = revid.H264Codec
case "":
default:
logger.Log(smartlogger.Error, "Bad input codec argument!")
logger.Log(smartlogger.Error, "Bad input codec argument")
}
switch *configFlags[outputPtr] {
@ -230,7 +230,7 @@ func handleFlags() {
config.Output = revid.FfmpegRtmp
case "":
default:
logger.Log(smartlogger.Error, "Bad output argument!")
logger.Log(smartlogger.Error, "Bad output argument")
}
switch *configFlags[rtmpMethodPtr] {
@ -240,7 +240,7 @@ func handleFlags() {
config.RtmpMethod = revid.LibRtmp
case "":
default:
logger.Log(smartlogger.Error, "Bad rtmp method argument!")
logger.Log(smartlogger.Error, "Bad rtmp method argument")
}
switch *configFlags[packetizationPtr] {
@ -252,7 +252,7 @@ func handleFlags() {
config.Packetization = revid.Flv
case "":
default:
logger.Log(smartlogger.Error, "Bad packetization argument!")
logger.Log(smartlogger.Error, "Bad packetization argument")
}
switch *configFlags[quantizationModePtr] {
@ -262,7 +262,7 @@ func handleFlags() {
config.QuantizationMode = revid.QuantizationOff
case "":
default:
logger.Log(smartlogger.Error, "Bad quantization mode argument!")
logger.Log(smartlogger.Error, "Bad quantization mode argument")
}
switch *configFlags[verbosityPtr] {
@ -272,7 +272,7 @@ func handleFlags() {
config.Verbosity = revid.Yes
case "":
default:
logger.Log(smartlogger.Error, "Bad verbosity argument!")
logger.Log(smartlogger.Error, "Bad verbosity argument")
}
switch *configFlags[horizontalFlipPtr] {
@ -283,7 +283,7 @@ func handleFlags() {
case "":
config.HorizontalFlip = revid.No
default:
logger.Log(smartlogger.Error, "Bad horizontal flip option!")
logger.Log(smartlogger.Error, "Bad horizontal flip option")
}
switch *configFlags[verticalFlipPtr] {
@ -294,7 +294,7 @@ func handleFlags() {
case "":
config.VerticalFlip = revid.No
default:
logger.Log(smartlogger.Error, "Bad vertical flip option!")
logger.Log(smartlogger.Error, "Bad vertical flip option")
}
fpc, err := strconv.Atoi(*configFlags[framesPerClipPtr])
@ -340,7 +340,7 @@ func run() error {
for {
if err := send(&ns); err != nil {
logger.Log(smartlogger.Warning, err.Error())
logger.Log(smartlogger.Error, "Polling failed", "error", err.Error())
time.Sleep(netSendRetryTime)
continue
}
@ -349,7 +349,7 @@ func run() error {
// vars changed
vars, err := ns.Vars()
if err != nil {
logger.Log(smartlogger.Warning, err.Error())
logger.Log(smartlogger.Error, "netSender failed to get vars", "error", err.Error())
time.Sleep(netSendRetryTime)
continue
}
@ -435,7 +435,7 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error
case "FfmpegRtmp":
config.Output = revid.FfmpegRtmp
default:
logger.Log(smartlogger.Warning, "Invalid Output param: ", value)
logger.Log(smartlogger.Warning, "Invalid Output param", "value", value)
continue
}
case "FramesPerClip":
@ -443,7 +443,7 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error
if fpc > 0 && err == nil {
config.FramesPerClip = fpc
} else {
logger.Log(smartlogger.Warning, "Invalid FramesPerClip param: ", value)
logger.Log(smartlogger.Warning, "Invalid FramesPerClip param", "value", value)
}
case "RtmpUrl":
config.RtmpUrl = value
@ -452,7 +452,7 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error
if asInt > 0 && err == nil {
config.Bitrate = value
} else {
logger.Log(smartlogger.Warning, "Invalid Bitrate param: ", value)
logger.Log(smartlogger.Warning, "Invalid Bitrate param", "value", value)
}
case "OutputFileName":
config.OutputFileName = value
@ -463,21 +463,21 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error
if asInt > 0 && err == nil {
config.Height = value
} else {
logger.Log(smartlogger.Warning, "Invalid Height param: ", value)
logger.Log(smartlogger.Warning, "Invalid Height param", "value", value)
}
case "Width":
asInt, err := strconv.Atoi(value)
if asInt > 0 && err == nil {
config.Width = value
} else {
logger.Log(smartlogger.Warning, "Invalid Width param: ", value)
logger.Log(smartlogger.Warning, "Invalid Width param", "value", value)
}
case "FrameRate":
asInt, err := strconv.Atoi(value)
if asInt > 0 && err == nil {
config.FrameRate = value
} else {
logger.Log(smartlogger.Warning, "Invalid FrameRate param: ", value)
logger.Log(smartlogger.Warning, "Invalid FrameRate param", "value", value)
}
case "HttpAddress":
config.HttpAddress = value
@ -486,7 +486,7 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error
if asInt > 0 && err == nil {
config.Quantization = value
} else {
logger.Log(smartlogger.Warning, "Invalid Quantization param: ", value)
logger.Log(smartlogger.Warning, "Invalid Quantization param", "value", value)
}
case "Timeout":
asInt, err := strconv.Atoi(value)
@ -505,7 +505,7 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error
case "No":
config.HorizontalFlip = revid.No
default:
logger.Log(smartlogger.Warning, "Invalid HorizontalFlip param: ", value)
logger.Log(smartlogger.Warning, "Invalid HorizontalFlip param", "value", value)
}
case "VerticalFlip":
switch value {
@ -514,11 +514,11 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error
case "No":
config.VerticalFlip = revid.No
default:
logger.Log(smartlogger.Warning, "Invalid VerticalFlip param: ", value)
logger.Log(smartlogger.Warning, "Invalid VerticalFlip param", "value", value)
}
default:
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
}
}