mirror of
https://github.com/mtan93/homebridge.git
synced 2026-03-08 05:31:55 +00:00
Merge remote-tracking branch 'nfarina/master'
# Conflicts: # lib/logger.js
This commit is contained in:
@@ -31,7 +31,7 @@ Logger.prototype.debug = function(msg) {
|
|||||||
if (DEBUG_ENABLED)
|
if (DEBUG_ENABLED)
|
||||||
this.log.apply(this, ['debug'].concat(Array.prototype.slice.call(arguments)));
|
this.log.apply(this, ['debug'].concat(Array.prototype.slice.call(arguments)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.prototype.info = function(msg) {
|
Logger.prototype.info = function(msg) {
|
||||||
this.log.apply(this, ['info'].concat(Array.prototype.slice.call(arguments)));
|
this.log.apply(this, ['info'].concat(Array.prototype.slice.call(arguments)));
|
||||||
}
|
}
|
||||||
@@ -43,35 +43,35 @@ Logger.prototype.warn = function(msg) {
|
|||||||
Logger.prototype.error = function(msg) {
|
Logger.prototype.error = function(msg) {
|
||||||
this.log.apply(this, ['error'].concat(Array.prototype.slice.call(arguments)));
|
this.log.apply(this, ['error'].concat(Array.prototype.slice.call(arguments)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.prototype.log = function(level, msg) {
|
Logger.prototype.log = function(level, msg) {
|
||||||
|
|
||||||
msg = util.format.apply(util, Array.prototype.slice.call(arguments, 1));
|
msg = util.format.apply(util, Array.prototype.slice.call(arguments, 1));
|
||||||
func = console.log;
|
func = console.log;
|
||||||
|
|
||||||
if (level == 'debug') {
|
if (level == 'debug') {
|
||||||
msg = chalk.gray(msg);
|
msg = chalk.gray(msg);
|
||||||
}
|
}
|
||||||
else if (level == 'warn') {
|
else if (level == 'warn') {
|
||||||
msg = chalk.yellow(msg);
|
msg = chalk.yellow(msg);
|
||||||
func = console.error;
|
func = console.error;
|
||||||
}
|
}
|
||||||
else if (level == 'error') {
|
else if (level == 'error') {
|
||||||
msg = chalk.bold.red(msg);
|
msg = chalk.bold.red(msg);
|
||||||
func = console.error;
|
func = console.error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepend prefix if applicable
|
// prepend prefix if applicable
|
||||||
if (this.prefix)
|
if (this.prefix)
|
||||||
msg = chalk.cyan("[" + this.prefix + "]") + " " + msg;
|
msg = chalk.cyan("[" + this.prefix + "]") + " " + msg;
|
||||||
|
|
||||||
// prepend timestamp
|
// prepend timestamp
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
msg = chalk.white("[" + date.toLocaleString() + "]") + " " + msg;
|
msg = chalk.white("[" + date.toLocaleString() + "]") + " " + msg;
|
||||||
|
|
||||||
func(msg);
|
func(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.withPrefix = function(prefix) {
|
Logger.withPrefix = function(prefix) {
|
||||||
|
|
||||||
if (!loggerCache[prefix]) {
|
if (!loggerCache[prefix]) {
|
||||||
@@ -87,6 +87,6 @@ Logger.withPrefix = function(prefix) {
|
|||||||
log.prefix = logger.prefix;
|
log.prefix = logger.prefix;
|
||||||
loggerCache[prefix] = log;
|
loggerCache[prefix] = log;
|
||||||
}
|
}
|
||||||
|
|
||||||
return loggerCache[prefix];
|
return loggerCache[prefix];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "homebridge",
|
"name": "homebridge",
|
||||||
"description": "HomeKit support for the impatient",
|
"description": "HomeKit support for the impatient",
|
||||||
"version": "0.3.1",
|
"version": "0.3.2",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "DEBUG=* ./bin/homebridge -D -P example-plugins/ || true"
|
"dev": "DEBUG=* ./bin/homebridge -D -P example-plugins/ || true"
|
||||||
},
|
},
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "^1.1.1",
|
"chalk": "^1.1.1",
|
||||||
"commander": "2.8.1",
|
"commander": "2.8.1",
|
||||||
"hap-nodejs": "0.2.7",
|
"hap-nodejs": "0.2.8",
|
||||||
"semver": "5.0.3",
|
"semver": "5.0.3",
|
||||||
"node-persist": "^0.0.8"
|
"node-persist": "^0.0.8"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user