diff --git a/cmd/revid-cli/main.go b/cmd/revid-cli/main.go index 87185323..d5cc51db 100644 --- a/cmd/revid-cli/main.go +++ b/cmd/revid-cli/main.go @@ -32,7 +32,9 @@ package main import ( "flag" + "io" "os" + "path/filepath" "runtime/pprof" "strconv" "strings" @@ -44,10 +46,11 @@ import ( "bitbucket.org/ausocean/av/device/raspivid" "bitbucket.org/ausocean/av/revid" "bitbucket.org/ausocean/av/revid/config" + "bitbucket.org/ausocean/iot/pi/netlogger" "bitbucket.org/ausocean/iot/pi/netsender" "bitbucket.org/ausocean/iot/pi/sds" - "bitbucket.org/ausocean/iot/pi/smartlogger" "bitbucket.org/ausocean/utils/logger" + "gopkg.in/natefinch/lumberjack.v2" ) // Revid modes @@ -73,8 +76,8 @@ var canProfile = true // The logger that will be used throughout. var ( - smartLog *smartlogger.Smartlogger - log *logger.Logger + netLogger *netlogger.NetLogger + log *logger.Logger ) const ( @@ -163,8 +166,16 @@ func handleFlags() config.Config { cfg.LogLevel = defaultLogVerbosity } - smartLog = smartlogger.New(*logPathPtr) - log = logger.New(cfg.LogLevel, &smartLog.LogRoller, true) + netLogger = netlogger.New() + log = logger.New(cfg.LogLevel, io.MultiWriter( + &lumberjack.Logger{ + Filename: filepath.Join(*logPathPtr, "netsender.log"), + MaxSize: 500, // megabytes + MaxBackups: 10, + MaxAge: 28, // days + }, + netLogger, + ), true) cfg.Logger = log @@ -355,7 +366,7 @@ func run(cfg config.Config) { ns.SetMode(paused, &vs) } - smartLog.SendLogs(ns) + netLogger.SendLogs(ns) sleep: sleepTime, err := strconv.Atoi(ns.Param("mp"))