Comparing version 0.0.1 to 0.1.0
@@ -15,3 +15,7 @@ function list (str) { | ||
amino.subscribe('log:stdout', console.log); | ||
amino.subscribe('log:stderr', console.error); | ||
amino.subscribe('log:stdout', function (args) { | ||
console.log.apply(console, args); | ||
}); | ||
amino.subscribe('log:stderr', function (args) { | ||
console.error.apply(console, args); | ||
}); |
24
index.js
@@ -1,15 +0,21 @@ | ||
var format = require('util').format; | ||
exports.attach = function (options) { | ||
var amino = this; | ||
amino.log = function (message, vars, channel) { | ||
if (typeof vars === 'string') { | ||
channel = vars; | ||
vars = []; | ||
amino.log = function () { | ||
var args = [].slice.call(arguments); | ||
amino.publish('log:stdout', args); | ||
if (!options.quiet) { | ||
console.log.apply(console, args); | ||
} | ||
if (!vars) vars = []; | ||
if (!channel) channel = 'stdout'; | ||
amino.publish('log:' + channel, format.apply(null, [message].concat(vars))); | ||
}; | ||
amino.warn = amino.log; | ||
amino.error = function () { | ||
var args = [].slice.call(arguments); | ||
amino.publish('log:stderr', args); | ||
if (!options.quiet) { | ||
console.error.apply(console, args); | ||
} | ||
}; | ||
}; |
{ | ||
"name": "amino-log", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "logging daemon for amino applications", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,3 +5,3 @@ describe('basic test', function () { | ||
amino | ||
.use(plugin) | ||
.use(plugin, {quiet: true}) | ||
.init(); | ||
@@ -14,3 +14,3 @@ daemon = child_process.spawn(path.resolve(__dirname, '../bin/amino-log')); | ||
it('stdout', function (done) { | ||
it('log', function (done) { | ||
daemon.stdout.once('data', function (chunk) { | ||
@@ -25,3 +25,13 @@ assert.equal(chunk.toString(), 'something!\n'); | ||
it('stderr', function (done) { | ||
it('warn', function (done) { | ||
daemon.stdout.once('data', function (chunk) { | ||
assert.equal(chunk.toString(), 'blah...\n'); | ||
done(); | ||
}); | ||
setTimeout(function () { | ||
amino.warn('blah...'); | ||
}, 200); | ||
}); | ||
it('error', function (done) { | ||
daemon.stderr.once('data', function (chunk) { | ||
@@ -32,3 +42,3 @@ assert.equal(chunk.toString(), 'dude!\n'); | ||
setTimeout(function () { | ||
amino.log('dude!', 'stderr'); | ||
amino.error('dude!'); | ||
}, 200); | ||
@@ -43,5 +53,5 @@ }); | ||
setTimeout(function () { | ||
amino.log('hello %s', ['stupid'], 'stderr'); | ||
amino.error('hello %s', ['stupid']); | ||
}, 200); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4817
84