comparison psgxs.js @ 12:9a6b8b3357c6

Use new functions like console.log instead of sys.puts, and aerate a bit.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 27 Aug 2010 01:14:40 +0200
parents 0ed3c06c5191
children ec7cea92fe8a
comparison
equal deleted inserted replaced
11:0ed3c06c5191 12:9a6b8b3357c6
17 * 17 *
18 * You should have received a copy of the GNU Affero General Public License 18 * You should have received a copy of the GNU Affero General Public License
19 * along with PSĜS. If not, see <http://www.gnu.org/licenses/>. 19 * along with PSĜS. If not, see <http://www.gnu.org/licenses/>.
20 */ 20 */
21 21
22 var sys = require('sys');
23 var xmpp = require('xmpp'); 22 var xmpp = require('xmpp');
24 var sha1 = require('sha1'); 23 var sha1 = require('sha1');
25 require('./iso8601'); 24 require('./iso8601');
26 var storage = require('./storage'); 25 var storage = require('./storage');
27 var errors = require('./errors'); 26 var errors = require('./errors');
33 32
34 var service_configuration = config.service_configuration; 33 var service_configuration = config.service_configuration;
35 var componentJID = config.jid; 34 var componentJID = config.jid;
36 var componentPassword = config.password; 35 var componentPassword = config.password;
37 36
38 conn.log = function (_, m) { sys.puts(m); }; 37 conn.log = function (_, m) { console.log(m); };
39 38
40 function _(m, c) { 39 function _(obj, color) {
41 if (c) 40 var str = require('sys').inspect(obj, false, null);
42 sys.print('\033[1;'+c+'m'); 41 if (color)
43 sys.print(sys.inspect(m, false, null)); 42 console.log('\033['+c+';1m' + str + '\033[0m');
44 if (c) 43 else
45 sys.print('\033[0m'); 44 console.log(str);
46 sys.puts('');
47 }; 45 };
48 46
49 process.addListener('uncaughtException', function (err) { 47 process.addListener('uncaughtException', function (err) {
50 console.log('\033[41;1mUncaught exception, this should never happen: ' + err + '.\033[0m'); 48 console.log('\033[41;1mUncaught exception, this should never happen: ' + err + '.\033[0m');
51 }); 49 });
776 } 774 }
777 775
778 if (!conf) 776 if (!conf)
779 conf = {}; 777 conf = {};
780 conf['pubsub#creator'] = toBareJID(to); 778 conf['pubsub#creator'] = toBareJID(to);
779
781 var r = storage.createNode(nodeID, conf); 780 var r = storage.createNode(nodeID, conf);
782 if (typeof r == 'number') 781 if (typeof r == 'number')
783 return makeError(response, r); 782 return makeError(response, r);
784 783
785 if (instant) 784 if (instant)