Skip to content
Browse files

allowed to run silently, or log

  • Loading branch information...
1 parent 6a0843f commit 94c1162044b6036bf3b339f7d89cf70d1db17324 alunny committed Oct 23, 2010
Showing with 8 additions and 1 deletion.
  1. +7 −1 lib/sleight.js
  2. +1 −0 spec/sleight_spec.js
View
8 lib/sleight.js
@@ -5,13 +5,17 @@ var http = require('http')
public: path.join(path.dirname(__filename), '..')
, port: 8088
, target: 'www.phonegap.com'
+ , silent: false
}
-function log(msg) {
+function doLog(msg) {
var timestamp = ' @ ' + (new Date()).getTime()
console.log(msg + timestamp)
}
+// a noop
+function noLog() { }
+
function aOrB(options, defaults) {
return function (field) {
if (options == undefined) return defaults[field]
@@ -24,12 +28,14 @@ exports.start = function (options) {
var choice = aOrB(options,defaults)
, port = choice('port')
, public = choice('public')
+ , silent = choice('silent')
, target = (choice('target')).split(':')
, targetDomain = target[0]
, targetPort = target[1] || 80
, client = http.createClient(targetPort, targetDomain)
+ , log = silent ? noLog : doLog
, sleightServer = http.createServer(function (req, res) {
paperboy
.deliver(public, req, res)
View
1 spec/sleight_spec.js
@@ -20,6 +20,7 @@ sleightServer = sleight.start({
public: public
, port: 3333
, target: 'localhost:4444'
+ , silent: true
});
sleightServer.run()

0 comments on commit 94c1162

Please sign in to comment.
Something went wrong with that request. Please try again.