Simple RSS Reader inspired by Gxxgle Reader
Revisión | 13cd87438b89cc5629280dbbf3abac6d75d1342e (tree) |
---|---|
Tiempo | 2013-07-04 00:46:29 |
Autor | hylom <hylom@hylo...> |
Commiter | hylom |
add logging tools
@@ -0,0 +1,37 @@ | ||
1 | +/* logger.js */ | |
2 | + | |
3 | +var util = require('util'); | |
4 | +var winston = require('winston'); | |
5 | +var config = require('./config.json'); | |
6 | + | |
7 | +winston.remove(winston.transports.Console); | |
8 | +winston.add(winston.transports.Console, config.logging); | |
9 | + | |
10 | +var logger = exports; | |
11 | + | |
12 | +/* logger.*([data], [...]) */ | |
13 | + | |
14 | +logger.error = function() { | |
15 | + winston.error(util.format.apply(this, arguments)); | |
16 | +} | |
17 | + | |
18 | +logger.debug = function() { | |
19 | + winston.debug(util.format.apply(this, arguments)); | |
20 | +} | |
21 | + | |
22 | +logger.warn = function() { | |
23 | + winston.warn(util.format.apply(this, arguments)); | |
24 | +} | |
25 | + | |
26 | +logger.info = function() { | |
27 | + winston.info(util.format.apply(this, arguments)); | |
28 | +} | |
29 | + | |
30 | +logger.verbose = function() { | |
31 | + winston.verbose(util.format.apply(this, arguments)); | |
32 | +} | |
33 | + | |
34 | +logger.silly = function() { | |
35 | + winston.silly(util.format.apply(this, arguments)); | |
36 | +} | |
37 | + |
@@ -8,6 +8,7 @@ | ||
8 | 8 | "dependencies": { |
9 | 9 | "express": "3.3.1", |
10 | 10 | "jade": "*", |
11 | - "mysql": "*" | |
11 | + "mysql": "*", | |
12 | + "winston": "*" | |
12 | 13 | } |
13 | 14 | } |
@@ -3,9 +3,10 @@ | ||
3 | 3 | * GET home page. |
4 | 4 | */ |
5 | 5 | |
6 | -mysql = require('mysql'); | |
7 | -config = require('../config.json'); | |
8 | -util = require('util'); | |
6 | +var mysql = require('mysql'); | |
7 | +var config = require('../config.json'); | |
8 | +var util = require('util'); | |
9 | +var logger = require('../logger.js'); | |
9 | 10 | |
10 | 11 | function timestampToDate(ts) { |
11 | 12 | var formatString = '%s/%s/%s'; |
@@ -48,6 +49,7 @@ exports.index = function (req, res) { | ||
48 | 49 | connection.query('SELECT feed_id, url, title FROM feed_urls;', function (err, rows, fields) { |
49 | 50 | connection.end(); |
50 | 51 | if (err) { |
52 | + logger.debug("query error at index.index: " + util.inspect(err)); | |
51 | 53 | res.send(500); |
52 | 54 | return; |
53 | 55 | } |
@@ -69,6 +71,7 @@ exports.feedContent = function (req, res) { | ||
69 | 71 | connection.query(sql, contentId, function (err, rows, fields) { |
70 | 72 | connection.end(); |
71 | 73 | if (err) { |
74 | + logger.debug("query error at index.feedContent: " + util.inspect(err)); | |
72 | 75 | res.send(500); |
73 | 76 | return; |
74 | 77 | } |
@@ -96,6 +99,7 @@ exports.feedContents = function (req, res) { | ||
96 | 99 | connection.query(sql, feedId, function (err, rows, fields) { |
97 | 100 | connection.end(); |
98 | 101 | if (err) { |
102 | + logger.debug("query error at index.feedContents: " + util.inspect(err)); | |
99 | 103 | res.send(500); |
100 | 104 | return; |
101 | 105 | } |