Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

reduce debug printout

  • Loading branch information...
commit 437cc954ef1629c4f618e556243e1b8e96234f79 1 parent 4931be6
John Lindal authored
View
3  TODO
@@ -1,5 +1,6 @@
-npm module
+npm modules
load from app directory or npm module
+ yui log filter
optimize dependency loading via nodejs:
configure versions on the server
View
5 combo-dev.js
@@ -51,11 +51,14 @@ var argv = require('optimist')
var config = Y.JSON.parse(mod_fs.readFileSync(argv.config, 'utf8'));
config.port = argv.port || config.port || 8080;
-var debug = argv.debug || config.debug;
+var log_levels = ['info', 'warn', 'error'];
+var debug = argv.debug || config.debug;
if (debug)
{
require('long-stack-traces');
+ log_levels.push('debug');
}
+require('./server/yui-log-filter.js').installFilter(Y, log_levels);
var app = mod_express.createServer();
View
10 combo.js
@@ -85,11 +85,13 @@ var argv = optimist
})
.argv;
-var debug = argv.debug;
-if (debug)
+var log_levels = ['info', 'warn', 'error'];
+if (argv.debug)
{
require('long-stack-traces');
+ log_levels.push('debug');
}
+require('./server/yui-log-filter.js').installFilter(Y, log_levels);
if (argv.cache)
{
@@ -113,7 +115,7 @@ app.get('/combo', function(req, res)
query = mod_qs.unescape(query);
if (path_util.invalidPath(query))
{
- Y.log('Blocked attempt to break sandbox: ' + query, 'debug', 'combo');
+ Y.log('Blocked attempt to break sandbox: ' + query, 'warn', 'combo');
res.end();
return;
}
@@ -121,7 +123,7 @@ app.get('/combo', function(req, res)
var query_info = content_type.analyze(Y, query);
if (!query_info)
{
- Y.log('unknown request type: ' + query, 'debug', 'combo');
+ Y.log('unknown request type: ' + query, 'warn', 'combo');
res.end();
return;
}
View
26 server/yui-log-filter.js
@@ -0,0 +1,26 @@
+"use strict";
+
+/* Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ *
+ * The copyrights embodied in the content of this file are licensed by
+ * Yahoo! Inc. under the BSD (revised) open source license.
+ */
+
+exports.installFilter = function(Y, levels, filter)
+{
+ var orig_log = Y.config.logFn;
+ Y.config.logFn = function(msg, cat, src)
+ {
+ if (levels && Y.Array.indexOf(levels, cat) == -1)
+ {
+ return;
+ }
+
+ if (filter && !filter.call(this, msg, cat, src))
+ {
+ return;
+ }
+
+ orig_log.apply(this, arguments);
+ };
+};
View
2  test/test-combo-dev.js
@@ -6,6 +6,8 @@
* Yahoo! Inc. under the BSD (revised) open source license.
*/
+console.log('test-combo-dev.js');
+
var module_version =
{
'sp-ns-foo': '1.0.f',
View
2  test/test-combo1.js
@@ -6,6 +6,8 @@
* Yahoo! Inc. under the BSD (revised) open source license.
*/
+console.log('test-combo1.js');
+
var module_version =
{
'sp-ns-foo': '1.0.f',
View
2  test/test-combo2.js
@@ -6,6 +6,8 @@
* Yahoo! Inc. under the BSD (revised) open source license.
*/
+console.log('test-combo2.js');
+
var module_version =
{
'sp-ns-foo': '1.0.f',
Please sign in to comment.
Something went wrong with that request. Please try again.