diff --git a/cmd/revid-cli/main b/cmd/revid-cli/main new file mode 100755 index 00000000..4711d25c Binary files /dev/null and b/cmd/revid-cli/main differ diff --git a/cmd/revid-cli/main.go b/cmd/revid-cli/main.go index 49319db0..8ebe3ab0 100644 --- a/cmd/revid-cli/main.go +++ b/cmd/revid-cli/main.go @@ -145,7 +145,7 @@ func main() { err = run() if err != nil { - config.Logger.Log(progName, "Error", err.Error()) // TODO(kortschak): Make this "Fatal" when that exists. + logger.Log(Error, err.Error()) // TODO(kortschak): Make this "Fatal" when that exists. os.Exit(1) } } @@ -154,7 +154,7 @@ func main() { func run() error { // initialize NetSender and use NetSender's logger //config.Logger = netsender.Logger() - config.Logger.Log(progName, "Info", "Running in NetSender mode") + logger.Log(smartlogger.Info, "Running in NetSender mode") var ns netsender.Sender err := ns.Init(nil, nil, nil, nil) @@ -176,7 +176,7 @@ func run() error { for { if err := send(&ns); err != nil { - config.Logger.Log(progName, "Warning", err.Error()) + logger.Log(smartlogger.Warning, err.Error()) time.Sleep(netSendRetryTime) continue } @@ -185,14 +185,14 @@ func run() error { // vars changed vars, err := ns.Vars() if err != nil { - config.Logger.Log(progName, "Warning", err.Error()) + logger.Log(smartlogger.Warning, err.Error()) time.Sleep(netSendRetryTime) continue } vs = ns.VarSum() if vars["mode"] == "Paused" { if !paused { - config.Logger.Log(progName, "Info", "Pausing revid") + logger.Log(Info, "Pausing revid") stopRevid() paused = true } @@ -234,21 +234,21 @@ func handleFlags() { case "": config.Verbosity = defaultLogVerbosity default: - fmt.Println("Bad input argument!") + logger.Log(smartlogger.Warning, "Bad input argument for LogVerbosity!") } if *cpuprofile != "" { if canProfile { f, err := os.Create(*cpuprofile) if err != nil { - log.Fatal("could not create CPU profile: ", err) + logger.Log(smartlogger.Fatal, "could not create CPU profile: ", err) } if err := pprof.StartCPUProfile(f); err != nil { - log.Fatal("could not start CPU profile: ", err) + logger.Log(smartlogger.Fatal, "could not start CPU profile: ", err) } defer pprof.StopCPUProfile() } else { - fmt.Fprintln(os.Stderr, "Ignoring cpuprofile flag - http/pprof built in.") + logger.Log(smartlogger.Warning, "ignoring cpuprofile flag - http/pprof built in.") } } @@ -259,7 +259,7 @@ func handleFlags() { config.Input = revid.File case "": default: - fmt.Println("Bad input argument!") + logger.Log(smartlogger.Error, "Bad input argument") } switch *configFlags[inputCodecPtr] { @@ -267,7 +267,7 @@ func handleFlags() { config.InputCodec = revid.H264Codec case "": default: - fmt.Println("Bad input codec argument!") + logger.Log(smartlogger.Error, "Bad input codec argument!") } switch *configFlags[outputPtr] { @@ -281,7 +281,7 @@ func handleFlags() { config.Output = revid.FfmpegRtmp case "": default: - fmt.Println("Bad output argument!") + logger.Log(smartlogger.Error, "Bad output argument!") } switch *configFlags[rtmpMethodPtr] { @@ -291,7 +291,7 @@ func handleFlags() { config.RtmpMethod = revid.LibRtmp case "": default: - fmt.Println("Bad rtmp method argument!") + logger.Log(smartlogger.Error, "Bad rtmp method argument!") } switch *configFlags[packetizationPtr] { @@ -303,7 +303,7 @@ func handleFlags() { config.Packetization = revid.Flv case "": default: - fmt.Println("Bad packetization argument!") + logger.Log(smartlogger.Error, "Bad packetization argument!") } switch *configFlags[quantizationModePtr] { @@ -313,7 +313,7 @@ func handleFlags() { config.QuantizationMode = revid.QuantizationOff case "": default: - fmt.Println("Bad quantization mode argument!") + logger.Log(smartlogger.Error, "Bad quantization mode argument!") } switch *configFlags[verbosityPtr] { @@ -323,7 +323,7 @@ func handleFlags() { config.Verbosity = revid.Yes case "": default: - fmt.Println("Bad verbosity argument!") + logger.Log(smartlogger.Error, "Bad verbosity argument!") } switch *configFlags[horizontalFlipPtr] { @@ -334,7 +334,7 @@ func handleFlags() { case "": config.HorizontalFlip = revid.No default: - fmt.Println("Bad horizontal flip option!") + logger.Log(smartlogger.Error, "Bad horizontal flip option!") } switch *configFlags[verticalFlipPtr] { @@ -345,7 +345,7 @@ func handleFlags() { case "": config.VerticalFlip = revid.No default: - fmt.Println("Bad vertical flip option!") + logger.Log(smartlogger.Error, "Bad vertical flip option!") } fpc, err := strconv.Atoi(*configFlags[framesPerClipPtr]) @@ -365,8 +365,6 @@ func handleFlags() { config.IntraRefreshPeriod = *configFlags[intraRefreshPeriodPtr] if !*useNetsender { - // instantiate our own logger - config.Logger = smartlogger.New(loggerVerbosity, smartlogger.File, "/var/log/netsender/") // run revid for the specified duration startRevid(nil) time.Sleep(*runDurationPtr) @@ -435,7 +433,7 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error case "FfmpegRtmp": config.Output = revid.FfmpegRtmp default: - rv.Log(revid.Warning, "Invalid Output param: "+value) + logger.Log(smartlogger.Warning, "Invalid Output param: ", value) continue } case "FramesPerClip": @@ -443,7 +441,7 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error if fpc > 0 && err == nil { config.FramesPerClip = fpc } else { - rv.Log(revid.Warning, "Invalid FramesPerClip param: "+value) + logger.Log(smartlogger.Warning, "Invalid FramesPerClip param: ", value) } case "RtmpUrl": config.RtmpUrl = value @@ -452,7 +450,7 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error if asInt > 0 && err == nil { config.Bitrate = value } else { - rv.Log(revid.Warning, "Invalid Bitrate param: "+value) + logger.Log(smartlogger.Warning, "Invalid Bitrate param: ", value) } case "OutputFileName": config.OutputFileName = value @@ -463,21 +461,21 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error if asInt > 0 && err == nil { config.Height = value } else { - rv.Log(revid.Warning, "Invalid Height param: "+value) + logger.Log(smartlogger.Warning, "Invalid Height param: ", value) } case "Width": asInt, err := strconv.Atoi(value) if asInt > 0 && err == nil { config.Width = value } else { - rv.Log(revid.Warning, "Invalid Width param: "+value) + smartlogger.Log(smartlogger.Warning, "Invalid Width param: ", value) } case "FrameRate": asInt, err := strconv.Atoi(value) if asInt > 0 && err == nil { config.FrameRate = value } else { - rv.Log(revid.Warning, "Invalid FrameRate param: "+value) + smartlogger.Log(smartlogger.Warning, "Invalid FrameRate param: ", value) } case "HttpAddress": config.HttpAddress = value @@ -486,7 +484,7 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error if asInt > 0 && err == nil { config.Quantization = value } else { - rv.Log(revid.Warning, "Invalid Quantization param: "+value) + smartlogger.Log(smartlogger.Warning, "Invalid Quantization param: ", value) } case "Timeout": asInt, err := strconv.Atoi(value) @@ -505,7 +503,7 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error case "No": config.HorizontalFlip = revid.No default: - rv.Log(revid.Warning, "Invalid HorizontalFlip param: "+value) + smartlogger.Log(smartlogger.Warning, "Invalid HorizontalFlip param: ", value) } case "VerticalFlip": switch value { @@ -514,11 +512,11 @@ func updateRevid(ns *netsender.Sender, vars map[string]string, stop bool) error case "No": config.VerticalFlip = revid.No default: - rv.Log(revid.Warning, "Invalid VerticalFlip param: "+value) + smartlogger.Log(smartlogger.Warning, "Invalid VerticalFlip param: ", value) } default: if unicode.IsUpper(rune(key[0])) { - rv.Log(revid.Warning, "Unexpected param: "+key) + smarlogger.Log(smartlogger.Warning, "Unexpected param: ", key) } // else system params are lower case } }