UrgentcareCLI 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/Gemfile.lock +60 -25
- data/Notes +1 -1
- data/README.md +5 -5
- data/Rakefile +2 -0
- data/UrgentCare.gemspec +3 -3
- data/background.jpg +0 -0
- data/lib/UrgentCare.rb +3 -0
- data/lib/UrgentCare/CLI.rb +6 -2
- data/lib/UrgentCare/version.rb +1 -1
- data/lib/Urgentcare/Scraper.rb +65 -23
- data/node_modules/.bin/rimraf +1 -0
- data/node_modules/.package-lock.json +250 -0
- data/node_modules/balanced-match/.github/FUNDING.yml +2 -0
- data/node_modules/balanced-match/LICENSE.md +21 -0
- data/node_modules/balanced-match/README.md +97 -0
- data/node_modules/balanced-match/index.js +62 -0
- data/node_modules/balanced-match/package.json +48 -0
- data/node_modules/brace-expansion/LICENSE +21 -0
- data/node_modules/brace-expansion/README.md +129 -0
- data/node_modules/brace-expansion/index.js +201 -0
- data/node_modules/brace-expansion/package.json +47 -0
- data/node_modules/concat-map/.travis.yml +4 -0
- data/node_modules/concat-map/LICENSE +18 -0
- data/node_modules/concat-map/README.markdown +62 -0
- data/node_modules/concat-map/example/map.js +6 -0
- data/node_modules/concat-map/index.js +13 -0
- data/node_modules/concat-map/package.json +43 -0
- data/node_modules/concat-map/test/map.js +39 -0
- data/node_modules/core-util-is/LICENSE +19 -0
- data/node_modules/core-util-is/README.md +3 -0
- data/node_modules/core-util-is/float.patch +604 -0
- data/node_modules/core-util-is/lib/util.js +107 -0
- data/node_modules/core-util-is/package.json +32 -0
- data/node_modules/core-util-is/test.js +68 -0
- data/node_modules/fs.realpath/LICENSE +43 -0
- data/node_modules/fs.realpath/README.md +33 -0
- data/node_modules/fs.realpath/index.js +66 -0
- data/node_modules/fs.realpath/old.js +303 -0
- data/node_modules/fs.realpath/package.json +26 -0
- data/node_modules/glob/LICENSE +21 -0
- data/node_modules/glob/README.md +375 -0
- data/node_modules/glob/changelog.md +67 -0
- data/node_modules/glob/common.js +234 -0
- data/node_modules/glob/glob.js +788 -0
- data/node_modules/glob/package.json +51 -0
- data/node_modules/glob/sync.js +484 -0
- data/node_modules/immediate/LICENSE.txt +20 -0
- data/node_modules/immediate/README.md +93 -0
- data/node_modules/immediate/dist/immediate.js +75 -0
- data/node_modules/immediate/dist/immediate.min.js +1 -0
- data/node_modules/immediate/lib/browser.js +69 -0
- data/node_modules/immediate/lib/index.js +73 -0
- data/node_modules/immediate/package.json +42 -0
- data/node_modules/inflight/LICENSE +15 -0
- data/node_modules/inflight/README.md +37 -0
- data/node_modules/inflight/inflight.js +54 -0
- data/node_modules/inflight/package.json +29 -0
- data/node_modules/inherits/LICENSE +16 -0
- data/node_modules/inherits/README.md +42 -0
- data/node_modules/inherits/inherits.js +9 -0
- data/node_modules/inherits/inherits_browser.js +27 -0
- data/node_modules/inherits/package.json +29 -0
- data/node_modules/isarray/.npmignore +1 -0
- data/node_modules/isarray/.travis.yml +4 -0
- data/node_modules/isarray/Makefile +6 -0
- data/node_modules/isarray/README.md +60 -0
- data/node_modules/isarray/component.json +19 -0
- data/node_modules/isarray/index.js +5 -0
- data/node_modules/isarray/package.json +45 -0
- data/node_modules/isarray/test.js +20 -0
- data/node_modules/jszip/.codeclimate.yml +16 -0
- data/node_modules/jszip/.editorconfig +8 -0
- data/node_modules/jszip/.jshintignore +1 -0
- data/node_modules/jszip/.jshintrc +21 -0
- data/node_modules/jszip/.travis.yml +17 -0
- data/node_modules/jszip/CHANGES.md +163 -0
- data/node_modules/jszip/LICENSE.markdown +651 -0
- data/node_modules/jszip/README.markdown +35 -0
- data/node_modules/jszip/dist/jszip.js +30 -0
- data/node_modules/jszip/dist/jszip.min.js +13 -0
- data/node_modules/jszip/index.d.ts +270 -0
- data/node_modules/jszip/lib/base64.js +106 -0
- data/node_modules/jszip/lib/compressedObject.js +74 -0
- data/node_modules/jszip/lib/compressions.js +14 -0
- data/node_modules/jszip/lib/crc32.js +77 -0
- data/node_modules/jszip/lib/defaults.js +11 -0
- data/node_modules/jszip/lib/external.js +19 -0
- data/node_modules/jszip/lib/flate.js +85 -0
- data/node_modules/jszip/lib/generate/ZipFileWorker.js +540 -0
- data/node_modules/jszip/lib/generate/index.js +57 -0
- data/node_modules/jszip/lib/index.js +52 -0
- data/node_modules/jszip/lib/license_header.js +11 -0
- data/node_modules/jszip/lib/load.js +81 -0
- data/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +74 -0
- data/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +42 -0
- data/node_modules/jszip/lib/nodejsUtils.js +57 -0
- data/node_modules/jszip/lib/object.js +389 -0
- data/node_modules/jszip/lib/readable-stream-browser.js +9 -0
- data/node_modules/jszip/lib/reader/ArrayReader.js +57 -0
- data/node_modules/jszip/lib/reader/DataReader.js +116 -0
- data/node_modules/jszip/lib/reader/NodeBufferReader.js +19 -0
- data/node_modules/jszip/lib/reader/StringReader.js +38 -0
- data/node_modules/jszip/lib/reader/Uint8ArrayReader.js +22 -0
- data/node_modules/jszip/lib/reader/readerFor.js +28 -0
- data/node_modules/jszip/lib/signature.js +7 -0
- data/node_modules/jszip/lib/stream/ConvertWorker.js +26 -0
- data/node_modules/jszip/lib/stream/Crc32Probe.js +24 -0
- data/node_modules/jszip/lib/stream/DataLengthProbe.js +29 -0
- data/node_modules/jszip/lib/stream/DataWorker.js +116 -0
- data/node_modules/jszip/lib/stream/GenericWorker.js +263 -0
- data/node_modules/jszip/lib/stream/StreamHelper.js +212 -0
- data/node_modules/jszip/lib/support.js +38 -0
- data/node_modules/jszip/lib/utf8.js +275 -0
- data/node_modules/jszip/lib/utils.js +476 -0
- data/node_modules/jszip/lib/zipEntries.js +262 -0
- data/node_modules/jszip/lib/zipEntry.js +294 -0
- data/node_modules/jszip/lib/zipObject.js +133 -0
- data/node_modules/jszip/package.json +63 -0
- data/node_modules/jszip/vendor/FileSaver.js +247 -0
- data/node_modules/lie/README.md +62 -0
- data/node_modules/lie/dist/lie.js +350 -0
- data/node_modules/lie/dist/lie.min.js +1 -0
- data/node_modules/lie/dist/lie.polyfill.js +358 -0
- data/node_modules/lie/dist/lie.polyfill.min.js +1 -0
- data/node_modules/lie/lib/browser.js +273 -0
- data/node_modules/lie/lib/index.js +298 -0
- data/node_modules/lie/license.md +7 -0
- data/node_modules/lie/lie.d.ts +244 -0
- data/node_modules/lie/package.json +69 -0
- data/node_modules/lie/polyfill.js +4 -0
- data/node_modules/minimatch/LICENSE +15 -0
- data/node_modules/minimatch/README.md +209 -0
- data/node_modules/minimatch/minimatch.js +923 -0
- data/node_modules/minimatch/package.json +30 -0
- data/node_modules/once/LICENSE +15 -0
- data/node_modules/once/README.md +79 -0
- data/node_modules/once/once.js +42 -0
- data/node_modules/once/package.json +33 -0
- data/node_modules/pako/CHANGELOG.md +164 -0
- data/node_modules/pako/LICENSE +21 -0
- data/node_modules/pako/README.md +191 -0
- data/node_modules/pako/dist/pako.js +6818 -0
- data/node_modules/pako/dist/pako.min.js +1 -0
- data/node_modules/pako/dist/pako_deflate.js +3997 -0
- data/node_modules/pako/dist/pako_deflate.min.js +1 -0
- data/node_modules/pako/dist/pako_inflate.js +3300 -0
- data/node_modules/pako/dist/pako_inflate.min.js +1 -0
- data/node_modules/pako/index.js +14 -0
- data/node_modules/pako/lib/deflate.js +400 -0
- data/node_modules/pako/lib/inflate.js +423 -0
- data/node_modules/pako/lib/utils/common.js +105 -0
- data/node_modules/pako/lib/utils/strings.js +187 -0
- data/node_modules/pako/lib/zlib/README +59 -0
- data/node_modules/pako/lib/zlib/adler32.js +51 -0
- data/node_modules/pako/lib/zlib/constants.js +68 -0
- data/node_modules/pako/lib/zlib/crc32.js +59 -0
- data/node_modules/pako/lib/zlib/deflate.js +1874 -0
- data/node_modules/pako/lib/zlib/gzheader.js +58 -0
- data/node_modules/pako/lib/zlib/inffast.js +345 -0
- data/node_modules/pako/lib/zlib/inflate.js +1556 -0
- data/node_modules/pako/lib/zlib/inftrees.js +343 -0
- data/node_modules/pako/lib/zlib/messages.js +32 -0
- data/node_modules/pako/lib/zlib/trees.js +1222 -0
- data/node_modules/pako/lib/zlib/zstream.js +47 -0
- data/node_modules/pako/package.json +44 -0
- data/node_modules/path-is-absolute/index.js +20 -0
- data/node_modules/path-is-absolute/license +21 -0
- data/node_modules/path-is-absolute/package.json +43 -0
- data/node_modules/path-is-absolute/readme.md +59 -0
- data/node_modules/process-nextick-args/index.js +45 -0
- data/node_modules/process-nextick-args/license.md +19 -0
- data/node_modules/process-nextick-args/package.json +25 -0
- data/node_modules/process-nextick-args/readme.md +18 -0
- data/node_modules/readable-stream/.travis.yml +34 -0
- data/node_modules/readable-stream/CONTRIBUTING.md +38 -0
- data/node_modules/readable-stream/GOVERNANCE.md +136 -0
- data/node_modules/readable-stream/LICENSE +47 -0
- data/node_modules/readable-stream/README.md +58 -0
- data/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +60 -0
- data/node_modules/readable-stream/duplex-browser.js +1 -0
- data/node_modules/readable-stream/duplex.js +1 -0
- data/node_modules/readable-stream/lib/_stream_duplex.js +131 -0
- data/node_modules/readable-stream/lib/_stream_passthrough.js +47 -0
- data/node_modules/readable-stream/lib/_stream_readable.js +1019 -0
- data/node_modules/readable-stream/lib/_stream_transform.js +214 -0
- data/node_modules/readable-stream/lib/_stream_writable.js +687 -0
- data/node_modules/readable-stream/lib/internal/streams/BufferList.js +79 -0
- data/node_modules/readable-stream/lib/internal/streams/destroy.js +74 -0
- data/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
- data/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
- data/node_modules/readable-stream/package.json +52 -0
- data/node_modules/readable-stream/passthrough.js +1 -0
- data/node_modules/readable-stream/readable-browser.js +7 -0
- data/node_modules/readable-stream/readable.js +19 -0
- data/node_modules/readable-stream/transform.js +1 -0
- data/node_modules/readable-stream/writable-browser.js +1 -0
- data/node_modules/readable-stream/writable.js +8 -0
- data/node_modules/rimraf/LICENSE +15 -0
- data/node_modules/rimraf/README.md +101 -0
- data/node_modules/rimraf/bin.js +50 -0
- data/node_modules/rimraf/package.json +29 -0
- data/node_modules/rimraf/rimraf.js +372 -0
- data/node_modules/safe-buffer/LICENSE +21 -0
- data/node_modules/safe-buffer/README.md +584 -0
- data/node_modules/safe-buffer/index.d.ts +187 -0
- data/node_modules/safe-buffer/index.js +62 -0
- data/node_modules/safe-buffer/package.json +37 -0
- data/node_modules/selenium-webdriver/CHANGES.md +1114 -0
- data/node_modules/selenium-webdriver/LICENSE +202 -0
- data/node_modules/selenium-webdriver/NOTICE +2 -0
- data/node_modules/selenium-webdriver/README.md +229 -0
- data/node_modules/selenium-webdriver/chrome.js +295 -0
- data/node_modules/selenium-webdriver/chromium.js +829 -0
- data/node_modules/selenium-webdriver/devtools/CDPConnection.js +35 -0
- data/node_modules/selenium-webdriver/edge.js +224 -0
- data/node_modules/selenium-webdriver/example/chrome_android.js +45 -0
- data/node_modules/selenium-webdriver/example/chrome_mobile_emulation.js +46 -0
- data/node_modules/selenium-webdriver/example/firefox_channels.js +84 -0
- data/node_modules/selenium-webdriver/example/google_search.js +50 -0
- data/node_modules/selenium-webdriver/example/google_search_test.js +70 -0
- data/node_modules/selenium-webdriver/example/headless.js +63 -0
- data/node_modules/selenium-webdriver/example/logging.js +64 -0
- data/node_modules/selenium-webdriver/firefox.js +789 -0
- data/node_modules/selenium-webdriver/http/index.js +324 -0
- data/node_modules/selenium-webdriver/http/util.js +172 -0
- data/node_modules/selenium-webdriver/ie.js +503 -0
- data/node_modules/selenium-webdriver/index.js +825 -0
- data/node_modules/selenium-webdriver/io/exec.js +162 -0
- data/node_modules/selenium-webdriver/io/index.js +348 -0
- data/node_modules/selenium-webdriver/io/zip.js +223 -0
- data/node_modules/selenium-webdriver/lib/atoms/find-elements.js +123 -0
- data/node_modules/selenium-webdriver/lib/atoms/get-attribute.js +101 -0
- data/node_modules/selenium-webdriver/lib/atoms/is-displayed.js +101 -0
- data/node_modules/selenium-webdriver/lib/atoms/mutation-listener.js +55 -0
- data/node_modules/selenium-webdriver/lib/by.js +415 -0
- data/node_modules/selenium-webdriver/lib/capabilities.js +553 -0
- data/node_modules/selenium-webdriver/lib/command.js +206 -0
- data/node_modules/selenium-webdriver/lib/error.js +605 -0
- data/node_modules/selenium-webdriver/lib/http.js +704 -0
- data/node_modules/selenium-webdriver/lib/input.js +946 -0
- data/node_modules/selenium-webdriver/lib/logging.js +661 -0
- data/node_modules/selenium-webdriver/lib/promise.js +285 -0
- data/node_modules/selenium-webdriver/lib/proxy.js +212 -0
- data/node_modules/selenium-webdriver/lib/session.js +77 -0
- data/node_modules/selenium-webdriver/lib/symbols.js +37 -0
- data/node_modules/selenium-webdriver/lib/until.js +429 -0
- data/node_modules/selenium-webdriver/lib/webdriver.js +2919 -0
- data/node_modules/selenium-webdriver/net/index.js +107 -0
- data/node_modules/selenium-webdriver/net/portprober.js +75 -0
- data/node_modules/selenium-webdriver/opera.js +406 -0
- data/node_modules/selenium-webdriver/package.json +54 -0
- data/node_modules/selenium-webdriver/proxy.js +32 -0
- data/node_modules/selenium-webdriver/remote/index.js +624 -0
- data/node_modules/selenium-webdriver/safari.js +168 -0
- data/node_modules/selenium-webdriver/testing/index.js +504 -0
- data/node_modules/set-immediate-shim/index.js +7 -0
- data/node_modules/set-immediate-shim/package.json +34 -0
- data/node_modules/set-immediate-shim/readme.md +31 -0
- data/node_modules/string_decoder/.travis.yml +50 -0
- data/node_modules/string_decoder/LICENSE +48 -0
- data/node_modules/string_decoder/README.md +47 -0
- data/node_modules/string_decoder/lib/string_decoder.js +296 -0
- data/node_modules/string_decoder/package.json +31 -0
- data/node_modules/tmp/CHANGELOG.md +288 -0
- data/node_modules/tmp/LICENSE +21 -0
- data/node_modules/tmp/README.md +365 -0
- data/node_modules/tmp/lib/tmp.js +780 -0
- data/node_modules/tmp/node_modules/.bin/rimraf +1 -0
- data/node_modules/tmp/node_modules/rimraf/CHANGELOG.md +65 -0
- data/node_modules/tmp/node_modules/rimraf/LICENSE +15 -0
- data/node_modules/tmp/node_modules/rimraf/README.md +101 -0
- data/node_modules/tmp/node_modules/rimraf/bin.js +68 -0
- data/node_modules/tmp/node_modules/rimraf/package.json +32 -0
- data/node_modules/tmp/node_modules/rimraf/rimraf.js +360 -0
- data/node_modules/tmp/package.json +58 -0
- data/node_modules/util-deprecate/History.md +16 -0
- data/node_modules/util-deprecate/LICENSE +24 -0
- data/node_modules/util-deprecate/README.md +53 -0
- data/node_modules/util-deprecate/browser.js +67 -0
- data/node_modules/util-deprecate/node.js +6 -0
- data/node_modules/util-deprecate/package.json +27 -0
- data/node_modules/wrappy/LICENSE +15 -0
- data/node_modules/wrappy/README.md +36 -0
- data/node_modules/wrappy/package.json +29 -0
- data/node_modules/wrappy/wrappy.js +33 -0
- data/node_modules/ws/LICENSE +21 -0
- data/node_modules/ws/README.md +496 -0
- data/node_modules/ws/browser.js +8 -0
- data/node_modules/ws/index.js +10 -0
- data/node_modules/ws/lib/buffer-util.js +129 -0
- data/node_modules/ws/lib/constants.js +10 -0
- data/node_modules/ws/lib/event-target.js +184 -0
- data/node_modules/ws/lib/extension.js +223 -0
- data/node_modules/ws/lib/limiter.js +55 -0
- data/node_modules/ws/lib/permessage-deflate.js +517 -0
- data/node_modules/ws/lib/receiver.js +507 -0
- data/node_modules/ws/lib/sender.js +405 -0
- data/node_modules/ws/lib/stream.js +165 -0
- data/node_modules/ws/lib/validation.js +104 -0
- data/node_modules/ws/lib/websocket-server.js +418 -0
- data/node_modules/ws/lib/websocket.js +942 -0
- data/node_modules/ws/package.json +56 -0
- data/package-lock.json +458 -0
- data/package.json +5 -0
- data/selenium.log +1 -0
- metadata +314 -19
@@ -0,0 +1,661 @@
|
|
1
|
+
// Licensed to the Software Freedom Conservancy (SFC) under one
|
2
|
+
// or more contributor license agreements. See the NOTICE file
|
3
|
+
// distributed with this work for additional information
|
4
|
+
// regarding copyright ownership. The SFC licenses this file
|
5
|
+
// to you under the Apache License, Version 2.0 (the
|
6
|
+
// "License"); you may not use this file except in compliance
|
7
|
+
// with the License. You may obtain a copy of the License at
|
8
|
+
//
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
//
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
12
|
+
// software distributed under the License is distributed on an
|
13
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
// KIND, either express or implied. See the License for the
|
15
|
+
// specific language governing permissions and limitations
|
16
|
+
// under the License.
|
17
|
+
|
18
|
+
'use strict'
|
19
|
+
|
20
|
+
/**
|
21
|
+
* @fileoverview Defines WebDriver's logging system. The logging system is
|
22
|
+
* broken into major components: local and remote logging.
|
23
|
+
*
|
24
|
+
* The local logging API, which is anchored by the {@linkplain Logger} class is
|
25
|
+
* similar to Java's logging API. Loggers, retrieved by
|
26
|
+
* {@linkplain #getLogger getLogger(name)}, use hierarchical, dot-delimited
|
27
|
+
* namespaces (e.g. "" > "webdriver" > "webdriver.logging"). Recorded log
|
28
|
+
* messages are represented by the {@linkplain Entry} class. You can capture log
|
29
|
+
* records by {@linkplain Logger#addHandler attaching} a handler function to the
|
30
|
+
* desired logger. For convenience, you can quickly enable logging to the
|
31
|
+
* console by simply calling {@linkplain #installConsoleHandler
|
32
|
+
* installConsoleHandler}.
|
33
|
+
*
|
34
|
+
* The [remote logging API](https://github.com/SeleniumHQ/selenium/wiki/Logging)
|
35
|
+
* allows you to retrieve logs from a remote WebDriver server. This API uses the
|
36
|
+
* {@link Preferences} class to define desired log levels prior to creating
|
37
|
+
* a WebDriver session:
|
38
|
+
*
|
39
|
+
* var prefs = new logging.Preferences();
|
40
|
+
* prefs.setLevel(logging.Type.BROWSER, logging.Level.DEBUG);
|
41
|
+
*
|
42
|
+
* var caps = Capabilities.chrome();
|
43
|
+
* caps.setLoggingPrefs(prefs);
|
44
|
+
* // ...
|
45
|
+
*
|
46
|
+
* Remote log entries, also represented by the {@link Entry} class, may be
|
47
|
+
* retrieved via {@link webdriver.WebDriver.Logs}:
|
48
|
+
*
|
49
|
+
* driver.manage().logs().get(logging.Type.BROWSER)
|
50
|
+
* .then(function(entries) {
|
51
|
+
* entries.forEach(function(entry) {
|
52
|
+
* console.log('[%s] %s', entry.level.name, entry.message);
|
53
|
+
* });
|
54
|
+
* });
|
55
|
+
*
|
56
|
+
* **NOTE:** Only a few browsers support the remote logging API (notably
|
57
|
+
* Firefox and Chrome). Firefox supports basic logging functionality, while
|
58
|
+
* Chrome exposes robust
|
59
|
+
* [performance logging](https://chromedriver.chromium.org/logging)
|
60
|
+
* options. Remote logging is still considered a non-standard feature, and the
|
61
|
+
* APIs exposed by this module for it are non-frozen. This module will be
|
62
|
+
* updated, possibly breaking backwards-compatibility, once logging is
|
63
|
+
* officially defined by the
|
64
|
+
* [W3C WebDriver spec](http://www.w3.org/TR/webdriver/).
|
65
|
+
*/
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Defines a message level that may be used to control logging output.
|
69
|
+
*
|
70
|
+
* @final
|
71
|
+
*/
|
72
|
+
class Level {
|
73
|
+
/**
|
74
|
+
* @param {string} name the level's name.
|
75
|
+
* @param {number} level the level's numeric value.
|
76
|
+
*/
|
77
|
+
constructor(name, level) {
|
78
|
+
if (level < 0) {
|
79
|
+
throw new TypeError('Level must be >= 0')
|
80
|
+
}
|
81
|
+
|
82
|
+
/** @private {string} */
|
83
|
+
this.name_ = name
|
84
|
+
|
85
|
+
/** @private {number} */
|
86
|
+
this.value_ = level
|
87
|
+
}
|
88
|
+
|
89
|
+
/** This logger's name. */
|
90
|
+
get name() {
|
91
|
+
return this.name_
|
92
|
+
}
|
93
|
+
|
94
|
+
/** The numeric log level. */
|
95
|
+
get value() {
|
96
|
+
return this.value_
|
97
|
+
}
|
98
|
+
|
99
|
+
/** @override */
|
100
|
+
toString() {
|
101
|
+
return this.name
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
/**
|
106
|
+
* Indicates no log messages should be recorded.
|
107
|
+
* @const
|
108
|
+
*/
|
109
|
+
Level.OFF = new Level('OFF', Infinity)
|
110
|
+
|
111
|
+
/**
|
112
|
+
* Log messages with a level of `1000` or higher.
|
113
|
+
* @const
|
114
|
+
*/
|
115
|
+
Level.SEVERE = new Level('SEVERE', 1000)
|
116
|
+
|
117
|
+
/**
|
118
|
+
* Log messages with a level of `900` or higher.
|
119
|
+
* @const
|
120
|
+
*/
|
121
|
+
Level.WARNING = new Level('WARNING', 900)
|
122
|
+
|
123
|
+
/**
|
124
|
+
* Log messages with a level of `800` or higher.
|
125
|
+
* @const
|
126
|
+
*/
|
127
|
+
Level.INFO = new Level('INFO', 800)
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Log messages with a level of `700` or higher.
|
131
|
+
* @const
|
132
|
+
*/
|
133
|
+
Level.DEBUG = new Level('DEBUG', 700)
|
134
|
+
|
135
|
+
/**
|
136
|
+
* Log messages with a level of `500` or higher.
|
137
|
+
* @const
|
138
|
+
*/
|
139
|
+
Level.FINE = new Level('FINE', 500)
|
140
|
+
|
141
|
+
/**
|
142
|
+
* Log messages with a level of `400` or higher.
|
143
|
+
* @const
|
144
|
+
*/
|
145
|
+
Level.FINER = new Level('FINER', 400)
|
146
|
+
|
147
|
+
/**
|
148
|
+
* Log messages with a level of `300` or higher.
|
149
|
+
* @const
|
150
|
+
*/
|
151
|
+
Level.FINEST = new Level('FINEST', 300)
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Indicates all log messages should be recorded.
|
155
|
+
* @const
|
156
|
+
*/
|
157
|
+
Level.ALL = new Level('ALL', 0)
|
158
|
+
|
159
|
+
const ALL_LEVELS = /** !Set<Level> */ new Set([
|
160
|
+
Level.OFF,
|
161
|
+
Level.SEVERE,
|
162
|
+
Level.WARNING,
|
163
|
+
Level.INFO,
|
164
|
+
Level.DEBUG,
|
165
|
+
Level.FINE,
|
166
|
+
Level.FINER,
|
167
|
+
Level.FINEST,
|
168
|
+
Level.ALL,
|
169
|
+
])
|
170
|
+
|
171
|
+
const LEVELS_BY_NAME = /** !Map<string, !Level> */ new Map([
|
172
|
+
[Level.OFF.name, Level.OFF],
|
173
|
+
[Level.SEVERE.name, Level.SEVERE],
|
174
|
+
[Level.WARNING.name, Level.WARNING],
|
175
|
+
[Level.INFO.name, Level.INFO],
|
176
|
+
[Level.DEBUG.name, Level.DEBUG],
|
177
|
+
[Level.FINE.name, Level.FINE],
|
178
|
+
[Level.FINER.name, Level.FINER],
|
179
|
+
[Level.FINEST.name, Level.FINEST],
|
180
|
+
[Level.ALL.name, Level.ALL],
|
181
|
+
])
|
182
|
+
|
183
|
+
/**
|
184
|
+
* Converts a level name or value to a {@link Level} value. If the name/value
|
185
|
+
* is not recognized, {@link Level.ALL} will be returned.
|
186
|
+
*
|
187
|
+
* @param {(number|string)} nameOrValue The log level name, or value, to
|
188
|
+
* convert.
|
189
|
+
* @return {!Level} The converted level.
|
190
|
+
*/
|
191
|
+
function getLevel(nameOrValue) {
|
192
|
+
if (typeof nameOrValue === 'string') {
|
193
|
+
return LEVELS_BY_NAME.get(nameOrValue) || Level.ALL
|
194
|
+
}
|
195
|
+
if (typeof nameOrValue !== 'number') {
|
196
|
+
throw new TypeError('not a string or number')
|
197
|
+
}
|
198
|
+
for (let level of ALL_LEVELS) {
|
199
|
+
if (nameOrValue >= level.value) {
|
200
|
+
return level
|
201
|
+
}
|
202
|
+
}
|
203
|
+
return Level.ALL
|
204
|
+
}
|
205
|
+
|
206
|
+
/**
|
207
|
+
* Describes a single log entry.
|
208
|
+
*
|
209
|
+
* @final
|
210
|
+
*/
|
211
|
+
class Entry {
|
212
|
+
/**
|
213
|
+
* @param {(!Level|string|number)} level The entry level.
|
214
|
+
* @param {string} message The log message.
|
215
|
+
* @param {number=} opt_timestamp The time this entry was generated, in
|
216
|
+
* milliseconds since 0:00:00, January 1, 1970 UTC. If omitted, the
|
217
|
+
* current time will be used.
|
218
|
+
* @param {string=} opt_type The log type, if known.
|
219
|
+
*/
|
220
|
+
constructor(level, message, opt_timestamp, opt_type) {
|
221
|
+
this.level = level instanceof Level ? level : getLevel(level)
|
222
|
+
this.message = message
|
223
|
+
this.timestamp =
|
224
|
+
typeof opt_timestamp === 'number' ? opt_timestamp : Date.now()
|
225
|
+
this.type = opt_type || ''
|
226
|
+
}
|
227
|
+
|
228
|
+
/**
|
229
|
+
* @return {{level: string, message: string, timestamp: number,
|
230
|
+
* type: string}} The JSON representation of this entry.
|
231
|
+
*/
|
232
|
+
toJSON() {
|
233
|
+
return {
|
234
|
+
level: this.level.name,
|
235
|
+
message: this.message,
|
236
|
+
timestamp: this.timestamp,
|
237
|
+
type: this.type,
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
/**
|
243
|
+
* An object used to log debugging messages. Loggers use a hierarchical,
|
244
|
+
* dot-separated naming scheme. For instance, "foo" is considered the parent of
|
245
|
+
* the "foo.bar" and an ancestor of "foo.bar.baz".
|
246
|
+
*
|
247
|
+
* Each logger may be assigned a {@linkplain #setLevel log level}, which
|
248
|
+
* controls which level of messages will be reported to the
|
249
|
+
* {@linkplain #addHandler handlers} attached to this instance. If a log level
|
250
|
+
* is not explicitly set on a logger, it will inherit its parent.
|
251
|
+
*
|
252
|
+
* This class should never be directly instantiated. Instead, users should
|
253
|
+
* obtain logger references using the {@linkplain ./logging.getLogger()
|
254
|
+
* getLogger()} function.
|
255
|
+
*
|
256
|
+
* @final
|
257
|
+
*/
|
258
|
+
class Logger {
|
259
|
+
/**
|
260
|
+
* @param {string} name the name of this logger.
|
261
|
+
* @param {Level=} opt_level the initial level for this logger.
|
262
|
+
*/
|
263
|
+
constructor(name, opt_level) {
|
264
|
+
/** @private {string} */
|
265
|
+
this.name_ = name
|
266
|
+
|
267
|
+
/** @private {Level} */
|
268
|
+
this.level_ = opt_level || null
|
269
|
+
|
270
|
+
/** @private {Logger} */
|
271
|
+
this.parent_ = null
|
272
|
+
|
273
|
+
/** @private {Set<function(!Entry)>} */
|
274
|
+
this.handlers_ = null
|
275
|
+
}
|
276
|
+
|
277
|
+
/** @return {string} the name of this logger. */
|
278
|
+
getName() {
|
279
|
+
return this.name_
|
280
|
+
}
|
281
|
+
|
282
|
+
/**
|
283
|
+
* @param {Level} level the new level for this logger, or `null` if the logger
|
284
|
+
* should inherit its level from its parent logger.
|
285
|
+
*/
|
286
|
+
setLevel(level) {
|
287
|
+
this.level_ = level
|
288
|
+
}
|
289
|
+
|
290
|
+
/** @return {Level} the log level for this logger. */
|
291
|
+
getLevel() {
|
292
|
+
return this.level_
|
293
|
+
}
|
294
|
+
|
295
|
+
/**
|
296
|
+
* @return {!Level} the effective level for this logger.
|
297
|
+
*/
|
298
|
+
getEffectiveLevel() {
|
299
|
+
let logger = this
|
300
|
+
let level
|
301
|
+
do {
|
302
|
+
level = logger.level_
|
303
|
+
logger = logger.parent_
|
304
|
+
} while (logger && !level)
|
305
|
+
return level || Level.OFF
|
306
|
+
}
|
307
|
+
|
308
|
+
/**
|
309
|
+
* @param {!Level} level the level to check.
|
310
|
+
* @return {boolean} whether messages recorded at the given level are loggable
|
311
|
+
* by this instance.
|
312
|
+
*/
|
313
|
+
isLoggable(level) {
|
314
|
+
return (
|
315
|
+
level.value !== Level.OFF.value &&
|
316
|
+
level.value >= this.getEffectiveLevel().value
|
317
|
+
)
|
318
|
+
}
|
319
|
+
|
320
|
+
/**
|
321
|
+
* Adds a handler to this logger. The handler will be invoked for each message
|
322
|
+
* logged with this instance, or any of its descendants.
|
323
|
+
*
|
324
|
+
* @param {function(!Entry)} handler the handler to add.
|
325
|
+
*/
|
326
|
+
addHandler(handler) {
|
327
|
+
if (!this.handlers_) {
|
328
|
+
this.handlers_ = new Set()
|
329
|
+
}
|
330
|
+
this.handlers_.add(handler)
|
331
|
+
}
|
332
|
+
|
333
|
+
/**
|
334
|
+
* Removes a handler from this logger.
|
335
|
+
*
|
336
|
+
* @param {function(!Entry)} handler the handler to remove.
|
337
|
+
* @return {boolean} whether a handler was successfully removed.
|
338
|
+
*/
|
339
|
+
removeHandler(handler) {
|
340
|
+
if (!this.handlers_) {
|
341
|
+
return false
|
342
|
+
}
|
343
|
+
return this.handlers_.delete(handler)
|
344
|
+
}
|
345
|
+
|
346
|
+
/**
|
347
|
+
* Logs a message at the given level. The message may be defined as a string
|
348
|
+
* or as a function that will return the message. If a function is provided,
|
349
|
+
* it will only be invoked if this logger's
|
350
|
+
* {@linkplain #getEffectiveLevel() effective log level} includes the given
|
351
|
+
* `level`.
|
352
|
+
*
|
353
|
+
* @param {!Level} level the level at which to log the message.
|
354
|
+
* @param {(string|function(): string)} loggable the message to log, or a
|
355
|
+
* function that will return the message.
|
356
|
+
*/
|
357
|
+
log(level, loggable) {
|
358
|
+
if (!this.isLoggable(level)) {
|
359
|
+
return
|
360
|
+
}
|
361
|
+
let message =
|
362
|
+
'[' +
|
363
|
+
this.name_ +
|
364
|
+
'] ' +
|
365
|
+
(typeof loggable === 'function' ? loggable() : loggable)
|
366
|
+
let entry = new Entry(level, message, Date.now())
|
367
|
+
for (let logger = this; logger; logger = logger.parent_) {
|
368
|
+
if (logger.handlers_) {
|
369
|
+
for (let handler of logger.handlers_) {
|
370
|
+
handler(entry)
|
371
|
+
}
|
372
|
+
}
|
373
|
+
}
|
374
|
+
}
|
375
|
+
|
376
|
+
/**
|
377
|
+
* Logs a message at the {@link Level.SEVERE} log level.
|
378
|
+
* @param {(string|function(): string)} loggable the message to log, or a
|
379
|
+
* function that will return the message.
|
380
|
+
*/
|
381
|
+
severe(loggable) {
|
382
|
+
this.log(Level.SEVERE, loggable)
|
383
|
+
}
|
384
|
+
|
385
|
+
/**
|
386
|
+
* Logs a message at the {@link Level.WARNING} log level.
|
387
|
+
* @param {(string|function(): string)} loggable the message to log, or a
|
388
|
+
* function that will return the message.
|
389
|
+
*/
|
390
|
+
warning(loggable) {
|
391
|
+
this.log(Level.WARNING, loggable)
|
392
|
+
}
|
393
|
+
|
394
|
+
/**
|
395
|
+
* Logs a message at the {@link Level.INFO} log level.
|
396
|
+
* @param {(string|function(): string)} loggable the message to log, or a
|
397
|
+
* function that will return the message.
|
398
|
+
*/
|
399
|
+
info(loggable) {
|
400
|
+
this.log(Level.INFO, loggable)
|
401
|
+
}
|
402
|
+
|
403
|
+
/**
|
404
|
+
* Logs a message at the {@link Level.DEBUG} log level.
|
405
|
+
* @param {(string|function(): string)} loggable the message to log, or a
|
406
|
+
* function that will return the message.
|
407
|
+
*/
|
408
|
+
debug(loggable) {
|
409
|
+
this.log(Level.DEBUG, loggable)
|
410
|
+
}
|
411
|
+
|
412
|
+
/**
|
413
|
+
* Logs a message at the {@link Level.FINE} log level.
|
414
|
+
* @param {(string|function(): string)} loggable the message to log, or a
|
415
|
+
* function that will return the message.
|
416
|
+
*/
|
417
|
+
fine(loggable) {
|
418
|
+
this.log(Level.FINE, loggable)
|
419
|
+
}
|
420
|
+
|
421
|
+
/**
|
422
|
+
* Logs a message at the {@link Level.FINER} log level.
|
423
|
+
* @param {(string|function(): string)} loggable the message to log, or a
|
424
|
+
* function that will return the message.
|
425
|
+
*/
|
426
|
+
finer(loggable) {
|
427
|
+
this.log(Level.FINER, loggable)
|
428
|
+
}
|
429
|
+
|
430
|
+
/**
|
431
|
+
* Logs a message at the {@link Level.FINEST} log level.
|
432
|
+
* @param {(string|function(): string)} loggable the message to log, or a
|
433
|
+
* function that will return the message.
|
434
|
+
*/
|
435
|
+
finest(loggable) {
|
436
|
+
this.log(Level.FINEST, loggable)
|
437
|
+
}
|
438
|
+
}
|
439
|
+
|
440
|
+
/**
|
441
|
+
* Maintains a collection of loggers.
|
442
|
+
*
|
443
|
+
* @final
|
444
|
+
*/
|
445
|
+
class LogManager {
|
446
|
+
constructor() {
|
447
|
+
/** @private {!Map<string, !Logger>} */
|
448
|
+
this.loggers_ = new Map()
|
449
|
+
this.root_ = new Logger('', Level.OFF)
|
450
|
+
}
|
451
|
+
|
452
|
+
/**
|
453
|
+
* Retrieves a named logger, creating it in the process. This function will
|
454
|
+
* implicitly create the requested logger, and any of its parents, if they
|
455
|
+
* do not yet exist.
|
456
|
+
*
|
457
|
+
* @param {string} name the logger's name.
|
458
|
+
* @return {!Logger} the requested logger.
|
459
|
+
*/
|
460
|
+
getLogger(name) {
|
461
|
+
if (!name) {
|
462
|
+
return this.root_
|
463
|
+
}
|
464
|
+
let parent = this.root_
|
465
|
+
for (let i = name.indexOf('.'); i != -1; i = name.indexOf('.', i + 1)) {
|
466
|
+
let parentName = name.substr(0, i)
|
467
|
+
parent = this.createLogger_(parentName, parent)
|
468
|
+
}
|
469
|
+
return this.createLogger_(name, parent)
|
470
|
+
}
|
471
|
+
|
472
|
+
/**
|
473
|
+
* Creates a new logger.
|
474
|
+
*
|
475
|
+
* @param {string} name the logger's name.
|
476
|
+
* @param {!Logger} parent the logger's parent.
|
477
|
+
* @return {!Logger} the new logger.
|
478
|
+
* @private
|
479
|
+
*/
|
480
|
+
createLogger_(name, parent) {
|
481
|
+
if (this.loggers_.has(name)) {
|
482
|
+
return /** @type {!Logger} */ (this.loggers_.get(name))
|
483
|
+
}
|
484
|
+
let logger = new Logger(name, null)
|
485
|
+
logger.parent_ = parent
|
486
|
+
this.loggers_.set(name, logger)
|
487
|
+
return logger
|
488
|
+
}
|
489
|
+
}
|
490
|
+
|
491
|
+
const logManager = new LogManager()
|
492
|
+
|
493
|
+
/**
|
494
|
+
* Retrieves a named logger, creating it in the process. This function will
|
495
|
+
* implicitly create the requested logger, and any of its parents, if they
|
496
|
+
* do not yet exist.
|
497
|
+
*
|
498
|
+
* The log level will be unspecified for newly created loggers. Use
|
499
|
+
* {@link Logger#setLevel(level)} to explicitly set a level.
|
500
|
+
*
|
501
|
+
* @param {string} name the logger's name.
|
502
|
+
* @return {!Logger} the requested logger.
|
503
|
+
*/
|
504
|
+
function getLogger(name) {
|
505
|
+
return logManager.getLogger(name)
|
506
|
+
}
|
507
|
+
|
508
|
+
/**
|
509
|
+
* Pads a number to ensure it has a minimum of two digits.
|
510
|
+
*
|
511
|
+
* @param {number} n the number to be padded.
|
512
|
+
* @return {string} the padded number.
|
513
|
+
*/
|
514
|
+
function pad(n) {
|
515
|
+
if (n >= 10) {
|
516
|
+
return '' + n
|
517
|
+
} else {
|
518
|
+
return '0' + n
|
519
|
+
}
|
520
|
+
}
|
521
|
+
|
522
|
+
/**
|
523
|
+
* Logs all messages to the Console API.
|
524
|
+
* @param {!Entry} entry the entry to log.
|
525
|
+
*/
|
526
|
+
function consoleHandler(entry) {
|
527
|
+
if (typeof console === 'undefined' || !console) {
|
528
|
+
return
|
529
|
+
}
|
530
|
+
|
531
|
+
var timestamp = new Date(entry.timestamp)
|
532
|
+
var msg =
|
533
|
+
'[' +
|
534
|
+
timestamp.getUTCFullYear() +
|
535
|
+
'-' +
|
536
|
+
pad(timestamp.getUTCMonth() + 1) +
|
537
|
+
'-' +
|
538
|
+
pad(timestamp.getUTCDate()) +
|
539
|
+
'T' +
|
540
|
+
pad(timestamp.getUTCHours()) +
|
541
|
+
':' +
|
542
|
+
pad(timestamp.getUTCMinutes()) +
|
543
|
+
':' +
|
544
|
+
pad(timestamp.getUTCSeconds()) +
|
545
|
+
'Z] ' +
|
546
|
+
'[' +
|
547
|
+
entry.level.name +
|
548
|
+
'] ' +
|
549
|
+
entry.message
|
550
|
+
|
551
|
+
var level = entry.level.value
|
552
|
+
if (level >= Level.SEVERE.value) {
|
553
|
+
console.error(msg)
|
554
|
+
} else if (level >= Level.WARNING.value) {
|
555
|
+
console.warn(msg)
|
556
|
+
} else {
|
557
|
+
console.log(msg)
|
558
|
+
}
|
559
|
+
}
|
560
|
+
|
561
|
+
/**
|
562
|
+
* Adds the console handler to the given logger. The console handler will log
|
563
|
+
* all messages using the JavaScript Console API.
|
564
|
+
*
|
565
|
+
* @param {Logger=} opt_logger The logger to add the handler to; defaults
|
566
|
+
* to the root logger.
|
567
|
+
*/
|
568
|
+
function addConsoleHandler(opt_logger) {
|
569
|
+
let logger = opt_logger || logManager.root_
|
570
|
+
logger.addHandler(consoleHandler)
|
571
|
+
}
|
572
|
+
|
573
|
+
/**
|
574
|
+
* Removes the console log handler from the given logger.
|
575
|
+
*
|
576
|
+
* @param {Logger=} opt_logger The logger to remove the handler from; defaults
|
577
|
+
* to the root logger.
|
578
|
+
* @see exports.addConsoleHandler
|
579
|
+
*/
|
580
|
+
function removeConsoleHandler(opt_logger) {
|
581
|
+
let logger = opt_logger || logManager.root_
|
582
|
+
logger.removeHandler(consoleHandler)
|
583
|
+
}
|
584
|
+
|
585
|
+
/**
|
586
|
+
* Installs the console log handler on the root logger.
|
587
|
+
*/
|
588
|
+
function installConsoleHandler() {
|
589
|
+
addConsoleHandler(logManager.root_)
|
590
|
+
}
|
591
|
+
|
592
|
+
/**
|
593
|
+
* Common log types.
|
594
|
+
* @enum {string}
|
595
|
+
*/
|
596
|
+
const Type = {
|
597
|
+
/** Logs originating from the browser. */
|
598
|
+
BROWSER: 'browser',
|
599
|
+
/** Logs from a WebDriver client. */
|
600
|
+
CLIENT: 'client',
|
601
|
+
/** Logs from a WebDriver implementation. */
|
602
|
+
DRIVER: 'driver',
|
603
|
+
/** Logs related to performance. */
|
604
|
+
PERFORMANCE: 'performance',
|
605
|
+
/** Logs from the remote server. */
|
606
|
+
SERVER: 'server',
|
607
|
+
}
|
608
|
+
|
609
|
+
/**
|
610
|
+
* Describes the log preferences for a WebDriver session.
|
611
|
+
*
|
612
|
+
* @final
|
613
|
+
*/
|
614
|
+
class Preferences {
|
615
|
+
constructor() {
|
616
|
+
/** @private {!Map<string, !Level>} */
|
617
|
+
this.prefs_ = new Map()
|
618
|
+
}
|
619
|
+
|
620
|
+
/**
|
621
|
+
* Sets the desired logging level for a particular log type.
|
622
|
+
* @param {(string|Type)} type The log type.
|
623
|
+
* @param {(!Level|string|number)} level The desired log level.
|
624
|
+
* @throws {TypeError} if `type` is not a `string`.
|
625
|
+
*/
|
626
|
+
setLevel(type, level) {
|
627
|
+
if (typeof type !== 'string') {
|
628
|
+
throw TypeError('specified log type is not a string: ' + typeof type)
|
629
|
+
}
|
630
|
+
this.prefs_.set(type, level instanceof Level ? level : getLevel(level))
|
631
|
+
}
|
632
|
+
|
633
|
+
/**
|
634
|
+
* Converts this instance to its JSON representation.
|
635
|
+
* @return {!Object<string, string>} The JSON representation of this set of
|
636
|
+
* preferences.
|
637
|
+
*/
|
638
|
+
toJSON() {
|
639
|
+
let json = {}
|
640
|
+
for (let key of this.prefs_.keys()) {
|
641
|
+
json[key] = this.prefs_.get(key).name
|
642
|
+
}
|
643
|
+
return json
|
644
|
+
}
|
645
|
+
}
|
646
|
+
|
647
|
+
// PUBLIC API
|
648
|
+
|
649
|
+
module.exports = {
|
650
|
+
Entry: Entry,
|
651
|
+
Level: Level,
|
652
|
+
LogManager: LogManager,
|
653
|
+
Logger: Logger,
|
654
|
+
Preferences: Preferences,
|
655
|
+
Type: Type,
|
656
|
+
addConsoleHandler: addConsoleHandler,
|
657
|
+
getLevel: getLevel,
|
658
|
+
getLogger: getLogger,
|
659
|
+
installConsoleHandler: installConsoleHandler,
|
660
|
+
removeConsoleHandler: removeConsoleHandler,
|
661
|
+
}
|