Save owncast logs to log file. Closes #908

This commit is contained in:
Gabe Kangas
2021-05-22 19:25:33 -07:00
parent bf6a3d9e85
commit 381daaec9b
8 changed files with 79 additions and 26 deletions

21
main.go
View File

@@ -8,7 +8,6 @@ import (
"github.com/markbates/pkger"
"github.com/owncast/owncast/logging"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
"github.com/owncast/owncast/config"
@@ -30,7 +29,6 @@ var (
)
func main() {
configureLogging()
// Enable bundling of admin assets
_ = pkger.Include("/admin")
@@ -57,12 +55,14 @@ func main() {
if BuildPlatform != "" {
config.BuildPlatform = BuildPlatform
}
log.Infoln(config.GetReleaseString())
if *logDirectory != "" {
config.LogDirectory = *logDirectory
}
configureLogging(*enableDebugOptions, *enableVerboseLogging)
log.Infoln(config.GetReleaseString())
// Create the data directory if needed
if !utils.DoesFileExists("data") {
os.Mkdir("./data", 0700)
@@ -83,16 +83,6 @@ func main() {
log.Exit(0)
}
if *enableDebugOptions {
logrus.SetReportCaller(true)
}
if *enableVerboseLogging {
log.SetLevel(log.TraceLevel)
} else {
log.SetLevel(log.InfoLevel)
}
config.EnableDebugFeatures = *enableDebugOptions
if *dbFile != "" {
@@ -144,11 +134,10 @@ func main() {
if err := router.Start(); err != nil {
log.Fatalln("failed to start/run the router", err)
}
}
func configureLogging() {
logging.Setup()
func configureLogging(enableDebugFeatures bool, enableVerboseLogging bool) {
logging.Setup(enableDebugFeatures, enableVerboseLogging)
log.SetFormatter(&log.TextFormatter{
FullTimestamp: true,
})