diff options
| author | Stephen Blott | 2016-03-06 07:28:41 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2016-03-17 14:26:43 +0000 | 
| commit | e507eb8e3fc1b7f6a9ff7fb0c46760161997912a (patch) | |
| tree | b3a93da13a6c640748247814b979f4ed5b9dedab /background_scripts/bg_utils.coffee | |
| parent | f7ac5152ff79d62d923a9830db990d2b4ad0d592 (diff) | |
| download | vimium-e507eb8e3fc1b7f6a9ff7fb0c46760161997912a.tar.bz2 | |
Logging; move logMessage to BgUtils."
Diffstat (limited to 'background_scripts/bg_utils.coffee')
| -rw-r--r-- | background_scripts/bg_utils.coffee | 12 | 
1 files changed, 12 insertions, 0 deletions
| diff --git a/background_scripts/bg_utils.coffee b/background_scripts/bg_utils.coffee index ca042686..0b6e4338 100644 --- a/background_scripts/bg_utils.coffee +++ b/background_scripts/bg_utils.coffee @@ -53,4 +53,16 @@ class TabRecency  BgUtils =    tabRecency: new TabRecency() +  # Log messages to the extension's logging page, but only if that page is open. +  log: do -> +    loggingPageUrl = chrome.runtime.getURL "pages/logging.html" +    console.log "Vimium logging URL:\n  #{loggingPageUrl}" if loggingPageUrl? # Do not output URL for tests. +    (message, sender = null) -> +      for viewWindow in chrome.extension.getViews {type: "tab"} +        if viewWindow.location.pathname == "/pages/logging.html" +          # Don't log messages from the logging page itself.  We do this check late because most of the time +          # it's not needed. +          if sender?.url != loggingPageUrl +            viewWindow.document.getElementById("log-text").value += "#{(new Date()).toISOString()}: #{message}\n" +  root.BgUtils = BgUtils | 
