summaryrefslogtreecommitdiff
path: root/src/lib/log.js
blob: a30a5a6de32efde49a11a46e1254df10d59168eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

{
  let PREFIX = typeof browser === "object"
    ? `[${browser.runtime.getManifest().name}]` : '';

  let debugCount = 0;

  function log(msg, ...rest) {
    console.log(`${PREFIX} ${msg}`, ...rest);
  }

  function debug(msg, ...rest) {
    console.debug(`${PREFIX}:${debugCount++} ${msg}`, ...rest);
  }

  function error(e, msg, ...rest) {
    console.error(`${PREFIX} ${msg}`, ...rest, e, e.message, e.stack);
  }
}