Skip to content

Commit 8db78e7

Browse files
committed
Use console.warn and console.error
1 parent f882b86 commit 8db78e7

File tree

27 files changed

+65
-48
lines changed

27 files changed

+65
-48
lines changed

as.js

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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", "Warning: 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/react-native/src/extensions/sea.js

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 14 additions & 8 deletions
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){}
@@ -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);
@@ -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 }
@@ -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

@@ -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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/book.js

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 6 additions & 4 deletions
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

Lines changed: 6 additions & 4 deletions
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
/*

0 commit comments

Comments
 (0)