0

Add -logdir flag (#1039)

This allow configuring the various logs that may be outputted
(transcoder and future logs)
This commit is contained in:
tomleb 2021-05-22 19:29:49 -04:00 committed by GitHub
parent e311cb53ea
commit 1504ea3509
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package config package config
import ( import (
"path/filepath"
"fmt" "fmt"
) )
@ -9,6 +10,9 @@ import (
// DatabaseFilePath is the path to the file ot be used as the global database for this run of the application. // DatabaseFilePath is the path to the file ot be used as the global database for this run of the application.
var DatabaseFilePath = "data/owncast.db" var DatabaseFilePath = "data/owncast.db"
// LogDirectory is the path to various log files
var LogDirectory = "."
// EnableDebugFeatures will print additional data to help in debugging. // EnableDebugFeatures will print additional data to help in debugging.
var EnableDebugFeatures = false var EnableDebugFeatures = false
@ -38,3 +42,7 @@ func GetReleaseString() string {
return fmt.Sprintf("Owncast v%s-%s (%s)", versionNumber, buildPlatform, gitCommit) return fmt.Sprintf("Owncast v%s-%s (%s)", versionNumber, buildPlatform, gitCommit)
} }
func GetTranscoderLogFilePath() string {
return filepath.Join(LogDirectory, "transcoder.log")
}

View File

@ -101,7 +101,7 @@ func (t *Transcoder) Start() {
err = _commandExec.Start() err = _commandExec.Start()
if err != nil { if err != nil {
log.Errorln("Transcoder error. See transcoder.log for full output to debug.") log.Errorln("Transcoder error. See ", config.GetTranscoderLogFilePath(), " for full output to debug.")
log.Panicln(err, command) log.Panicln(err, command)
} }
@ -119,7 +119,7 @@ func (t *Transcoder) Start() {
} }
if err != nil { if err != nil {
log.Errorln("transcoding error. look at transcoder.log to help debug. your copy of ffmpeg may not support your selected codec of", t.codec.Name(), "https://owncast.online/docs/troubleshooting/#codecs") log.Errorln("transcoding error. look at ", config.GetTranscoderLogFilePath(), " to help debug. your copy of ffmpeg may not support your selected codec of", t.codec.Name(), "https://owncast.online/docs/troubleshooting/#codecs")
} }
} }
@ -142,7 +142,7 @@ func (t *Transcoder) getString() string {
hlsOptionsString = "-hls_flags " + strings.Join(hlsOptionFlags, "+") hlsOptionsString = "-hls_flags " + strings.Join(hlsOptionFlags, "+")
} }
ffmpegFlags := []string{ ffmpegFlags := []string{
`FFREPORT=file="transcoder.log":level=32`, fmt.Sprintf(`FFREPORT=file="%s":level=32`, config.GetTranscoderLogFilePath()),
t.ffmpegPath, t.ffmpegPath,
"-hide_banner", "-hide_banner",
"-loglevel warning", "-loglevel warning",

View File

@ -37,6 +37,7 @@ func main() {
configFile := flag.String("configFile", "config.yaml", "Config file path to migrate to the new database") configFile := flag.String("configFile", "config.yaml", "Config file path to migrate to the new database")
dbFile := flag.String("database", "", "Path to the database file.") dbFile := flag.String("database", "", "Path to the database file.")
logDirectory := flag.String("logdir", "", "Directory where logs will be written to")
enableDebugOptions := flag.Bool("enableDebugFeatures", false, "Enable additional debugging options.") enableDebugOptions := flag.Bool("enableDebugFeatures", false, "Enable additional debugging options.")
enableVerboseLogging := flag.Bool("enableVerboseLogging", false, "Enable additional logging.") enableVerboseLogging := flag.Bool("enableVerboseLogging", false, "Enable additional logging.")
restoreDatabaseFile := flag.String("restoreDatabase", "", "Restore an Owncast database backup") restoreDatabaseFile := flag.String("restoreDatabase", "", "Restore an Owncast database backup")
@ -58,6 +59,10 @@ func main() {
} }
log.Infoln(config.GetReleaseString()) log.Infoln(config.GetReleaseString())
if *logDirectory != "" {
config.LogDirectory = *logDirectory
}
// Create the data directory if needed // Create the data directory if needed
if !utils.DoesFileExists("data") { if !utils.DoesFileExists("data") {
os.Mkdir("./data", 0700) os.Mkdir("./data", 0700)