log: fix enabling systemd logging when using --log-file
This also moves all the systemd logging decisions to fs/log
This commit is contained in:
parent
5ae5e1dd56
commit
c98dd8755c
6 changed files with 61 additions and 53 deletions
12
cmd/cmd.go
12
cmd/cmd.go
|
@ -21,7 +21,6 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
systemd "github.com/iguanesolutions/go-systemd/v5"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/rclone/rclone/fs/accounting"
|
||||
|
@ -376,11 +375,6 @@ func StartStats() func() {
|
|||
func initConfig() {
|
||||
ctx := context.Background()
|
||||
ci := fs.GetConfig(ctx)
|
||||
// Activate logger systemd support if systemd invocation ID is detected
|
||||
_, sysdLaunch := systemd.GetInvocationID()
|
||||
if sysdLaunch {
|
||||
ci.LogSystemdSupport = true // used during fslog.InitLogging()
|
||||
}
|
||||
|
||||
// Start the logger
|
||||
fslog.InitLogging()
|
||||
|
@ -398,10 +392,8 @@ func initConfig() {
|
|||
fs.Debugf("rclone", "Version %q starting with parameters %q", fs.Version, os.Args)
|
||||
|
||||
// Inform user about systemd log support now that we have a logger
|
||||
if sysdLaunch {
|
||||
fs.Debugf("rclone", "systemd logging support automatically activated")
|
||||
} else if ci.LogSystemdSupport {
|
||||
fs.Debugf("rclone", "systemd logging support manually activated")
|
||||
if fslog.Opt.LogSystemdSupport {
|
||||
fs.Debugf("rclone", "systemd logging support activated")
|
||||
}
|
||||
|
||||
// Start the remote control server if configured
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue