moussaka-client
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "moussaka-client", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"authors": [ | ||
@@ -5,0 +5,0 @@ "Sean Dawson <contact@seandawson.info>" |
@@ -8,3 +8,6 @@ // Logging | ||
var Logger = function () {}; | ||
var Logger = function (logLevel) { | ||
this.logLevel = logLevel || | ||
this.severity.warning.level; | ||
}; | ||
@@ -43,6 +46,8 @@ Logger.prototype.severity = { | ||
console.log(sprintf('[%s] [%s]: %s', (new Date()) | ||
.toLocaleTimeString(), | ||
severity.label, | ||
msg)); | ||
if (severity.level >= this.logLevel) { | ||
console.log(sprintf('[%s] [%s]: %s', (new Date()) | ||
.toLocaleTimeString(), | ||
severity.label, | ||
msg)); | ||
} | ||
@@ -49,0 +54,0 @@ }; |
@@ -46,2 +46,7 @@ // Main class | ||
if (opts.logLevel) { | ||
logger.logLevel = opts.logLevel; | ||
} | ||
}; | ||
@@ -52,2 +57,13 @@ | ||
MoussakaClient.prototype.getBaseUrl = function () { | ||
if (!this.serverUrl) { | ||
throw new Error('Server URL not defined.'); | ||
} | ||
var str = this.serverUrl; | ||
if (str.substr(-1) === '/') { | ||
return str.substr(0, str.length - 1); | ||
} | ||
return str; | ||
}; | ||
MoussakaClient.prototype.registerVar = function (name, value, schema) { | ||
@@ -120,3 +136,3 @@ if (this.registedVars[name]) { | ||
MoussakaClient.prototype.connect = function () { | ||
var url = this.serverUrl + path.join('/projects/', | ||
var url = this.getBaseUrl() + path.join('/projects/', | ||
this.projectId, 'devices/'); | ||
@@ -153,3 +169,3 @@ logger.trace('Connecting device at: ' + url); | ||
MoussakaClient.prototype.disconnect = function () { | ||
var url = this.serverUrl + path.join('/projects/', | ||
var url = this.getBaseUrl() + path.join('/projects/', | ||
this.projectId, 'devices/', this._id, '/'); | ||
@@ -194,3 +210,3 @@ logger.trace('Disconnecting device at: ' + url); | ||
MoussakaClient.prototype.pollFn = function () { | ||
var url = this.serverUrl + path.join('/projects/', | ||
var url = this.getBaseUrl() + path.join('/projects/', | ||
this.projectId, 'sessions/', this._id, '/updates/'); | ||
@@ -197,0 +213,0 @@ |
{ | ||
"name": "moussaka-client", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A javascript library that allows you to use javascript applications with the Moussaka prototyping framework.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -49,3 +49,3 @@ moussaka-client | ||
| ----------------- |-----------------------------------------------------------------------------------------------|-------------------------| | ||
| deviceName | The name of the device (i.e. John Smith's PC) | None | | ||
| deviceName | The name of the device (i.e. John Smith's PC.) | None | | ||
| apiKey | The user API key retreived from the user account settings in Moussaka. | None | | ||
@@ -55,3 +55,4 @@ | projectId | The project ID retreived from the project view page in Moussaka. | None | | ||
| serverUrl | The url to your Moussaka server. | http://localhost:3000/ | | ||
| pollInterval | The time in milliseconds between each poll to the server | 1000 | | ||
| pollInterval | The time in milliseconds between each poll to the server. | 1000 | | ||
| logLevel | See section below. | 2 (warning) | | ||
@@ -111,5 +112,18 @@ #### Installing | ||
#### Log Level | ||
By passing in a logLevel option you can control the detail of the log messages. The log levels are as follows: | ||
- trace: 0 | ||
- info: 1 | ||
- warning: 2 | ||
- error: 3 | ||
- exception: 4 | ||
For example, to see only messages that are errors or exceptions, you would pass { logLevel: 3 } to the MoussakaClient constructor. | ||
@@ -26,3 +26,4 @@ (function (require, module) { | ||
projectId: chance.guid(), | ||
projectVersion: chance.word() | ||
projectVersion: chance.word(), | ||
serverUrl: 'http://localhost:3333/' | ||
}; | ||
@@ -29,0 +30,0 @@ |
@@ -43,3 +43,3 @@ (function (require, module) { | ||
} | ||
}); | ||
}, 3333); | ||
@@ -46,0 +46,0 @@ it('should register vars without error', function() { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
395714
9877
127
3