Merge branch 'master' into m3u-update

This commit is contained in:
Trek H 2020-01-24 15:59:16 +10:30
commit 94e82c898f
3 changed files with 33 additions and 4 deletions

View File

@ -32,7 +32,9 @@ package main
import ( import (
"flag" "flag"
"io"
"os" "os"
"path/filepath"
"runtime/pprof" "runtime/pprof"
"strconv" "strconv"
"strings" "strings"
@ -44,10 +46,11 @@ import (
"bitbucket.org/ausocean/av/device/raspivid" "bitbucket.org/ausocean/av/device/raspivid"
"bitbucket.org/ausocean/av/revid" "bitbucket.org/ausocean/av/revid"
"bitbucket.org/ausocean/av/revid/config" "bitbucket.org/ausocean/av/revid/config"
"bitbucket.org/ausocean/iot/pi/netlogger"
"bitbucket.org/ausocean/iot/pi/netsender" "bitbucket.org/ausocean/iot/pi/netsender"
"bitbucket.org/ausocean/iot/pi/sds" "bitbucket.org/ausocean/iot/pi/sds"
"bitbucket.org/ausocean/iot/pi/smartlogger"
"bitbucket.org/ausocean/utils/logger" "bitbucket.org/ausocean/utils/logger"
"gopkg.in/natefinch/lumberjack.v2"
) )
// Revid modes // Revid modes
@ -72,7 +75,10 @@ const (
var canProfile = true var canProfile = true
// The logger that will be used throughout. // The logger that will be used throughout.
var log *logger.Logger var (
netLog *netlogger.Logger
log *logger.Logger
)
const ( const (
metaPreambleKey = "copyright" metaPreambleKey = "copyright"
@ -160,7 +166,20 @@ func handleFlags() config.Config {
cfg.LogLevel = defaultLogVerbosity cfg.LogLevel = defaultLogVerbosity
} }
log = logger.New(cfg.LogLevel, &smartlogger.New(*logPathPtr).LogRoller, true) netLog = netlogger.New()
log = logger.New(
cfg.LogLevel,
io.MultiWriter(
&lumberjack.Logger{
Filename: filepath.Join(*logPathPtr, "netsender.log"),
MaxSize: 500, // MB
MaxBackups: 10,
MaxAge: 28, // days
},
netLog,
),
true,
)
cfg.Logger = log cfg.Logger = log
@ -296,6 +315,11 @@ func run(cfg config.Config) {
continue continue
} }
err = netLog.Send(ns)
if err != nil {
log.Log(logger.Warning, pkg+"Logs could not be sent", "error", err.Error())
}
// If var sum hasn't changed we continue. // If var sum hasn't changed we continue.
var vars map[string]string var vars map[string]string
newVs := ns.VarSum() newVs := ns.VarSum()

3
go.mod
View File

@ -3,7 +3,7 @@ module bitbucket.org/ausocean/av
go 1.13 go 1.13
require ( require (
bitbucket.org/ausocean/iot v1.2.11 bitbucket.org/ausocean/iot v1.2.13
bitbucket.org/ausocean/utils v1.2.12 bitbucket.org/ausocean/utils v1.2.12
github.com/Comcast/gots v0.0.0-20190305015453-8d56e473f0f7 github.com/Comcast/gots v0.0.0-20190305015453-8d56e473f0f7
github.com/go-audio/audio v0.0.0-20181013203223-7b2a6ca21480 github.com/go-audio/audio v0.0.0-20181013203223-7b2a6ca21480
@ -12,4 +12,5 @@ require (
github.com/pkg/errors v0.8.1 github.com/pkg/errors v0.8.1
github.com/yobert/alsa v0.0.0-20180630182551-d38d89fa843e github.com/yobert/alsa v0.0.0-20180630182551-d38d89fa843e
gocv.io/x/gocv v0.21.0 gocv.io/x/gocv v0.21.0
gopkg.in/natefinch/lumberjack.v2 v2.0.0
) )

4
go.sum
View File

@ -4,6 +4,10 @@ bitbucket.org/ausocean/iot v1.2.10 h1:TTu+ykH5gQA8wU/pN0aS55ySQ/XcGxV4s4LKx3Wye5
bitbucket.org/ausocean/iot v1.2.10/go.mod h1:Q5FwaOKnCty3dVeVtki6DLwYa5vhNpOaeu1lwLyPCg8= bitbucket.org/ausocean/iot v1.2.10/go.mod h1:Q5FwaOKnCty3dVeVtki6DLwYa5vhNpOaeu1lwLyPCg8=
bitbucket.org/ausocean/iot v1.2.11 h1:MwYQK1F2ESA5jPVSCB0lBUN8HBiNDHGkh/OMGJKw8Oc= bitbucket.org/ausocean/iot v1.2.11 h1:MwYQK1F2ESA5jPVSCB0lBUN8HBiNDHGkh/OMGJKw8Oc=
bitbucket.org/ausocean/iot v1.2.11/go.mod h1:Q5FwaOKnCty3dVeVtki6DLwYa5vhNpOaeu1lwLyPCg8= bitbucket.org/ausocean/iot v1.2.11/go.mod h1:Q5FwaOKnCty3dVeVtki6DLwYa5vhNpOaeu1lwLyPCg8=
bitbucket.org/ausocean/iot v1.2.12 h1:Ixf0CTmWOMJVrJ6IYMEluTrCLlu9LM1eNSBZ+ZUnDmU=
bitbucket.org/ausocean/iot v1.2.12/go.mod h1:Q5FwaOKnCty3dVeVtki6DLwYa5vhNpOaeu1lwLyPCg8=
bitbucket.org/ausocean/iot v1.2.13 h1:E9LcW3HYqRgJqxNhPJUCfVRvoV2IAU4B7JSDNxB/x2k=
bitbucket.org/ausocean/iot v1.2.13/go.mod h1:Q5FwaOKnCty3dVeVtki6DLwYa5vhNpOaeu1lwLyPCg8=
bitbucket.org/ausocean/utils v1.2.11 h1:zA0FOaPjN960ryp8PKCkV5y50uWBYrIxCVnXjwbvPqg= bitbucket.org/ausocean/utils v1.2.11 h1:zA0FOaPjN960ryp8PKCkV5y50uWBYrIxCVnXjwbvPqg=
bitbucket.org/ausocean/utils v1.2.11/go.mod h1:uXzX9z3PLemyURTMWRhVI8uLhPX4uuvaaO85v2hcob8= bitbucket.org/ausocean/utils v1.2.11/go.mod h1:uXzX9z3PLemyURTMWRhVI8uLhPX4uuvaaO85v2hcob8=
bitbucket.org/ausocean/utils v1.2.12 h1:VnskjWTDM475TnQRhBQE0cNp9D6Y6OELrd4UkD2VVIQ= bitbucket.org/ausocean/utils v1.2.12 h1:VnskjWTDM475TnQRhBQE0cNp9D6Y6OELrd4UkD2VVIQ=