From ec290f1058755b52b6013622af02ff4683a7bf61 Mon Sep 17 00:00:00 2001 From: Saxon Date: Sun, 5 May 2019 19:39:56 +0930 Subject: [PATCH 1/2] revid: logging is now checked as a valid device so that logging level may be changed remotely --- revid/config.go | 17 +++++++++-------- revid/revid.go | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/revid/config.go b/revid/config.go index 6f5a0c8a..d9bd4877 100644 --- a/revid/config.go +++ b/revid/config.go @@ -148,7 +148,7 @@ const ( defaultFramesPerClip = 1 httpFramesPerClip = 560 defaultInputCodec = H264 - defaultVerbosity = No // FIXME(kortschak): This makes no sense whatsoever. No is currently 15. + defaultVerbosity = logger.Error defaultRtpAddr = "localhost:6970" defaultBurstPeriod = 10 // Seconds defaultRotation = 0 // Degrees @@ -161,14 +161,15 @@ const ( // if particular parameters have not been defined. func (c *Config) Validate(r *Revid) error { switch c.LogLevel { - case Yes: - case No: - case NothingDefined: - c.LogLevel = defaultVerbosity - c.Logger.Log(logger.Info, pkg+"no LogLevel mode defined, defaulting", - "LogLevel", defaultVerbosity) + case logger.Debug: + case logger.Info: + case logger.Warning: + case logger.Error: + case logger.Fatal: default: - return errors.New("bad LogLevel defined in config") + c.LogLevel = defaultVerbosity + c.Logger.Log(logger.Info, pkg+"bad LogLevel mode defined, defaulting", + "LogLevel", defaultVerbosity) } switch c.Input { diff --git a/revid/revid.go b/revid/revid.go index 72eb52de..3a85df69 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -155,6 +155,8 @@ func (r *Revid) reset(config Config) error { return err } + r.config.Logger.SetLevel(config.LogLevel) + err = r.setupPipeline( func(dst io.WriteCloser, fps int) (io.WriteCloser, error) { e := mts.NewEncoder(dst, float64(fps), mts.Video) @@ -448,6 +450,21 @@ func (r *Revid) Update(vars map[string]string) error { break } r.config.BurstPeriod = uint(v) + case "Logging": + switch value { + case "Debug": + r.config.LogLevel = logger.Debug + case "Info": + r.config.LogLevel = logger.Info + case "Warning": + r.config.LogLevel = logger.Warning + case "Error": + r.config.LogLevel = logger.Error + case "Fatal": + r.config.LogLevel = logger.Fatal + default: + r.config.Logger.Log(logger.Warning, pkg+"invalid Logging param", "value", value) + } } } r.config.Logger.Log(logger.Info, pkg+"revid config changed", "config", fmt.Sprintf("%+v", r.config)) From 39745c98403071efd6006488956474b536638998 Mon Sep 17 00:00:00 2001 From: Saxon Date: Sun, 5 May 2019 19:51:20 +0930 Subject: [PATCH 2/2] av: updated go mod --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index 7ffe0a32..cd09945f 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ bitbucket.org/ausocean/iot v1.2.4 h1:M/473iQ0d4q+76heerjAQuqXzQyc5dZ3F7Bfuq6X7q4= bitbucket.org/ausocean/iot v1.2.4/go.mod h1:5HVLgPHccW2PxS7WDUQO6sKWMgk3Vfze/7d5bHs8EWU= -bitbucket.org/ausocean/utils v0.0.0-20190408050157-66d3b4d4041e h1:rn7Z1vE6m1NSH+mrPJPgquEfBDsqzBEH4Y6fxzyB6kA= -bitbucket.org/ausocean/utils v0.0.0-20190408050157-66d3b4d4041e/go.mod h1:uXzX9z3PLemyURTMWRhVI8uLhPX4uuvaaO85v2hcob8= bitbucket.org/ausocean/utils v1.2.6 h1:JN66APCV+hu6GebIHSu2KSywhLym4vigjSz5+fB0zXc= bitbucket.org/ausocean/utils v1.2.6/go.mod h1:uXzX9z3PLemyURTMWRhVI8uLhPX4uuvaaO85v2hcob8= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=