mirror of
https://github.com/datarhei/core.git
synced 2025-09-26 20:11:29 +08:00
Use configured logging target
This commit is contained in:
@@ -70,6 +70,27 @@ func doMigration(logger log.Logger, configstore cfgstore.Store) error {
|
||||
return fmt.Errorf("the configuration contains errors: %v", messages)
|
||||
}
|
||||
|
||||
var writer log.Writer
|
||||
|
||||
if cfg.Log.Target.Output == "stdout" {
|
||||
writer = log.NewConsoleWriter(
|
||||
os.Stdout,
|
||||
true,
|
||||
)
|
||||
} else if cfg.Log.Target.Output == "file" {
|
||||
writer = log.NewFileWriter(
|
||||
cfg.Log.Target.Path,
|
||||
log.NewJSONFormatter(),
|
||||
)
|
||||
} else {
|
||||
writer = log.NewConsoleWriter(
|
||||
os.Stderr,
|
||||
true,
|
||||
)
|
||||
}
|
||||
|
||||
logger = logger.WithOutput(writer)
|
||||
|
||||
ff, err := ffmpeg.New(ffmpeg.Config{
|
||||
Binary: cfg.FFmpeg.Binary,
|
||||
})
|
||||
|
@@ -38,8 +38,6 @@ func doImport(logger log.Logger, configstore cfgstore.Store) error {
|
||||
logger = log.New("")
|
||||
}
|
||||
|
||||
logger.Info().Log("Database import")
|
||||
|
||||
cfg := configstore.Get()
|
||||
|
||||
// Merging the persisted config with the environment variables
|
||||
@@ -65,6 +63,27 @@ func doImport(logger log.Logger, configstore cfgstore.Store) error {
|
||||
return fmt.Errorf("the configuration contains errors: %v", messages)
|
||||
}
|
||||
|
||||
var writer log.Writer
|
||||
|
||||
if cfg.Log.Target.Output == "stdout" {
|
||||
writer = log.NewConsoleWriter(
|
||||
os.Stdout,
|
||||
true,
|
||||
)
|
||||
} else if cfg.Log.Target.Output == "file" {
|
||||
writer = log.NewFileWriter(
|
||||
cfg.Log.Target.Path,
|
||||
log.NewJSONFormatter(),
|
||||
)
|
||||
} else {
|
||||
writer = log.NewConsoleWriter(
|
||||
os.Stderr,
|
||||
true,
|
||||
)
|
||||
}
|
||||
|
||||
logger = logger.WithOutput(writer)
|
||||
|
||||
logger.Info().Log("Checking for database ...")
|
||||
|
||||
// Check if there's a v1.json from the old Restreamer
|
||||
|
Reference in New Issue
Block a user