2018-04-19 10:03:12 +03:00
|
|
|
/*
|
|
|
|
NAME
|
|
|
|
RevidCLI.go
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
See Readme.md
|
|
|
|
|
|
|
|
AUTHORS
|
|
|
|
Saxon A. Nelson-Milton <saxon@ausocean.org>
|
|
|
|
Jack Richardson <jack@ausocean.org>
|
|
|
|
|
|
|
|
LICENSE
|
|
|
|
RevidCLI.go is Copyright (C) 2017 the Australian Ocean Lab (AusOcean)
|
|
|
|
|
|
|
|
It is free software: you can redistribute it and/or modify them
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with revid in gpl.txt. If not, see [GNU licenses](http://www.gnu.org/licenses).
|
|
|
|
*/
|
2018-04-15 13:42:06 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
2018-04-19 09:42:07 +03:00
|
|
|
"strconv"
|
2018-04-19 11:19:36 +03:00
|
|
|
"time"
|
2018-04-19 08:58:16 +03:00
|
|
|
|
2018-04-19 11:19:36 +03:00
|
|
|
"bitbucket.org/ausocean/av/revid"
|
2018-04-19 08:58:16 +03:00
|
|
|
"bitbucket.org/ausocean/IoT/pi/netsender"
|
2018-04-15 13:42:06 +03:00
|
|
|
)
|
|
|
|
|
2018-04-19 11:11:18 +03:00
|
|
|
// Indexes for configFlags
|
2018-04-15 13:42:06 +03:00
|
|
|
const (
|
|
|
|
inputPtr = 0
|
|
|
|
inputCodecPtr = 1
|
|
|
|
outputPtr = 2
|
|
|
|
rtmpMethodPtr = 3
|
2018-04-19 11:19:36 +03:00
|
|
|
packetizationPtr = 4
|
2018-04-15 13:42:06 +03:00
|
|
|
quantizationModePtr = 5
|
|
|
|
verbosityPtr = 6
|
2018-04-19 11:24:44 +03:00
|
|
|
framesPerClipPtr = 7
|
2018-04-15 13:42:06 +03:00
|
|
|
rtmpUrlPtr = 8
|
|
|
|
bitratePtr = 9
|
|
|
|
outputFileNamePtr = 10
|
|
|
|
inputFileNamePtr = 11
|
|
|
|
heightPtr = 12
|
|
|
|
widthPtr = 13
|
|
|
|
frameRatePtr = 14
|
|
|
|
httpAddressPtr = 15
|
|
|
|
quantizationPtr = 18
|
|
|
|
timeoutPtr = 19
|
|
|
|
intraRefreshPeriodPtr = 20
|
|
|
|
)
|
|
|
|
|
2018-04-19 09:42:07 +03:00
|
|
|
// Other misc consts
|
|
|
|
const (
|
|
|
|
sleepTime = 2 * 43200
|
|
|
|
defaultRunDuration = 2 * 43200
|
2018-04-19 11:19:36 +03:00
|
|
|
noOfConfigconfigFlags = 21
|
2018-04-19 09:42:07 +03:00
|
|
|
revidStopTime = 5
|
|
|
|
)
|
|
|
|
|
|
|
|
// Globals
|
|
|
|
var (
|
2018-04-19 08:58:16 +03:00
|
|
|
configReceived bool = true
|
2018-04-19 09:42:07 +03:00
|
|
|
varSum int = 0
|
|
|
|
vars = make(map[string]string)
|
2018-04-19 11:11:18 +03:00
|
|
|
revidInst revid.Revid
|
2018-04-19 10:25:37 +03:00
|
|
|
config revid.Config
|
2018-04-19 08:58:16 +03:00
|
|
|
)
|
|
|
|
|
2018-04-15 13:42:06 +03:00
|
|
|
func main() {
|
|
|
|
flagNames := [19][2]string{
|
2018-04-19 09:42:07 +03:00
|
|
|
{"Input", "The input type"},
|
|
|
|
{"InputCodec", "The codec of the input"},
|
|
|
|
{"Output", "The output type"},
|
|
|
|
{"RtmpMethod", "The method used to send over rtmp (ffmpeg or librtmp)"},
|
|
|
|
{"Packetization", "The method of data packetisation"},
|
|
|
|
{"QuantizationMode", "The level of quantization"},
|
|
|
|
{"Verbosity", "Verbosity on or off"},
|
|
|
|
{"FramesPerClip", "Number of frames per clip sent"},
|
|
|
|
{"RtmpUrl", "Url of rtmp endpoint"},
|
|
|
|
{"Bitrate", "Bitrate of recorded video"},
|
|
|
|
{"OutputFileName", "The directory of the output file"},
|
|
|
|
{"InputFileName", "The directory of the input file"},
|
|
|
|
{"Height", "Height in pixels"},
|
|
|
|
{"Width", "Width in pixels"},
|
|
|
|
{"FrameRate", "Frame rate of captured video"},
|
|
|
|
{"HttpAddress", "Destination address of http posts"},
|
|
|
|
{"Quantization", "Desired quantization value"},
|
|
|
|
{"Timeout", "Http timeout in seconds"},
|
|
|
|
{"IntraRefreshPeriod", "The IntraRefreshPeriod i.e. how many keyframes we send"},
|
2018-04-15 13:42:06 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 11:11:18 +03:00
|
|
|
// Create the configFlags based on the flagNames array
|
|
|
|
var configFlags [noOfConfigconfigFlags](*string)
|
2018-04-15 13:42:06 +03:00
|
|
|
for i := 0; i < 20; i++ {
|
2018-04-19 11:11:18 +03:00
|
|
|
configFlags[i] = flag.String(flagNames[i][0], "", flagNames[i][1])
|
2018-04-15 13:42:06 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 10:03:12 +03:00
|
|
|
// Do we want a netsender session
|
2018-04-19 09:42:07 +03:00
|
|
|
netSenderFlagPtr := flag.Bool("netSender", false, "Are we checking vars through netsender?")
|
2018-04-19 10:03:12 +03:00
|
|
|
// User might also want to define how long revid runs for
|
|
|
|
runDurationPtr := flag.Int("runDuration",defaultRunDuration,"How long do you want revid to run for?")
|
2018-04-19 09:42:07 +03:00
|
|
|
|
2018-04-15 13:42:06 +03:00
|
|
|
flag.Parse()
|
|
|
|
|
2018-04-19 11:14:38 +03:00
|
|
|
switch *configFlags[inputPtr] {
|
2018-04-15 13:42:06 +03:00
|
|
|
case "Raspivid":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.Input = revid.Raspivid
|
2018-04-15 13:42:06 +03:00
|
|
|
case "Rtp":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.Input = revid.Rtp
|
2018-04-15 13:42:06 +03:00
|
|
|
case "File":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.Input = revid.File
|
2018-04-15 13:42:06 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 11:14:38 +03:00
|
|
|
switch *configFlags[inputCodecPtr] {
|
2018-04-15 13:42:06 +03:00
|
|
|
case "H264Codec":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.InputCodec = revid.H264Codec
|
2018-04-15 13:42:06 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 11:14:38 +03:00
|
|
|
switch *configFlags[outputPtr] {
|
2018-04-15 13:42:06 +03:00
|
|
|
case "File":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.Output = revid.File
|
2018-04-15 13:42:06 +03:00
|
|
|
case "Http":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.Output = revid.Http
|
2018-04-15 13:42:06 +03:00
|
|
|
case "Rtmp":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.Output = revid.Rtmp
|
2018-04-15 13:42:06 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 11:14:38 +03:00
|
|
|
switch *configFlags[rtmpMethodPtr] {
|
2018-04-15 13:42:06 +03:00
|
|
|
case "Ffmpeg":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.RtmpMethod = revid.Ffmpeg
|
2018-04-15 13:42:06 +03:00
|
|
|
case "LibRtmp":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.RtmpMethod = revid.LibRtmp
|
2018-04-15 13:42:06 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 11:24:44 +03:00
|
|
|
switch *configFlags[packetizationPtr] {
|
2018-04-15 13:42:06 +03:00
|
|
|
case "None":
|
2018-04-19 11:19:36 +03:00
|
|
|
config.Packetization = revid.None
|
2018-04-15 13:42:06 +03:00
|
|
|
case "Rtp":
|
2018-04-19 11:19:36 +03:00
|
|
|
config.Packetization = revid.Rtp
|
2018-04-15 13:42:06 +03:00
|
|
|
case "Flv":
|
2018-04-19 11:19:36 +03:00
|
|
|
config.Packetization = revid.Flv
|
2018-04-15 13:42:06 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 11:19:36 +03:00
|
|
|
switch *configFlags[quantizationModePtr] {
|
2018-04-15 13:42:06 +03:00
|
|
|
case "QuantizationOn":
|
2018-04-19 11:24:44 +03:00
|
|
|
config.QuantizationMode = revid.QuantizationOn
|
2018-04-15 13:42:06 +03:00
|
|
|
case "QuantizationOff":
|
2018-04-19 11:24:44 +03:00
|
|
|
config.QuantizationMode = revid.QuantizationOff
|
2018-04-15 13:42:06 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 11:14:38 +03:00
|
|
|
switch *configFlags[verbosityPtr] {
|
2018-04-15 13:42:06 +03:00
|
|
|
case "No":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.Verbosity = revid.No
|
2018-04-15 13:42:06 +03:00
|
|
|
case "Yes":
|
2018-04-19 11:16:26 +03:00
|
|
|
config.Verbosity = revid.Yes
|
2018-04-15 13:42:06 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 11:14:38 +03:00
|
|
|
config.FramesPerClip = *configFlags[framesPerClipPtr]
|
|
|
|
config.RtmpUrl = *configFlags[rtmpUrlPtr]
|
|
|
|
config.Bitrate = *configFlags[bitratePtr]
|
|
|
|
config.OutputFileName = *configFlags[outputFileNamePtr]
|
|
|
|
config.InputFileName = *configFlags[inputFileNamePtr]
|
|
|
|
config.Height = *configFlags[heightPtr]
|
|
|
|
config.Width = *configFlags[widthPtr]
|
|
|
|
config.FrameRate = *configFlags[frameRatePtr]
|
|
|
|
config.HttpAddress = *configFlags[httpAddressPtr]
|
|
|
|
config.Quantization = *configFlags[quantisationPtr]
|
|
|
|
config.Timeout = *configFlags[timeoutPtr]
|
|
|
|
config.IntraRefreshPeriod = *configFlags[intraRefreshPeriodPtr]
|
2018-04-19 09:42:07 +03:00
|
|
|
|
2018-04-19 10:03:12 +03:00
|
|
|
createRevidInstance()
|
2018-04-19 11:11:18 +03:00
|
|
|
revidInst.Start()
|
2018-04-19 08:58:16 +03:00
|
|
|
|
2018-04-19 10:03:12 +03:00
|
|
|
// Is the netsender flag been used ? if so run this loop
|
2018-04-19 09:42:07 +03:00
|
|
|
for *netSenderFlagPtr {
|
2018-04-19 08:58:16 +03:00
|
|
|
periodicNetsenderReport()
|
|
|
|
sleepTime, err := strconv.Atoi(netsender.GetConfigParam("monPeriod"))
|
|
|
|
time.Sleep(time.Duration(sleepTime) * time.Second)
|
|
|
|
}
|
2018-04-19 09:42:07 +03:00
|
|
|
|
2018-04-19 10:03:12 +03:00
|
|
|
// If we're not running a netsender session then we run revid for the amount
|
|
|
|
// of time the user defined or the default 2 days
|
2018-04-19 09:42:07 +03:00
|
|
|
time.Sleep( time.Duration(*runDurationPtr) * time.Second )
|
2018-04-19 11:24:44 +03:00
|
|
|
revidInst.Stop()
|
2018-04-19 08:58:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func netsenderInit() {
|
|
|
|
netsender.InitRevidNetsender()
|
|
|
|
netsender.ExternalReader = revidReportActions
|
|
|
|
|
|
|
|
if err := netsender.GetConfig(); err != nil {
|
|
|
|
//default to a config?????
|
|
|
|
processManager.Logger.Log("Error", err.Error())
|
|
|
|
} else {
|
|
|
|
configReceived = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func periodicNetsenderReport(){
|
|
|
|
if !configReceived {
|
|
|
|
if err := netsender.GetConfig(); err != nil {
|
|
|
|
processManager.Logger.Log("Error", err.Error())
|
|
|
|
} else {
|
|
|
|
configReceived = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var reply string
|
|
|
|
if reply, reconfig, err = netsender.Send(netsender.RequestPoll, criticalInputs); err != nil {
|
|
|
|
processManager.Logger.Log("Error", err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
if cloudVarSum := netsender.GetVarSum(); cloudVarSum != varSum {
|
|
|
|
if newVars, err := netsender.GetVars(); err != nil {
|
|
|
|
processManager.Logger.Log("Error", err.Error())
|
|
|
|
} else {
|
|
|
|
varSum = cloudVarSum
|
|
|
|
for newVar, value := range newVars {
|
|
|
|
if currentValue, varExists := vars[newVar]; !varExists || currentValue != value {
|
|
|
|
vars[newVar] = value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
updateRevid()
|
2018-04-19 09:42:07 +03:00
|
|
|
}
|
2018-04-19 08:58:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func updateRevid() {
|
2018-04-19 11:11:18 +03:00
|
|
|
revidInst.Stop()
|
2018-04-19 09:42:07 +03:00
|
|
|
time.Sleep( time.Duration(revidStopTime) * time.Second )
|
2018-04-19 08:58:16 +03:00
|
|
|
for key, value := range vars {
|
|
|
|
switch key {
|
|
|
|
case "FramesPerClip":
|
2018-04-19 10:03:12 +03:00
|
|
|
asInt,err := strconv.Atoi(value)
|
|
|
|
if asInt > 0 && err == nil {
|
|
|
|
config.FramesPerClip = value
|
|
|
|
}
|
2018-04-19 08:58:16 +03:00
|
|
|
case "RtmpUrl":
|
|
|
|
config.RtmpUrl = value
|
|
|
|
case "Bitrate":
|
2018-04-19 10:03:12 +03:00
|
|
|
asInt,err := strconv.Atoi(value)
|
|
|
|
if asInt > 0 && err == nil {
|
|
|
|
config.Bitrate = value
|
|
|
|
}
|
2018-04-19 08:58:16 +03:00
|
|
|
case "OutputFileName":
|
|
|
|
config.OutputFileName = value
|
|
|
|
case "InputFileName":
|
|
|
|
config.InputFileName = value
|
|
|
|
case "Height":
|
2018-04-19 10:03:12 +03:00
|
|
|
asInt,err := strconv.Atoi(value)
|
|
|
|
if asInt > 0 && err == nil {
|
|
|
|
config.Height = value
|
|
|
|
}
|
2018-04-19 08:58:16 +03:00
|
|
|
case "Width":
|
2018-04-19 10:03:12 +03:00
|
|
|
asInt,err := strconv.Atoi(value)
|
|
|
|
if asInt > 0 && err == nil {
|
|
|
|
config.Width = value
|
|
|
|
}
|
2018-04-19 08:58:16 +03:00
|
|
|
case "FrameRate":
|
2018-04-19 10:03:12 +03:00
|
|
|
asInt,err := strconv.Atoi(value)
|
|
|
|
if asInt > 0 && err == nil {
|
|
|
|
config.FrameRate = value
|
|
|
|
}
|
2018-04-19 08:58:16 +03:00
|
|
|
case "HttpAddress":
|
|
|
|
config.HttpAddress = value
|
|
|
|
case "Quantization":
|
2018-04-19 10:03:12 +03:00
|
|
|
asInt,err := strconv.Atoi(value)
|
|
|
|
if asInt > 0 && err == nil {
|
|
|
|
config.Quantization = value
|
|
|
|
}
|
2018-04-19 08:58:16 +03:00
|
|
|
case "Timeout":
|
2018-04-19 10:03:12 +03:00
|
|
|
asInt,err := strconv.Atoi(value)
|
|
|
|
if asInt > 0 && err == nil {
|
|
|
|
config.Timeout = value
|
|
|
|
}
|
2018-04-19 08:58:16 +03:00
|
|
|
case "IntraRefreshPeriod":
|
2018-04-19 10:03:12 +03:00
|
|
|
asInt,err := strconv.Atoi(value)
|
|
|
|
if asInt > 0 && err == nil {
|
|
|
|
confog.IntraRefreshPeriod = value
|
|
|
|
}
|
2018-04-19 08:58:16 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-19 10:03:12 +03:00
|
|
|
createRevidInstance()
|
2018-04-19 11:11:18 +03:00
|
|
|
revidInst.Start()
|
2018-04-19 08:58:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func revidReportActions(pin int) (int, error) {
|
|
|
|
switch {
|
|
|
|
// case pin == ds18b20Temp:
|
|
|
|
// sensors, err := ds18b20.Sensors()
|
|
|
|
// if err != nil {
|
|
|
|
// processManager.Logger.Log("Error", "Error retrieving connected sensors: "+err.Error())
|
|
|
|
// return -1, errors.New("No sensors connected")
|
|
|
|
// }
|
|
|
|
|
|
|
|
// t, err := ds18b20.Temperature(sensors[0])
|
|
|
|
// if err == nil {
|
|
|
|
// return int(t), nil
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return -1, errors.New("Unable to read temperature")
|
|
|
|
|
|
|
|
// case pin == dht11Temp:
|
|
|
|
// if val, _, _, err := dht.ReadDHTxxWithRetry(dht.DHT11, dhtPin, false, 5); err != nil {
|
|
|
|
// return -1, errors.New("DHT Read Err: " + err.Error())
|
|
|
|
// } else {
|
|
|
|
// return int(val), nil
|
|
|
|
// }
|
|
|
|
|
|
|
|
// case pin == dht11Hum:
|
|
|
|
// if _, val, _, err := dht.ReadDHTxxWithRetry(dht.DHT11, dhtPin, false, 5); err != nil {
|
|
|
|
// return -1, errors.New("DHT Read Err: " + err.Error())
|
|
|
|
// } else {
|
|
|
|
// return int(val), nil
|
|
|
|
// }
|
|
|
|
|
|
|
|
// case pin == dht22Temp:
|
|
|
|
// if val, _, _, err := dht.ReadDHTxxWithRetry(dht.DHT22, dhtPin, false, 5); err != nil {
|
|
|
|
// return -1, errors.New("DHT Read Err: " + err.Error())
|
|
|
|
// } else {
|
|
|
|
// return int(val), nil
|
|
|
|
// }
|
|
|
|
|
|
|
|
// case pin == dht22Hum:
|
|
|
|
// if _, val, _, err := dht.ReadDHTxxWithRetry(dht.DHT22, dhtPin, false, 5); err != nil {
|
|
|
|
// return -1, errors.New("DHT Read Err: " + err.Error())
|
|
|
|
// } else {
|
|
|
|
// return int(val), nil
|
|
|
|
// }
|
|
|
|
|
|
|
|
case pin == cpuTemp:
|
|
|
|
var out []byte
|
|
|
|
var err error
|
|
|
|
var val float64
|
|
|
|
if out, err = exec.Command("/opt/vc/bin/vcgencmd", "measure_temp").Output(); err != nil {
|
|
|
|
return -1, errors.New("CPU Temp Read Err: " + err.Error())
|
|
|
|
}
|
|
|
|
if val, err = strconv.ParseFloat(string(out[5:len(out)-3]), 32); err != nil {
|
|
|
|
return -1, errors.New("CPU Temp Read Err: " + err.Error())
|
|
|
|
}
|
|
|
|
return int(val), nil
|
|
|
|
|
|
|
|
case pin == cpuUsage:
|
|
|
|
stat, err := linuxproc.ReadStat("/proc/stat")
|
|
|
|
if err != nil {
|
|
|
|
return -1, errors.New("CPU Uage Read Err: " + err.Error())
|
|
|
|
}
|
2018-04-19 09:42:07 +03:00
|
|
|
total1 := stat.CPUStatAll.User + stat.CPUStatAll.Nice + stat.CPUStatAll.System +
|
|
|
|
stat.CPUStatAll.Idle + stat.CPUStatAll.IOWait + stat.CPUStatAll.IRQ +
|
|
|
|
stat.CPUStatAll.SoftIRQ + stat.CPUStatAll.Steal + stat.CPUStatAll.Guest +
|
|
|
|
stat.CPUStatAll.GuestNice
|
2018-04-19 08:58:16 +03:00
|
|
|
idle1 := stat.CPUStatAll.Idle
|
|
|
|
|
|
|
|
time.Sleep(time.Millisecond * 100)
|
|
|
|
|
|
|
|
stat, err = linuxproc.ReadStat("/proc/stat")
|
|
|
|
if err != nil {
|
|
|
|
return -1, errors.New("CPU Uage Read Err: " + err.Error())
|
|
|
|
}
|
2018-04-19 09:42:07 +03:00
|
|
|
total2 := stat.CPUStatAll.User + stat.CPUStatAll.Nice + stat.CPUStatAll.System +
|
|
|
|
stat.CPUStatAll.Idle + stat.CPUStatAll.IOWait + stat.CPUStatAll.IRQ +
|
|
|
|
stat.CPUStatAll.SoftIRQ + stat.CPUStatAll.Steal + stat.CPUStatAll.Guest +
|
|
|
|
stat.CPUStatAll.GuestNice
|
2018-04-19 08:58:16 +03:00
|
|
|
idle2 := stat.CPUStatAll.Idle
|
|
|
|
|
|
|
|
return int((1.0 - (float64(idle2-idle1) / float64(total2-total1))) * 100), nil
|
|
|
|
|
|
|
|
// case pin == priority:
|
|
|
|
// return int(processManager.PriorityLevel), nil
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -1, errors.New("External pin not defined")
|
|
|
|
}
|
2018-04-15 13:42:06 +03:00
|
|
|
}
|
2018-04-19 10:03:12 +03:00
|
|
|
|
|
|
|
func createRevidInstance(){
|
|
|
|
// Try to create the revid instance with the given config
|
2018-04-19 11:11:18 +03:00
|
|
|
for revidInst, err := revid.NewRevid(config); err != nil; {
|
2018-04-19 10:03:12 +03:00
|
|
|
// If the config does have a logger, use it to output error, otherwise
|
|
|
|
// just output to std output
|
|
|
|
if config.Logger != nil {
|
|
|
|
config.Logger.Log("FATAL ERROR", err)
|
|
|
|
} else {
|
|
|
|
fmt.Printf("FATAL ERROR: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|