Skip to content

Commit cc38e51

Browse files
committed
Use console.warn, console.error
1 parent f882b86 commit cc38e51

File tree

22 files changed

+59
-43
lines changed

22 files changed

+59
-43
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);

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: 8 additions & 6 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

@@ -1380,12 +1380,14 @@
13801380
var noop = function(){}
13811381
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) } }
13821382
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 } }
1383+
json.sucks = function(d){ if(d > 99){ console.warn("JSON blocking CPU detected. Add `gun/lib/yson.js` to fix."); json.sucks = noop } }
13841384

13851385
function Mesh(root){
13861386
var mesh = function(){};
13871387
var opt = root.opt || {};
13881388
opt.log = opt.log || console.log;
1389+
opt.warn = opt.warn || console.warn;
1390+
opt.error = opt.error || console.error;
13891391
opt.gap = opt.gap || opt.wait || 0;
13901392
opt.max = opt.max || (opt.memory? (opt.memory * 999 * 999) : 300000000) * 0.3;
13911393
opt.pack = opt.pack || (opt.max * 0.01 * 0.01);
@@ -1619,7 +1621,7 @@
16191621
if(!tmp){ return }
16201622
if(t? 3 > tmp.length : !tmp.length){ return } // TODO: ^
16211623
if(!t){try{tmp = (1 === tmp.length? tmp[0] : JSON.stringify(tmp));
1622-
}catch(e){return opt.log('DAM JSON stringify error', e)}}
1624+
}catch(e){return opt.error('DAM JSON stringify error', e)}}
16231625
if(!tmp){ return }
16241626
send(tmp, peer);
16251627
}
@@ -1667,7 +1669,7 @@
16671669
var tmp = +(new Date); tmp = (tmp - (peer.met||tmp));
16681670
mesh.bye.time = ((mesh.bye.time || tmp) + tmp) / 2;
16691671
}
1670-
mesh.hear['!'] = function(msg, peer){ opt.log('Error:', msg.err) }
1672+
mesh.hear['!'] = function(msg, peer){ opt.error('Error:', msg.err) }
16711673
mesh.hear['?'] = function(msg, peer){
16721674
if(msg.pid){
16731675
if(!peer.pid){ peer.pid = msg.pid }
@@ -1794,7 +1796,7 @@
17941796
var noop = function(){}, store, u;
17951797
try{store = (Gun.window||noop).localStorage}catch(e){}
17961798
if(!store){
1797-
Gun.log("Warning: No localStorage exists to persist data to!");
1799+
Gun.warn("No localStorage exists to persist data to!");
17981800
store = {setItem: function(k,v){this[k]=v}, removeItem: function(k){delete this[k]}, getItem: function(k){return this[k]}};
17991801
}
18001802

@@ -1862,7 +1864,7 @@
18621864
;(function(){
18631865
var u;
18641866
if(''+u == typeof Gun){ return }
1865-
var DEP = function(n){ console.warn("Warning! Deprecated internal utility will break in next version:", n) }
1867+
var DEP = function(n){ console.warn("Deprecated internal utility will break in next version:", n) }
18661868
// Generic javascript utilities.
18671869
var Type = Gun;
18681870
//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/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
/*

lib/radisk3.js

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

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

0 commit comments

Comments
 (0)