Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added logger

  • Loading branch information...
commit 55ace47152efd00aadf89b5023e409902d57d7ee 1 parent db76ad3
@Shogun147 authored
View
5 lib/katana.js
@@ -160,6 +160,11 @@ App.readConf(); (App.env !== 'development') && App.readConf(App.env);
require('./cli-args');
+App.logger = require('./logger');
+App.log = function() {
+ App.logger.log.apply(App.logger, [].slice.call(arguments));
+}
+
var Request = require('./request');
var Response = require('./response');
View
35 lib/logger.js
@@ -0,0 +1,35 @@
+var Winston = require('winston');
+var conf = App.get('logger');
+var merge = require('./utils').merge;
+
+conf = merge({
+ padLevels: true,
+ levels: null,
+ colors: {
+ verbose: 'magenta'
+ },
+
+ transports: {
+ Console: {
+ level: 'debug',
+ colorize: true
+ }
+ }
+}, conf || {});
+
+var transports = Object.map(conf.transports, function(name, options) {
+ return [name, new (Winston.transports[name])(options)];
+});
+
+conf.transports = [];
+Object.keys(transports).forEach(function(name) {
+ conf.transports.push(transports[name]);
+});
+
+var Logger = new (Winston.Logger)(conf);
+
+Logger.on('error', function(error) {
+ console.error('Logger:', error);
+});
+
+module.exports = Logger;
View
10 template/app/config/development/app.js
@@ -32,6 +32,16 @@ module.exports = {
},
favicon: 'public/images/favicon.ico',
+
+ logger: {
+ padLevels: true,
+ transports: {
+ Console: {
+ level: 'debug',
+ colorize: true
+ }
+ }
+ },
view: {
engine: 'ejs',
Please sign in to comment.
Something went wrong with that request. Please try again.