diff --git a/README.md b/README.md index be0ffa02..b96d2bef 100644 --- a/README.md +++ b/README.md @@ -1084,6 +1084,13 @@ skipped or have nil values. Some of them, if not passed, are taken from the ;; :all is set. :log-level :err ;; to show only errors but not debug + ;; Sets driver's log level. + ;; The value is a string. Possible values are: + ;; chrome: [ALL, DEBUG, INFO, WARNING, SEVERE, OFF] + ;; phantomjs: [ERROR, WARN, INFO, DEBUG] (default INFO) + ;; firefox [fatal, error, warn, info, config, debug, trace] + :driver-log-level + ;; Paths to the driver's log files as strings. ;; When not set, the output goes to /dev/null (or NUL on Windows) :log-stdout diff --git a/src/etaoin/api.clj b/src/etaoin/api.clj index 598acb8c..2a383e36 100644 --- a/src/etaoin/api.clj +++ b/src/etaoin/api.clj @@ -2962,6 +2962,15 @@ browser's logs. Possible values are: `:off`, `:debug`, `:warn`, `:info`, `:error`, `:all`. When not passed, `:all` is set. + -- `:driver-log-level` a keyword to set driver's log level. + The value is a string. Possible values are: + chrome: [ALL, DEBUG, INFO, WARNING, SEVERE, OFF] + phantomjs: [ERROR, WARN, INFO, DEBUG] (default INFO) + firefox [fatal, error, warn, info, config, debug, trace] + + -- `:log-stdout` and `:log-stderr`. Paths to the driver's log files as strings. + When not set, the output goes to /dev/null (or NUL on Windows) + -- `:args-driver` is a vector of additional arguments to the driver's process. @@ -2977,7 +2986,8 @@ args-driver path-driver download-dir - path-browser]}]] + path-browser + driver-log-level]}]] (let [{:keys [type port]} @driver log-level (or log-level :all) @@ -2991,6 +3001,8 @@ (let [{:keys [perf]} dev] (swap! driver drv/set-perf-logging perf))) + _ (when driver-log-level + (swap! driver drv/set-driver-log-level driver-log-level)) _ (when args-driver (swap! driver drv/set-args args-driver)) _ (when path-browser diff --git a/src/etaoin/driver.clj b/src/etaoin/driver.clj index eda59ce7..a354752e 100644 --- a/src/etaoin/driver.clj +++ b/src/etaoin/driver.clj @@ -463,3 +463,27 @@ :enablePage page? :traceCategories (string/join "," (map name categories)) :bufferUsageReportingInterval interval}))))) + +(defmulti set-driver-log-level + dispatch-driver) + +(defmethod set-driver-log-level + :default + [driver _] + (log/debugf "For this driver, the log level setting is not implemented.") + driver) + +(defmethod set-driver-log-level + :chrome + [driver log-level] + (set-args driver [(format "--log-level=%s" log-level)])) + +(defmethod set-driver-log-level + :firefox + [driver log-level] + (set-args driver ["--log" log-level])) + +(defmethod set-driver-log-level + :phantom + [driver log-level] + (set-args driver [(format "--webdriver-loglevel=%s" log-level)]))