Skip to content
This repository was archived by the owner on Dec 31, 2023. It is now read-only.

Commit 522a3a8

Browse files
committed
prefix all console messages with the plugin name
1 parent 7ac3a5e commit 522a3a8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
33
const CONFIG_DEFAULT_HOST = 'https://phabricator.example.com/api/';
44
const CONFIG_DEFAULT_TOKEN = 'api-XYZ';
55

6+
function prefix(fn, start) {
7+
const ctx = this;
8+
return function(message) {
9+
fn.call(ctx, start + message);
10+
}
11+
}
12+
13+
console.debug = prefix(console.debug, '[open-in-diffusion] ');
14+
console.error = prefix(console.error, '[open-in-diffusion] ');
15+
console.info = prefix(console.info, '[open-in-diffusion] ');
16+
console.log = prefix(console.log, '[open-in-diffusion] ');
17+
console.warn = prefix(console.warn, '[open-in-diffusion] ');
18+
619
function rangeToString(range) {
720
if (range.start.row === range.end.row) {
821
return range.start.row + 1;

0 commit comments

Comments
 (0)