comparison server.js @ 4:f630f4b90564

Remove the old log system and use console.log instead.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 19 Sep 2011 01:51:12 -0700
parents 2e2a2154efbb
children 29becdd02dea
comparison
equal deleted inserted replaced
3:2e2a2154efbb 4:f630f4b90564
335 res.write(body); 335 res.write(body);
336 res.write(' </section>\n'); 336 res.write(' </section>\n');
337 } 337 }
338 338
339 res.write('\n'); 339 res.write('\n');
340 res.write(' <section hidden="">\n');
341 res.write(' <h2>logs</h2>\n');
342 res.write(' <div id="log"></div>\n');
343 res.write(' </section>\n');
344 res.write('\n');
345 340
346 if (!footer) 341 if (!footer)
347 res.write(' <footer/>\n'); 342 res.write(' <footer/>\n');
348 else { 343 else {
349 res.write(' <footer>\n'); 344 res.write(' <footer>\n');
355 res.write('\n'); 350 res.write('\n');
356 res.write(' <script type="application/ecmascript" src="blog.js"/>\n'); 351 res.write(' <script type="application/ecmascript" src="blog.js"/>\n');
357 } 352 }
358 353
359 res.write(' </body>\n'); 354 res.write(' </body>\n');
355 console.log('It works!');
360 res.end('</html>\n'); 356 res.end('</html>\n');
361 }; 357 };
362 358
363 http.createServer(function(req, res) { 359 http.createServer(function(req, res) {
360 util.log('Connection from ' + (req.headers['x-forwarded-for'] || req.client.remoteAddress) + ' (' + req.headers['user-agent'] + ') to ' + req.method.toLocaleLowerCase() + ' “' + req.url + '” from ' + req.headers['referer'] + '.');
361
364 var re = new RegExp('^' + config.webRoot); 362 var re = new RegExp('^' + config.webRoot);
365 req.url = req.url.replace(re, ''); 363 req.url = req.url.replace(re, '');
366 var ext = req.url.substring(req.url.lastIndexOf('.')+1); 364 var ext = req.url.substring(req.url.lastIndexOf('.')+1);
367 var url = require('url').parse(req.url); 365 var url = require('url').parse(req.url);
368 366