Skip to content

Commit 4d26c40

Browse files
committed
Use console.warn and console.error
1 parent f882b86 commit 4d26c40

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+149
-132
lines changed

as.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
$.as.route(location.hash.slice(1));
212212
$(JOY.start = JOY.start || function(){ $.as(document, gun, null, JOY.opt) });
213213

214-
if($('body').attr('peers')){ (console.warn || console.log)('Warning: Please upgrade <body peers=""> to https://github.com/eraeco/joydb#peers !') }
214+
if($('body').attr('peers')){ console.warn('Please upgrade <body peers=""> to https://github.com/eraeco/joydb#peers !') }
215215

216216
});
217217
;(function(){ // need to isolate into separate module!
@@ -228,7 +228,7 @@
228228
var opt = joy.opt = window.CONFIG || {}, peers;
229229
$('link[type=peer]').each(function(){ (peers || (peers = [])).push($(this).attr('href')) });
230230
!window.gun && (opt.peers = opt.peers || peers || (function(){
231-
(console.warn || console.log)('Warning: No peer provided, defaulting to DEMO peer. Do not run in production, or your data will be regularly wiped, reset, or deleted. For more info, check https://github.com/eraeco/joydb#peers !');
231+
console.warn('No peer provided, defaulting to DEMO peer. Do not run in production, or your data will be regularly wiped, reset, or deleted. For more info, check https://github.com/eraeco/joydb#peers !');
232232
return ['https://gunjs.herokuapp.com/gun'];
233233
}()));
234234
window.gun = window.gun || Gun(opt);

axe.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
tmp = peers[id = 'http://localhost:8765/gun'] = peers[id] || {};
2828
tmp.id = tmp.url = id; tmp.retry = tmp.retry || 0;
2929
Gun.log.once("AXE", "AXE enabled: Trying to find network via (1) local peer (2) last used peers (3) a URL parameter, and last (4) hard coded peers.");
30-
Gun.log.once("AXEWarn", "Warning: AXE is in alpha, use only for testing!");
30+
Gun.warn.once("AXEWarn", "AXE is in alpha, use only for testing!");
3131
var last = lS.peers || ''; if(last){ last += ' ' }
3232
last += ((loc.search||'').split('peers=')[1]||'').split('&')[0];
3333

examples/Main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ if (!isElectron && ('serviceWorker' in navigator)) {
4242
navigator.serviceWorker.register('iris/serviceworker.js')
4343
.catch(function(err) {
4444
// registration failed :(
45-
console.log('ServiceWorker registration failed: ', err);
45+
console.warn('ServiceWorker registration failed: ', err);
4646
});
4747
});
4848
}

examples/react-native/src/extensions/sea.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@
894894
(cb || noop)({ok: 0});
895895
});
896896
} catch (e) {
897-
Gun.log('User.delete failed! Error:', e);
897+
Gun.error('User.delete failed! Error:', e);
898898
}
899899
return gun;
900900
}

examples/vanilla/video.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
record.ing.start()
3838
}
3939

40-
function error(err) { console.log(err) }
40+
function error(err) { console.error(err) }
4141

4242
if (type === 'Camera') {
4343
navigator.getMedia({ video: true, audio: true }, load, error)

gun.js

+20-14
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@
436436
var ERR = "Error: Invalid graph!";
437437
var cut = function(s){ return " '"+(''+s).slice(0,9)+"...' " }
438438
var L = JSON.stringify, MD = 2147483647, State = Gun.state;
439-
var C = 0, CT, CF = function(){if(C>999 && (C/-(CT - (CT = +new Date))>1)){Gun.window && console.log("Warning: You're syncing 1K+ records a second, faster than DOM can update - consider limiting query.");CF=function(){C=0}}};
439+
var C = 0, CT, CF = function(){if(C>999 && (C/-(CT - (CT = +new Date))>1)){Gun.window && console.warn("You're syncing 1K+ records a second, faster than DOM can update - consider limiting query.");CF=function(){C=0}}};
440440

441441
}());
442442

@@ -540,7 +540,11 @@
540540
var obj_each = function(o,f){ Object.keys(o).forEach(f,o) }, text_rand = String.random, turn = setTimeout.turn, valid = Gun.valid, state_is = Gun.state.is, state_ify = Gun.state.ify, u, empty = {}, C;
541541

