diff --git a/accounts/pkg/command/root.go b/accounts/pkg/command/root.go index 731cf37749b..17d17364c82 100644 --- a/accounts/pkg/command/root.go +++ b/accounts/pkg/command/root.go @@ -75,6 +75,7 @@ func NewLogger(cfg *config.Config) log.Logger { log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), log.Color(cfg.Log.Color), + log.File(cfg.Log.File), ) } @@ -133,6 +134,7 @@ func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Accounts.Supervised = true } + cfg.Accounts.Log.File = cfg.Log.File return SutureService{ cfg: cfg.Accounts, } diff --git a/accounts/pkg/config/config.go b/accounts/pkg/config/config.go index 530aefca79f..8863919429b 100644 --- a/accounts/pkg/config/config.go +++ b/accounts/pkg/config/config.go @@ -62,6 +62,7 @@ type Log struct { Level string Pretty bool Color bool + File string } // Repo defines which storage implementation is to be used. diff --git a/accounts/pkg/flagset/flagset.go b/accounts/pkg/flagset/flagset.go index a4a0aaf61f7..9542d75c32a 100644 --- a/accounts/pkg/flagset/flagset.go +++ b/accounts/pkg/flagset/flagset.go @@ -34,6 +34,12 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { // ServerWithConfig applies cfg to the root flagset func ServerWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ + &cli.StringFlag{ + Name: "log-file", + Usage: "Enable log to file", + EnvVars: []string{"ACCOUNTS_LOG_FILE", "OCIS_LOG_FILE"}, + Destination: &cfg.Log.File, + }, &cli.BoolFlag{ Name: "tracing-enabled", Usage: "Enable sending traces", diff --git a/changelog/unreleased/logging-to-file.md b/changelog/unreleased/logging-to-file.md new file mode 100644 index 00000000000..c7d4a38ece3 --- /dev/null +++ b/changelog/unreleased/logging-to-file.md @@ -0,0 +1,9 @@ +Enhancement: File Logging + +When running supervised, support for configuring all logs to a single log file: +`OCIS_LOG_FILE=/Users/foo/bar/ocis.log MICRO_REGISTRY=etcd bin/ocis server` + +Supports directing log from single extensions to a log file: +`PROXY_LOG_FILE=/Users/foo/bar/proxy.log MICRO_REGISTRY=etcd bin/ocis proxy` + +https://github.com/owncloud/ocis/pull/1816 diff --git a/glauth/pkg/command/root.go b/glauth/pkg/command/root.go index 7db6ee288b9..55404851daf 100644 --- a/glauth/pkg/command/root.go +++ b/glauth/pkg/command/root.go @@ -64,6 +64,7 @@ func NewLogger(cfg *config.Config) log.Logger { log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), log.Color(cfg.Log.Color), + log.File(cfg.Log.File), ) } @@ -122,6 +123,7 @@ func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.GLAuth.Supervised = true } + cfg.GLAuth.Log.File = cfg.Log.File return SutureService{ cfg: cfg.GLAuth, } diff --git a/glauth/pkg/config/config.go b/glauth/pkg/config/config.go index a83dc84d6b3..21c10190811 100644 --- a/glauth/pkg/config/config.go +++ b/glauth/pkg/config/config.go @@ -7,6 +7,7 @@ type Log struct { Level string Pretty bool Color bool + File string } // Debug defines the available debug configuration. diff --git a/glauth/pkg/flagset/flagset.go b/glauth/pkg/flagset/flagset.go index c596609cbe6..ad767a0e723 100644 --- a/glauth/pkg/flagset/flagset.go +++ b/glauth/pkg/flagset/flagset.go @@ -46,6 +46,12 @@ func HealthWithConfig(cfg *config.Config) []cli.Flag { // ServerWithConfig applies cfg to the root flagset func ServerWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ + &cli.StringFlag{ + Name: "log-file", + Usage: "Enable log to file", + EnvVars: []string{"GLAUTH_LOG_FILE", "OCIS_LOG_FILE"}, + Destination: &cfg.Log.File, + }, &cli.StringFlag{ Name: "config-file", Value: flags.OverrideDefaultString(cfg.File, ""), diff --git a/graph-explorer/pkg/command/root.go b/graph-explorer/pkg/command/root.go index 8252b158f70..d1140550712 100644 --- a/graph-explorer/pkg/command/root.go +++ b/graph-explorer/pkg/command/root.go @@ -64,6 +64,7 @@ func NewLogger(cfg *config.Config) log.Logger { log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), log.Color(cfg.Log.Color), + log.File(cfg.Log.File), ) } @@ -122,6 +123,7 @@ func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.GraphExplorer.Supervised = true } + cfg.GraphExplorer.Log.File = cfg.Log.File return SutureService{ cfg: cfg.GraphExplorer, } diff --git a/graph-explorer/pkg/config/config.go b/graph-explorer/pkg/config/config.go index 9a7c2288eef..8bb1cde8e72 100644 --- a/graph-explorer/pkg/config/config.go +++ b/graph-explorer/pkg/config/config.go @@ -7,6 +7,7 @@ type Log struct { Level string Pretty bool Color bool + File string } // Debug defines the available debug configuration. diff --git a/graph-explorer/pkg/flagset/flagset.go b/graph-explorer/pkg/flagset/flagset.go index 0fc5c27d8e3..baa5723f2e1 100644 --- a/graph-explorer/pkg/flagset/flagset.go +++ b/graph-explorer/pkg/flagset/flagset.go @@ -46,6 +46,12 @@ func HealthWithConfig(cfg *config.Config) []cli.Flag { // ServerWithConfig applies cfg to the root flagset func ServerWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ + &cli.StringFlag{ + Name: "log-file", + Usage: "Enable log to file", + EnvVars: []string{"GRAPH_EXPLORER_LOG_FILE", "OCIS_LOG_FILE"}, + Destination: &cfg.Log.File, + }, &cli.BoolFlag{ Name: "tracing-enabled", Usage: "Enable sending traces", diff --git a/graph/pkg/command/root.go b/graph/pkg/command/root.go index aae6a905561..ec758502c3b 100644 --- a/graph/pkg/command/root.go +++ b/graph/pkg/command/root.go @@ -65,6 +65,7 @@ func NewLogger(cfg *config.Config) log.Logger { log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), log.Color(cfg.Log.Color), + log.File(cfg.Log.File), ) } @@ -123,6 +124,7 @@ func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Graph.Supervised = true } + cfg.Graph.Log.File = cfg.Log.File return SutureService{ cfg: cfg.Graph, } diff --git a/graph/pkg/config/config.go b/graph/pkg/config/config.go index 580652a8994..433e9e72ff8 100644 --- a/graph/pkg/config/config.go +++ b/graph/pkg/config/config.go @@ -7,6 +7,7 @@ type Log struct { Level string Pretty bool Color bool + File string } // Debug defines the available debug configuration. diff --git a/graph/pkg/flagset/flagset.go b/graph/pkg/flagset/flagset.go index bd9efe93ce7..c4734797a21 100644 --- a/graph/pkg/flagset/flagset.go +++ b/graph/pkg/flagset/flagset.go @@ -53,6 +53,12 @@ func HealthWithConfig(cfg *config.Config) []cli.Flag { // ServerWithConfig applies cfg to the root flagset func ServerWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ + &cli.StringFlag{ + Name: "log-file", + Usage: "Enable log to file", + EnvVars: []string{"GRAPH_LOG_FILE", "OCIS_LOG_FILE"}, + Destination: &cfg.Log.File, + }, &cli.BoolFlag{ Name: "tracing-enabled", Usage: "Enable sending traces", diff --git a/idp/pkg/command/root.go b/idp/pkg/command/root.go index 3f8c37535d3..140d036111f 100644 --- a/idp/pkg/command/root.go +++ b/idp/pkg/command/root.go @@ -65,6 +65,7 @@ func NewLogger(cfg *config.Config) log.Logger { log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), log.Color(cfg.Log.Color), + log.File(cfg.Log.File), ) } @@ -123,6 +124,7 @@ func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.IDP.Supervised = true } + cfg.IDP.Log.File = cfg.Log.File return SutureService{ cfg: cfg.IDP, } diff --git a/idp/pkg/config/config.go b/idp/pkg/config/config.go index 44f51c4151d..2fcd3553e2f 100644 --- a/idp/pkg/config/config.go +++ b/idp/pkg/config/config.go @@ -11,6 +11,7 @@ type Log struct { Level string Pretty bool Color bool + File string } // Debug defines the available debug configuration. diff --git a/idp/pkg/flagset/flagset.go b/idp/pkg/flagset/flagset.go index bf37ba0f7fb..aea12c4fe6e 100644 --- a/idp/pkg/flagset/flagset.go +++ b/idp/pkg/flagset/flagset.go @@ -46,6 +46,12 @@ func HealthWithConfig(cfg *config.Config) []cli.Flag { // ServerWithConfig applies cfg to the root flagset func ServerWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ + &cli.StringFlag{ + Name: "log-file", + Usage: "Enable log to file", + EnvVars: []string{"IDP_LOG_FILE", "OCIS_LOG_FILE"}, + Destination: &cfg.Log.File, + }, &cli.StringFlag{ Name: "config-file", Value: flags.OverrideDefaultString(cfg.File, ""), diff --git a/ocis-pkg/config/config.go b/ocis-pkg/config/config.go index e015f957a14..2e484880d62 100644 --- a/ocis-pkg/config/config.go +++ b/ocis-pkg/config/config.go @@ -22,6 +22,7 @@ type Log struct { Level string Pretty bool Color bool + File string } // Debug defines the available debug configuration. diff --git a/ocis-pkg/log/log.go b/ocis-pkg/log/log.go index 522023b6c07..8b95d0fe490 100644 --- a/ocis-pkg/log/log.go +++ b/ocis-pkg/log/log.go @@ -61,6 +61,13 @@ func NewLogger(opts ...Option) Logger { }, ), ) + } else if options.File != "" { + f, err := os.OpenFile(options.File, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0644) + if err != nil { + print(fmt.Sprintf("file could not be opened for writing: %s. error: %v", options.File, err)) + os.Exit(1) + } + logger = logger.Output(f) } else { logger = zerolog.New(os.Stderr) } diff --git a/ocis-pkg/log/option.go b/ocis-pkg/log/option.go index 023e0da1229..756ad16dab8 100644 --- a/ocis-pkg/log/option.go +++ b/ocis-pkg/log/option.go @@ -9,6 +9,7 @@ type Options struct { Level string Pretty bool Color bool + File string } // newOptions initializes the available default options. @@ -54,3 +55,10 @@ func Color(val bool) Option { o.Color = val } } + +// File provides a function to set the color option. +func File(val string) Option { + return func(o *Options) { + o.File = val + } +} diff --git a/ocis/pkg/command/root.go b/ocis/pkg/command/root.go index bda4b1b00f8..4a931d79d52 100644 --- a/ocis/pkg/command/root.go +++ b/ocis/pkg/command/root.go @@ -66,6 +66,7 @@ func NewLogger(cfg *config.Config) log.Logger { log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), log.Color(cfg.Log.Color), + log.File(cfg.Log.File), ) } diff --git a/ocis/pkg/flagset/flagset.go b/ocis/pkg/flagset/flagset.go index 4d8da2033f8..fb43c6cab67 100644 --- a/ocis/pkg/flagset/flagset.go +++ b/ocis/pkg/flagset/flagset.go @@ -35,6 +35,12 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"OCIS_LOG_COLOR"}, Destination: &cfg.Log.Color, }, + &cli.StringFlag{ + Name: "ocis-log-file", + Usage: "Enable log to file", + EnvVars: []string{"OCIS_LOG_FILE"}, + Destination: &cfg.Log.File, + }, &cli.BoolFlag{ Name: "tracing-enabled", Usage: "Enable sending traces", diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index 93e8417e117..7eeb49f836b 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -19,8 +19,8 @@ import ( "github.com/olekukonko/tablewriter" accounts "github.com/owncloud/ocis/accounts/pkg/command" glauth "github.com/owncloud/ocis/glauth/pkg/command" - graph "github.com/owncloud/ocis/graph/pkg/command" graphExplorer "github.com/owncloud/ocis/graph-explorer/pkg/command" + graph "github.com/owncloud/ocis/graph/pkg/command" idp "github.com/owncloud/ocis/idp/pkg/command" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/log" @@ -133,6 +133,7 @@ func Start(o ...Option) error { s.cfg.Storage.Log.Color = s.cfg.Log.Color s.cfg.Storage.Log.Level = s.cfg.Log.Level s.cfg.Storage.Log.Pretty = s.cfg.Log.Pretty + s.cfg.Storage.Log.File = s.cfg.Log.File // notify goroutines that they are running on supervised mode s.cfg.Mode = ociscfg.SUPERVISED diff --git a/ocis/pkg/tracing/tracing.go b/ocis/pkg/tracing/tracing.go index 29e8f7b3c00..068e253929a 100644 --- a/ocis/pkg/tracing/tracing.go +++ b/ocis/pkg/tracing/tracing.go @@ -114,5 +114,6 @@ func NewLogger(cfg *config.Config) log.Logger { log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), log.Color(cfg.Log.Color), + log.File(cfg.Log.File), ) } diff --git a/ocs/pkg/command/root.go b/ocs/pkg/command/root.go index 2bd1945b5bc..ceb2db3b03d 100644 --- a/ocs/pkg/command/root.go +++ b/ocs/pkg/command/root.go @@ -63,6 +63,7 @@ func NewLogger(cfg *config.Config) log.Logger { log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), log.Color(cfg.Log.Color), + log.File(cfg.Log.File), ) } @@ -121,6 +122,7 @@ func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.OCS.Supervised = true } + cfg.OCS.Log.File = cfg.Log.File return SutureService{ cfg: cfg.OCS, } diff --git a/ocs/pkg/config/config.go b/ocs/pkg/config/config.go index 6a4af5d4b35..6a01ad55d65 100644 --- a/ocs/pkg/config/config.go +++ b/ocs/pkg/config/config.go @@ -7,6 +7,7 @@ type Log struct { Level string Pretty bool Color bool + File string } // Debug defines the available debug configuration. diff --git a/ocs/pkg/flagset/flagset.go b/ocs/pkg/flagset/flagset.go index a8b1fc7c49d..7e428536dba 100644 --- a/ocs/pkg/flagset/flagset.go +++ b/ocs/pkg/flagset/flagset.go @@ -22,6 +22,12 @@ func HealthWithConfig(cfg *config.Config) []cli.Flag { // ServerWithConfig applies cfg to the root flagset func ServerWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ + &cli.StringFlag{ + Name: "log-file", + Usage: "Enable log to file", + EnvVars: []string{"OCS_LOG_FILE", "OCIS_LOG_FILE"}, + Destination: &cfg.Log.File, + }, &cli.StringFlag{ Name: "log-level", Usage: "Set logging level", diff --git a/onlyoffice/pkg/command/root.go b/onlyoffice/pkg/command/root.go index 2ab484ccb27..f541c3ca352 100644 --- a/onlyoffice/pkg/command/root.go +++ b/onlyoffice/pkg/command/root.go @@ -64,6 +64,7 @@ func NewLogger(cfg *config.Config) log.Logger { log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), log.Color(cfg.Log.Color), + log.File(cfg.Log.File), ) } @@ -122,6 +123,7 @@ func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Onlyoffice.Supervised = true } + cfg.Onlyoffice.Log.File = cfg.Log.File return SutureService{ cfg: cfg.Onlyoffice, } diff --git a/onlyoffice/pkg/config/config.go b/onlyoffice/pkg/config/config.go index bbc6bc6b69c..4b8d548227f 100644 --- a/onlyoffice/pkg/config/config.go +++ b/onlyoffice/pkg/config/config.go @@ -7,6 +7,7 @@ type Log struct { Level string Pretty bool Color bool + File string } // Debug defines the available debug configuration. diff --git a/onlyoffice/pkg/flagset/flagset.go b/onlyoffice/pkg/flagset/flagset.go index d908dd1b0c4..d8a59bd5aeb 100644 --- a/onlyoffice/pkg/flagset/flagset.go +++ b/onlyoffice/pkg/flagset/flagset.go @@ -53,6 +53,12 @@ func HealthWithConfig(cfg *config.Config) []cli.Flag { // ServerWithConfig applies cfg to the root flagset func ServerWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ + &cli.StringFlag{ + Name: "log-file", + Usage: "Enable log to file", + EnvVars: []string{"ONLYOFFICE_LOG_FILE", "OCIS_LOG_FILE"}, + Destination: &cfg.Log.File, + }, &cli.BoolFlag{ Name: "tracing-enabled", Usage: "Enable sending traces", diff --git a/proxy/pkg/command/root.go b/proxy/pkg/command/root.go index ef72673d01c..7f7f5fdd5f1 100644 --- a/proxy/pkg/command/root.go +++ b/proxy/pkg/command/root.go @@ -66,6 +66,7 @@ func NewLogger(cfg *config.Config) log.Logger { log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), log.Color(cfg.Log.Color), + log.File(cfg.Log.File), ) } @@ -124,6 +125,7 @@ func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Proxy.Supervised = true } + cfg.Proxy.Log.File = cfg.Log.File return SutureService{ cfg: cfg.Proxy, } diff --git a/proxy/pkg/config/config.go b/proxy/pkg/config/config.go index e749d5c9702..424bcce3035 100644 --- a/proxy/pkg/config/config.go +++ b/proxy/pkg/config/config.go @@ -7,6 +7,7 @@ type Log struct { Level string Pretty bool Color bool + File string } // Debug defines the available debug configuration. diff --git a/proxy/pkg/flagset/flagset.go b/proxy/pkg/flagset/flagset.go index 8dcb3028ad1..292676ec837 100644 --- a/proxy/pkg/flagset/flagset.go +++ b/proxy/pkg/flagset/flagset.go @@ -46,6 +46,12 @@ func HealthWithConfig(cfg *config.Config) []cli.Flag { // ServerWithConfig applies cfg to the root flagset func ServerWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ + &cli.StringFlag{ + Name: "log-file", + Usage: "Enable log to file", + EnvVars: []string{"PROXY_LOG_FILE", "OCIS_LOG_FILE"}, + Destination: &cfg.Log.File, + }, &cli.StringFlag{ Name: "config-file", Value: "", diff --git a/settings/pkg/command/root.go b/settings/pkg/command/root.go index 58e71cf78ea..e369d832e76 100644 --- a/settings/pkg/command/root.go +++ b/settings/pkg/command/root.go @@ -66,6 +66,7 @@ func NewLogger(cfg *config.Config) log.Logger { log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), log.Color(cfg.Log.Color), + log.File(cfg.Log.File), ) } @@ -124,6 +125,7 @@ func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Settings.Supervised = true } + cfg.Settings.Log.File = cfg.Log.File return SutureService{ cfg: cfg.Settings, } diff --git a/settings/pkg/config/config.go b/settings/pkg/config/config.go index d699b2d232c..f137a9ac471 100644 --- a/settings/pkg/config/config.go +++ b/settings/pkg/config/config.go @@ -7,6 +7,7 @@ type Log struct { Level string Pretty bool Color bool + File string } // Debug defines the available debug configuration. diff --git a/settings/pkg/store/filesystem/store.go b/settings/pkg/store/filesystem/store.go index cf2046b0582..8eb3f034161 100644 --- a/settings/pkg/store/filesystem/store.go +++ b/settings/pkg/store/filesystem/store.go @@ -28,6 +28,7 @@ func New(cfg *config.Config) settings.Manager { olog.Color(cfg.Log.Color), olog.Pretty(cfg.Log.Pretty), olog.Level(cfg.Log.Level), + olog.File(cfg.Log.File), ), } diff --git a/storage/pkg/command/root.go b/storage/pkg/command/root.go index 45df059032b..eb20e0f8df6 100644 --- a/storage/pkg/command/root.go +++ b/storage/pkg/command/root.go @@ -107,5 +107,6 @@ func NewLogger(cfg *config.Config) log.Logger { log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), log.Color(cfg.Log.Color), + log.File(cfg.Log.File), ) } diff --git a/storage/pkg/config/config.go b/storage/pkg/config/config.go index 489b005be70..11b395e9214 100644 --- a/storage/pkg/config/config.go +++ b/storage/pkg/config/config.go @@ -7,6 +7,7 @@ type Log struct { Level string Pretty bool Color bool + File string } // Debug defines the available debug configuration. diff --git a/store/pkg/command/root.go b/store/pkg/command/root.go index 63a20b4c8fb..17fc954c08b 100644 --- a/store/pkg/command/root.go +++ b/store/pkg/command/root.go @@ -66,6 +66,7 @@ func NewLogger(cfg *config.Config) log.Logger { log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), log.Color(cfg.Log.Color), + log.File(cfg.Log.File), ) } @@ -124,6 +125,7 @@ func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Store.Supervised = true } + cfg.Store.Log.File = cfg.Log.File return SutureService{ cfg: cfg.Store, } diff --git a/store/pkg/config/config.go b/store/pkg/config/config.go index 3774c6c10bc..ce9c852521e 100644 --- a/store/pkg/config/config.go +++ b/store/pkg/config/config.go @@ -7,6 +7,7 @@ type Log struct { Level string Pretty bool Color bool + File string } // Debug defines the available debug configuration. diff --git a/store/pkg/flagset/flagset.go b/store/pkg/flagset/flagset.go index 09f83121b40..f87f08efc04 100644 --- a/store/pkg/flagset/flagset.go +++ b/store/pkg/flagset/flagset.go @@ -53,6 +53,12 @@ func HealthWithConfig(cfg *config.Config) []cli.Flag { // ServerWithConfig applies cfg to the root flagset func ServerWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ + &cli.StringFlag{ + Name: "log-file", + Usage: "Enable log to file", + EnvVars: []string{"STORE_LOG_FILE", "OCIS_LOG_FILE"}, + Destination: &cfg.Log.File, + }, &cli.BoolFlag{ Name: "tracing-enabled", Usage: "Enable sending traces", diff --git a/thumbnails/pkg/command/root.go b/thumbnails/pkg/command/root.go index ec006eb5f8d..b1e04ec788c 100644 --- a/thumbnails/pkg/command/root.go +++ b/thumbnails/pkg/command/root.go @@ -63,6 +63,7 @@ func NewLogger(cfg *config.Config) log.Logger { log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), log.Color(cfg.Log.Color), + log.File(cfg.Log.File), ) } @@ -121,6 +122,7 @@ func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Thumbnails.Supervised = true } + cfg.Thumbnails.Log.File = cfg.Log.File return SutureService{ cfg: cfg.Thumbnails, } diff --git a/thumbnails/pkg/config/config.go b/thumbnails/pkg/config/config.go index 9d913633d35..d742f9bfee0 100644 --- a/thumbnails/pkg/config/config.go +++ b/thumbnails/pkg/config/config.go @@ -7,6 +7,7 @@ type Log struct { Level string Pretty bool Color bool + File string } // Debug defines the available debug configuration. diff --git a/thumbnails/pkg/flagset/flagset.go b/thumbnails/pkg/flagset/flagset.go index 85d8b7df1b7..a7d7152f420 100644 --- a/thumbnails/pkg/flagset/flagset.go +++ b/thumbnails/pkg/flagset/flagset.go @@ -26,6 +26,12 @@ func HealthWithConfig(cfg *config.Config) []cli.Flag { // ServerWithConfig applies cfg to the root flagset func ServerWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ + &cli.StringFlag{ + Name: "log-file", + Usage: "Enable log to file", + EnvVars: []string{"THUMBNAILS_LOG_FILE", "OCIS_LOG_FILE"}, + Destination: &cfg.Log.File, + }, &cli.StringFlag{ Name: "log-level", Usage: "Set logging level", diff --git a/web/pkg/command/root.go b/web/pkg/command/root.go index 863ee56d450..74348e62d7b 100644 --- a/web/pkg/command/root.go +++ b/web/pkg/command/root.go @@ -55,6 +55,7 @@ func NewLogger(cfg *config.Config) log.Logger { log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), log.Color(cfg.Log.Color), + log.File(cfg.Log.File), ) } @@ -113,6 +114,7 @@ func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Web.Supervised = true } + cfg.Web.Log.File = cfg.Log.File return SutureService{ cfg: cfg.Web, } diff --git a/web/pkg/config/config.go b/web/pkg/config/config.go index 179a8b8ed25..4ea408ec2f8 100644 --- a/web/pkg/config/config.go +++ b/web/pkg/config/config.go @@ -7,6 +7,7 @@ type Log struct { Level string Pretty bool Color bool + File string } // Debug defines the available debug configuration. diff --git a/web/pkg/flagset/flagset.go b/web/pkg/flagset/flagset.go index 982377bf5fe..717663f9862 100644 --- a/web/pkg/flagset/flagset.go +++ b/web/pkg/flagset/flagset.go @@ -46,6 +46,12 @@ func HealthWithConfig(cfg *config.Config) []cli.Flag { // ServerWithConfig applies cfg to the root flagset func ServerWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ + &cli.StringFlag{ + Name: "log-file", + Usage: "Enable log to file", + EnvVars: []string{"WEB_LOG_FILE", "OCIS_LOG_FILE"}, + Destination: &cfg.Log.File, + }, &cli.StringFlag{ Name: "config-file", Value: "", diff --git a/webdav/pkg/command/root.go b/webdav/pkg/command/root.go index ac52eafda30..bbceaba92b5 100644 --- a/webdav/pkg/command/root.go +++ b/webdav/pkg/command/root.go @@ -61,6 +61,7 @@ func NewLogger(cfg *config.Config) log.Logger { log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), log.Color(cfg.Log.Color), + log.File(cfg.Log.File), ) } @@ -119,6 +120,7 @@ func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.WebDAV.Supervised = true } + cfg.WebDAV.Log.File = cfg.Log.File return SutureService{ cfg: cfg.WebDAV, } diff --git a/webdav/pkg/config/config.go b/webdav/pkg/config/config.go index f14a96b0852..0b0e3646248 100644 --- a/webdav/pkg/config/config.go +++ b/webdav/pkg/config/config.go @@ -7,6 +7,7 @@ type Log struct { Level string Pretty bool Color bool + File string } // Debug defines the available debug configuration. diff --git a/webdav/pkg/flagset/flagset.go b/webdav/pkg/flagset/flagset.go index c0b4847e633..fae18f1468e 100644 --- a/webdav/pkg/flagset/flagset.go +++ b/webdav/pkg/flagset/flagset.go @@ -22,6 +22,12 @@ func HealthWithConfig(cfg *config.Config) []cli.Flag { // ServerWithConfig applies cfg to the root flagset func ServerWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ + &cli.StringFlag{ + Name: "log-file", + Usage: "Enable log to file", + EnvVars: []string{"WEBDAV_LOG_FILE", "OCIS_LOG_FILE"}, + Destination: &cfg.Log.File, + }, &cli.StringFlag{ Name: "log-level", Usage: "Set logging level",