Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Added flag to turn off logging (fixes #197)
Browse files Browse the repository at this point in the history
  • Loading branch information
vania-pooh committed Oct 30, 2018
1 parent 93a0f60 commit 3b58a89
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 21 deletions.
21 changes: 12 additions & 9 deletions cmd/selenoid.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var (
port uint16
uiPort uint16
userNS string
disableLogs bool
)

func init() {
Expand Down Expand Up @@ -157,20 +158,22 @@ func initFlags() {
c.Flags().StringVarP(&args, "args", "g", "", "additional service arguments (e.g. \"-limit 5\")")
c.Flags().StringVarP(&env, "env", "e", "", "override service environment variables (e.g. \"KEY1=value1 KEY2=value2\")")
c.Flags().StringVarP(&userNS, "userns", "", "", "override user namespace, similarly to \"docker run --userns host ...\" (Docker only)")
c.Flags().BoolVarP(&disableLogs, "disable-logs", "", false, "start with log saving feature disabled")
}
}

func createLifecycle(configDir string, port uint16) (*selenoid.Lifecycle, error) {
config := selenoid.LifecycleConfig{
Quiet: quiet,
Force: force,
ConfigDir: configDir,
Browsers: browsers,
BrowserEnv: browserEnv,
Download: !skipDownload,
Args: args,
Env: env,
Port: int(port),
Quiet: quiet,
Force: force,
ConfigDir: configDir,
Browsers: browsers,
BrowserEnv: browserEnv,
Download: !skipDownload,
Args: args,
Env: env,
Port: int(port),
DisableLogs: disableLogs,

LastVersions: lastVersions,
RegistryUrl: registry,
Expand Down
4 changes: 4 additions & 0 deletions selenoid/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ type UserNSAware struct {
UserNS string
}

type LogsAware struct {
DisableLogs bool
}

const (
SelenoidDefaultPort = 4444
SelenoidUIDefaultPort = 8080
Expand Down
4 changes: 3 additions & 1 deletion selenoid/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type DockerConfigurator struct {
BrowserEnvAware
PortAware
UserNSAware
LogsAware
LastVersions int
Pull bool
RegistryUrl string
Expand All @@ -96,6 +97,7 @@ func NewDockerConfigurator(config *LifecycleConfig) (*DockerConfigurator, error)
BrowserEnvAware: BrowserEnvAware{BrowserEnv: config.BrowserEnv},
PortAware: PortAware{Port: config.Port},
UserNSAware: UserNSAware{UserNS: config.UserNS},
LogsAware: LogsAware{DisableLogs: config.DisableLogs},
RegistryUrl: config.RegistryUrl,
LastVersions: config.LastVersions,
Tmpfs: config.Tmpfs,
Expand Down Expand Up @@ -666,7 +668,7 @@ func (c *DockerConfigurator) Start() error {
cmd = append(cmd, "-video-output-dir", "/opt/selenoid/video/", "-video-recorder-image", videoRecorderImage)
}

if !contains(cmd, "-log-output-dir") && isLogSavingSupported(c.Logger, c.Version) {
if !c.DisableLogs && !contains(cmd, "-log-output-dir") && isLogSavingSupported(c.Logger, c.Version) {
cmd = append(cmd, "-log-output-dir", "/opt/selenoid/logs/")
}

Expand Down
4 changes: 3 additions & 1 deletion selenoid/drivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type DriversConfigurator struct {
BrowserEnvAware
PortAware
RequestedBrowsersAware
LogsAware
Browsers string
BrowsersJsonUrl string

Expand All @@ -85,6 +86,7 @@ func NewDriversConfigurator(config *LifecycleConfig) *DriversConfigurator {
PortAware: PortAware{Port: config.Port},
DownloadAware: DownloadAware{DownloadNeeded: config.Download},
RequestedBrowsersAware: RequestedBrowsersAware{Browsers: config.Browsers},
LogsAware: LogsAware{DisableLogs: config.DisableLogs},
BrowsersJsonUrl: config.BrowsersJsonUrl,
Browsers: config.Browsers,
GithubBaseUrl: config.GithubBaseUrl,
Expand Down Expand Up @@ -584,7 +586,7 @@ func (d *DriversConfigurator) Start() error {
if !contains(args, "-disable-docker") {
args = append(args, "-disable-docker")
}
if !contains(args, "-log-output-dir") && isLogSavingSupported(d.Logger, d.Version) {
if !d.DisableLogs && !contains(args, "-log-output-dir") && isLogSavingSupported(d.Logger, d.Version) {
logsConfigDir := getVolumeConfigDir(filepath.Join(d.ConfigDir, logsDirName), append(selenoidConfigDirElem, logsDirName))
args = append(args, "-log-output-dir", logsConfigDir)
}
Expand Down
21 changes: 11 additions & 10 deletions selenoid/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ import (
)

type LifecycleConfig struct {
Quiet bool
Force bool
ConfigDir string
Browsers string
BrowserEnv string
Download bool
Args string
Env string
Version string
Port int
Quiet bool
Force bool
ConfigDir string
Browsers string
BrowserEnv string
Download bool
Args string
Env string
Version string
Port int
DisableLogs bool

// Docker specific
LastVersions int
Expand Down

0 comments on commit 3b58a89

Please sign in to comment.