542542
Gun.log = function(){ return (!Gun.log.off && C.log.apply(C, arguments)), [].slice.call(arguments).join(' ') };
543+
Gun.warn = function(){ return (!Gun.log.off && !Gun.warn.off && C.warn.apply(C, arguments)), [].slice.call(arguments).join(' ') };
544+
Gun.error = function(){ return (!Gun.log.off && !Gun.error.off && C.error.apply(C, arguments)), [].slice.call(arguments).join(' ') };
543545
Gun.log.once = function(w,s,o){ return (o = Gun.log.once)[w] = o[w] || 0, o[w]++ || Gun.log(s) };
546+
Gun.warn.once = function(w,s,o){ return (o = Gun.warn.once)[w] = o[w] || 0, o[w]++ || Gun.warn(s) };
547+
Gun.error.once = function(w,s,o){ return (o = Gun.error.once)[w] = o[w] || 0, o[w]++ || Gun.error(s) };
544548

545549
if(typeof window !== "undefined"){ (window.GUN = window.Gun = Gun).window = window }
546550
try{ if(typeof MODULE !== "undefined"){ MODULE.exports = Gun } }catch(e){}
@@ -696,7 +700,7 @@
696700
var root = cat.root, gun = msg.$ || (msg.$ = cat.$), at = (gun||'')._ || empty, tmp = msg.put||'', soul = tmp['#'], key = tmp['.'], change = (u !== tmp['='])? tmp['='] : tmp[':'], state = tmp['>'] || -Infinity, sat; // eve = event, at = data at, cat = chain at, sat = sub at (children chains).
697701
if(u !== msg.put && (u === tmp['#'] || u === tmp['.'] || (u === tmp[':'] && u === tmp['=']) || u === tmp['>'])){ // convert from old format
698702
if(!valid(tmp)){
699-
if(!(soul = ((tmp||'')._||'')['#'])){ console.log("chain not yet supported for", tmp, '...', msg, cat); return; }
703+
if(!(soul = ((tmp||'')._||'')['#'])){ console.warn("chain not yet supported for", tmp, '...', msg, cat); return; }
700704
gun = cat.root.$.get(soul);
701705
return setTimeout.each(Object.keys(tmp).sort(), function(k){ // TODO: .keys( is slow // BUG? ?Some re-in logic may depend on this being sync?
702706
if('_' == k || u === (state = state_is(tmp, k))){ return }
@@ -852,7 +856,7 @@
852856
var gun, tmp;
853857
if(typeof key === 'string'){
854858
if(key.length == 0) {
855-
(gun = this.chain())._.err = {err: Gun.log('0 length key!', key)};
859+
(gun = this.chain())._.err = {err: Gun.warn('0 length key!', key)};
856860
if(cb){ cb.call(gun, gun._.err) }
857861
return gun;
858862
}
@@ -943,7 +947,7 @@
943947
gun = tmp(this, key);
944948
}
945949
if(!gun){
946-
(gun = this.chain())._.err = {err: Gun.log('Invalid get request!', key)}; // CLEAN UP
950+
(gun = this.chain())._.err = {err: Gun.warn('Invalid get request!', key)}; // CLEAN UP
947951
if(cb){ cb.call(gun, gun._.err) }
948952
return gun;
949953
}
@@ -1254,7 +1258,7 @@
12541258
return gun;
12551259
}
12561260
function none(gun,opt,chain){
1257-
Gun.log.once("valonce", "Chainable val is experimental, its behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it.");
1261+
Gun.warn.once("valonce", "Chainable val is experimental, its behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it.");
12581262
(chain = gun.chain())._.nix = gun.once(function(data, key){ chain._.on('in', this._) });
12591263
chain._.lex = gun._.lex; // TODO: Better approach in future? This is quick for now.
12601264
return chain;
@@ -1329,7 +1333,7 @@
13291333
gun.on('in', map, chain._);
13301334
return chain;
13311335
}
1332-
Gun.log.once("mapfn", "Map functions are experimental, their behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it.");
1336+
Gun.warn.once("mapfn", "Map functions are experimental, their behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it.");
13331337
chain = gun.chain();
13341338
gun.map().on(function(data, key, msg, eve){
13351339
var next = (cb||noop).call(this, data, key, msg, eve);
@@ -1366,7 +1370,7 @@
13661370
}
13671371
gun.put(function(go){
13681372
item.get(function(soul, o, msg){ // TODO: BUG! We no longer have this option? & go error not handled?
1369-
if(!soul){ return cb.call(gun, {err: Gun.log('Only a node can be linked! Not "' + msg.put + '"!')}) }
1373+
if(!soul){ return cb.call(gun, {err: Gun.warn('Only a node can be linked! Not "' + msg.put + '"!')}) }
13701374
(tmp = {})[soul] = {'#': soul}; go(tmp);
13711375
},true);
13721376
})
@@ -1380,12 +1384,14 @@
13801384
var noop = function(){}
13811385
var parse = JSON.parseAsync || function(t,cb,r){ var u, d = +new Date; try{ cb(u, JSON.parse(t,r), json.sucks(+new Date - d)) }catch(e){ cb(e) } }
13821386
var json = JSON.stringifyAsync || function(v,cb,r,s){ var u, d = +new Date; try{ cb(u, JSON.stringify(v,r,s), json.sucks(+new Date - d)) }catch(e){ cb(e) } }
1383-
json.sucks = function(d){ if(d > 99){ console.log("Warning: JSON blocking CPU detected. Add `gun/lib/yson.js` to fix."); json.sucks = noop } }
1387+
json.sucks = function(d){ if(d > 99){ console.warn("JSON blocking CPU detected. Add `gun/lib/yson.js` to fix."); json.sucks = noop } }
13841388

13851389
function Mesh(root){
13861390
var mesh = function(){};
13871391
var opt = root.opt || {};
13881392
opt.log = opt.log || console.log;
1393+
opt.warn = opt.warn || console.warn;
1394+
opt.error = opt.error || console.error;
13891395
opt.gap = opt.gap || opt.wait || 0;
13901396
opt.max = opt.max || (opt.memory? (opt.memory * 999 * 999) : 300000000) * 0.3;
13911397
opt.pack = opt.pack || (opt.max * 0.01 * 0.01);
@@ -1619,7 +1625,7 @@
16191625
if(!tmp){ return }
16201626
if(t? 3 > tmp.length : !tmp.length){ return } // TODO: ^
16211627
if(!t){try{tmp = (1 === tmp.length? tmp[0] : JSON.stringify(tmp));
1622-
}catch(e){return opt.log('DAM JSON stringify error', e)}}
1628+
}catch(e){return opt.error('DAM JSON stringify error', e)}}
16231629
if(!tmp){ return }
16241630
send(tmp, peer);
16251631
}
@@ -1667,7 +1673,7 @@
16671673
var tmp = +(new Date); tmp = (tmp - (peer.met||tmp));
16681674
mesh.bye.time = ((mesh.bye.time || tmp) + tmp) / 2;
16691675
}
1670-
mesh.hear['!'] = function(msg, peer){ opt.log('Error:', msg.err) }
1676+
mesh.hear['!'] = function(msg, peer){ opt.error('Error:', msg.err) }
16711677
mesh.hear['?'] = function(msg, peer){
16721678
if(msg.pid){
16731679
if(!peer.pid){ peer.pid = msg.pid }
@@ -1708,7 +1714,7 @@
17081714
if(tmp = console.STAT){ tmp.peers = mesh.near }
17091715
if(opt.super){ return } // temporary (?) until we have better fix/solution?
17101716
var souls = Object.keys(root.next||''); // TODO: .keys( is slow
1711-
if(souls.length > 9999 && !console.SUBS){ console.log(console.SUBS = "Warning: You have more than 10K live GETs, which might use more bandwidth than your screen can show - consider `.off()`.") }
1717+
if(souls.length > 9999 && !console.SUBS){ console.warn(console.SUBS = "You have more than 10K live GETs, which might use more bandwidth than your screen can show - consider `.off()`.") }
17121718
setTimeout.each(souls, function(soul){ var node = root.next[soul];
17131719
if(opt.super || (node.ask||'')['']){ mesh.say({get: {'#': soul}}, peer); return }
17141720
setTimeout.each(Object.keys(node.ask||''), function(key){ if(!key){ return }
@@ -1794,7 +1800,7 @@
17941800
var noop = function(){}, store, u;
17951801
try{store = (Gun.window||noop).localStorage}catch(e){}
17961802
if(!store){
1797-
Gun.log("Warning: No localStorage exists to persist data to!");
1803+
Gun.warn("No localStorage exists to persist data to!");
17981804
store = {setItem: function(k,v){this[k]=v}, removeItem: function(k){delete this[k]}, getItem: function(k){return this[k]}};
17991805
}
18001806

@@ -1841,7 +1847,7 @@
18411847
try{!err && store.setItem(opt.prefix, tmp);
18421848
}catch(e){ err = stop = e || "localStorage failure" }
18431849
if(err){
1844-
Gun.log(err + " Consider using GUN's IndexedDB plugin for RAD for more storage space, https://gun.eco/docs/RAD#install");
1850+
Gun.error(err + " Consider using GUN's IndexedDB plugin for RAD for more storage space, https://gun.eco/docs/RAD#install");
18451851
root.on('localStorage:error', {err: err, get: opt.prefix, put: disk});
18461852
}
18471853
size = tmp.length;
@@ -1862,7 +1868,7 @@
18621868
;(function(){
18631869
var u;
18641870
if(''+u == typeof Gun){ return }
1865-
var DEP = function(n){ console.warn("Warning! Deprecated internal utility will break in next version:", n) }
1871+
var DEP = function(n){ console.warn("Deprecated internal utility will break in next version:", n) }
18661872
// Generic javascript utilities.
18671873
var Type = Gun;
18681874
//Type.fns = Type.fn = {is: function(fn){ return (!!fn && fn instanceof Function) }}

gun.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/book.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
;(function(){ // Book
2-
console.log("Warning: Book is in alpha!");
2+
console.warn("Book is in alpha!");
33
var sT = setTimeout, B = sT.Book || (sT.Book = function(text){
44
var b = function book(word, is){
55
var has = b.all[word], p;

lib/file.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ Gun.on('create', function(root){
1919
fs.readFileSync(opt.file).toString()
2020
: null) || {};
2121

22-
Gun.log.once(
22+
Gun.warn.once(
2323
'file-warning',
24-
'WARNING! This `file.js` module for gun is ' +
24+
'This `file.js` module for gun is ' +
2525
'intended for local development testing only!'
2626
);
2727

lib/radisk.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
opt = opt || {};
66
opt.log = opt.log || console.log;
7+
opt.warn = opt.warn || console.warn;
8+
opt.error = opt.error || console.error;
79
opt.file = String(opt.file || 'radata');
810
var has = (Radisk.has || (Radisk.has = {}))[opt.file];
911
if(has){ return has }
@@ -25,16 +27,16 @@
2527
var ST = 0;
2628

2729
if(!opt.store){
28-
return opt.log("ERROR: Radisk needs `opt.store` interface with `{get: fn, put: fn (, list: fn)}`!");
30+
return opt.error("Radisk needs `opt.store` interface with `{get: fn, put: fn (, list: fn)}`!");
2931
}
3032
if(!opt.store.put){
31-
return opt.log("ERROR: Radisk needs `store.put` interface with `(file, data, cb)`!");
33+
return opt.error("Radisk needs `store.put` interface with `(file, data, cb)`!");
3234
}
3335
if(!opt.store.get){
34-
return opt.log("ERROR: Radisk needs `store.get` interface with `(file, cb)`!");
36+
return opt.error("Radisk needs `store.get` interface with `(file, cb)`!");
3537
}
3638
if(!opt.store.list){
37-
//opt.log("WARNING: `store.list` interface might be needed!");
39+
//opt.warn("`store.list` interface might be needed!");
3840
}
3941

4042
if(''+u != typeof require){ require('./yson') }

lib/radisk2.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
opt = opt || {};
77
opt.log = opt.log || console.log;
8+
opt.warn = opt.warn || console.warn;
9+
opt.error = opt.error || console.error;
810
opt.file = String(opt.file || 'radata');
911
var has = (Radisk.has || (Radisk.has = {}))[opt.file];
1012
if(has){ return has }
@@ -23,16 +25,16 @@
2325
var LOG = false;
2426

2527
if(!opt.store){
26-
return opt.log("ERROR: Radisk needs `opt.store` interface with `{get: fn, put: fn (, list: fn)}`!");
28+
return opt.error("Radisk needs `opt.store` interface with `{get: fn, put: fn (, list: fn)}`!");
2729
}
2830
if(!opt.store.put){
29-
return opt.log("ERROR: Radisk needs `store.put` interface with `(file, data, cb)`!");
31+
return opt.error("Radisk needs `store.put` interface with `(file, data, cb)`!");
3032
}
3133
if(!opt.store.get){
32-
return opt.log("ERROR: Radisk needs `store.get` interface with `(file, cb)`!");
34+
return opt.error("Radisk needs `store.get` interface with `(file, cb)`!");
3335
}
3436
if(!opt.store.list){
35-
//opt.log("WARNING: `store.list` interface might be needed!");
37+
//opt.warn("`store.list` interface might be needed!");
3638
}
3739

3840
/*

lib/radisk3.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
;(function(){ // RAD
2-
console.log("Warning: Experimental rewrite of RAD to use Book. It is not API compatible with RAD yet and is very alpha.");
2+
console.warn("Experimental rewrite of RAD to use Book. It is not API compatible with RAD yet and is very alpha.");
33
var sT = setTimeout, Book = sT.Book, RAD = sT.RAD || (sT.RAD = function(opt){
44
opt = opt || {};
55
opt.file = String(opt.file || 'radata');

lib/radmigtmp.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = function(r){
88
l.push([f,v]);
99
});
1010
if(l.length){
11-
console.log("\n! ! ! WARNING ! ! !\nRAD v0.2020.x has detected OLD v0.2019.x data & automatically migrating. Automatic migration will be turned OFF in future versions! If you are just developing/testing, we recommend you reset your data. Please contact us if you have any concerns.\nThis message should only log once.")
11+
console.warn("RAD v0.2020.x has detected OLD v0.2019.x data & automatically migrating. Automatic migration will be turned OFF in future versions! If you are just developing/testing, we recommend you reset your data. Please contact us if you have any concerns.\nThis message should only log once.")
1212
}
1313
var f, v;
1414
l.forEach(function(a){

lib/rfs.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
function Store(opt){
22
opt = opt || {};
33
opt.log = opt.log || console.log;
4+
opt.error = opt.error || console.error;
45
opt.file = String(opt.file || 'radata');
56
var fs = require('fs'), u;
67

78
var store = function Store(){};
89
if(Store[opt.file]){
9-
console.log("Warning: reusing same fs store and options as 1st.");
10+
console.warn("Reusing same fs store and options as 1st.");
1011
return Store[opt.file];
1112
}
1213
Store[opt.file] = store;
@@ -35,7 +36,7 @@ function Store(opt){
3536
if('ENOENT' === (err.code||'').toUpperCase()){
3637
return cb();
3738
}
38-
opt.log("ERROR:", err);
39+
opt.error("ERROR:", err);
3940
}
4041
cb(err, data);
4142
});

lib/rindexed.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if (navigator.storage && navigator.storage.estimate) {
1616
var store = Store[opt.file], db = null, u;
1717

1818
if(store){
19-
console.log("Warning: reusing same IndexedDB store and options as 1st.");
19+
console.warn("Reusing same IndexedDB store and options as 1st.");
2020
return Store[opt.file];
2121
}
2222
store = Store[opt.file] = function(){};
@@ -26,7 +26,7 @@ if (navigator.storage && navigator.storage.estimate) {
2626
var s = store.d || (store.d = {});
2727
store.put = function(f, d, cb){ s[f] = d; setTimeout(function(){ cb(null, 1) },250) };
2828
store.get = function(f, cb){ setTimeout(function(){ cb(null, s[f] || u) },5) };
29-
console.log('Warning: No indexedDB exists to persist data to!');
29+
console.warn('No indexedDB exists to persist data to!');
3030
return store;
3131
}}catch(e){}
3232

@@ -35,7 +35,7 @@ if (navigator.storage && navigator.storage.estimate) {
3535
var o = indexedDB.open(opt.file, 1);
3636
o.onupgradeneeded = function(eve){ (eve.target.result).createObjectStore(opt.file) }
3737
o.onsuccess = function(){ db = o.result }
38-
o.onerror = function(eve){ console.log(eve||1); }
38+
o.onerror = function(eve){ console.error(eve||1); }
3939
}; store.start();
4040

4141
store.put = function(key, data, cb){

lib/rs3.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function Store(opt){
4545

4646
var store = function Store(){};
4747
if(Store[opt.file]){
48-
console.log("Warning: reusing same S3 store and options as 1st.");
48+
console.warn("Reusing same S3 store and options as 1st.");
4949
return Store[opt.file];
5050
}
5151
Store[opt.file] = store;

lib/super.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
} else {
1515

1616
}
17-
if (!peer.id) {console.log('[*** WARN] no peer.id %s', soul);}
17+
if (!peer.id) {console.warn('No peer.id %s', soul);}
1818
var subs = Gun.subs(soul) || null;
1919
var tmp = subs ? subs.split(',') : [], p = at.opt.peers;
2020
if (subs) {

lib/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
;(function(){
22
var u;
33
if(''+u == typeof Gun){ return }
4-
var DEP = function(n){ console.log("Warning! Deprecated internal utility will break in next version:", n) }
4+
var DEP = function(n){ console.warn("Deprecated internal utility will break in next version:", n) }
55
// Generic javascript utilities.
66
var Type = Gun;
77
//Type.fns = Type.fn = {is: function(fn){ return (!!fn && fn instanceof Function) }}

nts.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
var smooth = 2;
55

66
Gun.on('create', function(root){ // switch to DAM, deprecated old
7-
Gun.log.once("nts", "gun/nts is removed deprecated old");
7+
Gun.warn.once("nts", "gun/nts is removed deprecated old");
88
this.to.next(root);
99
return ; // stub out for now. TODO: IMPORTANT! re-add back in later.
1010
var opt = root.opt, mesh = opt.mesh;

0 commit comments

Comments
 (0)