• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Simple RSS Reader inspired by Gxxgle Reader


コミットメタ情報

リビジョン13cd87438b89cc5629280dbbf3abac6d75d1342e (tree)
日時2013-07-04 00:46:29
作者hylom <hylom@hylo...>
コミッターhylom

ログメッセージ

add logging tools

変更サマリ

差分

--- /dev/null
+++ b/client/logger.js
@@ -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+
--- a/client/package.json
+++ b/client/package.json
@@ -8,6 +8,7 @@
88 "dependencies": {
99 "express": "3.3.1",
1010 "jade": "*",
11- "mysql": "*"
11+ "mysql": "*",
12+ "winston": "*"
1213 }
1314 }
--- a/client/routes/index.js
+++ b/client/routes/index.js
@@ -3,9 +3,10 @@
33 * GET home page.
44 */
55
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');
910
1011 function timestampToDate(ts) {
1112 var formatString = '%s/%s/%s';
@@ -48,6 +49,7 @@ exports.index = function (req, res) {
4849 connection.query('SELECT feed_id, url, title FROM feed_urls;', function (err, rows, fields) {
4950 connection.end();
5051 if (err) {
52+ logger.debug("query error at index.index: " + util.inspect(err));
5153 res.send(500);
5254 return;
5355 }
@@ -69,6 +71,7 @@ exports.feedContent = function (req, res) {
6971 connection.query(sql, contentId, function (err, rows, fields) {
7072 connection.end();
7173 if (err) {
74+ logger.debug("query error at index.feedContent: " + util.inspect(err));
7275 res.send(500);
7376 return;
7477 }
@@ -96,6 +99,7 @@ exports.feedContents = function (req, res) {
9699 connection.query(sql, feedId, function (err, rows, fields) {
97100 connection.end();
98101 if (err) {
102+ logger.debug("query error at index.feedContents: " + util.inspect(err));
99103 res.send(500);
100104 return;
101105 }