Permalink
Browse files

More about logging, Session.save basic test now pass !!!!

  • Loading branch information...
nka11 committed Jul 7, 2011
1 parent 43c0127 commit 1bcbbe09d4947a6f3c49829a47ad23e490e039c0
Showing with 302 additions and 36 deletions.
  1. +5 −1 conf/log4js.json
  2. +1 −1 node_modules/NoCR
  3. +14 −12 src/Node.js
  4. +1 −0 src/Property.js
  5. +1 −1 src/Repository.js
  6. +6 −3 src/Session.js
  7. +3 −1 src/Value.js
  8. +260 −8 src/Workspace.js
  9. +3 −1 src/types/NodeType.js
  10. +4 −2 src/types/nodeTypeManager.js
  11. +4 −6 test/testSuite.js
View
@@ -1,6 +1,10 @@
{ "appenders": [
{
- "type": "console"
+ "type": "logLevelFilter",
+ "level": "DEBUG",
+ "appender": {
+ "type": "console"
+ }
}
],
"levels": {
View
@@ -23,25 +23,26 @@ nodeproto = {
getProperty: function(name, callback) {
var self = this, errmsg;
if (name in self['properties']) {
- _.debug('[getProperty]: found in instances'); // memory cache L1
+ self.logger.debug('[getProperty]: found in instances'); // memory cache L1
if (typeof callback !== "undefined") {
- //_.debug(_.inspect(self['properties'][name]));
+ self.logger.trace(_.inspect(self['properties'][name]));
callback(null, self['properties'][name]);
} else {
return self['properties'][name];
}
} else if (name in self['node:properties']) {
- _.debug('[getProperty]: found in data');
+ self.logger.debug('[getProperty]: found in data');
self.session.getRepository().getDataById(self['node:properties'][name],function(err, propData) {
self['properties'][name] = new Property(propData, self.session);
if (typeof callback !== "undefined") {
+ self.logger.trace(_.inspect(self['properties'][name]));
callback(null, self['properties'][name]);
} else {
return self['properties'][name];
}
});
} else {
- _.debug('[getProperty]: not found');
+ self.logger.debug('[getProperty]: not found');
errmsg = "Property not found in node";
if (typeof callback !== "undefined") {
callback(errmsg);
@@ -54,8 +55,8 @@ nodeproto = {
* Can accept callback func or not, as operations are performed in-memory, there is no async
*/
setProperty: function(name, value, type, callback) {
- //_.debug("[setProperty]: " + _.inspect(arguments));
var self = this, type,error, prop;
+ self.logger.trace("[setProperty]: " + _.inspect(arguments));
if (arguments.length === 0) {
throw new Error("at least name should be specified");
}
@@ -84,7 +85,7 @@ nodeproto = {
}
if (self.type.canSetProperty(name, value)) {
self.ismodified = true;
- //_.debug(_.inspect(self));
+ self.logger.trace(_.inspect(self));
if (name in self['node:properties'] || name in self['properties']) { //such property already exist ethier persisted or in session scope
self.getProperty(name, function(err, prop) {//gets the property instance and sets the value
if (err === null) {
@@ -114,16 +115,16 @@ nodeproto = {
}
}
} else { //deleting the property if null or no value specified
- _.debug("value is not specified or null, removing " + name + " property from registries");
+ self.logger.info("value is not specified or null, removing " + name + " property from registries");
//_.debug(_.inspect(self['node:properties']));
if (name in self['node:properties']) {
- _.debug("Property found in data, deleting");
+ self.logger.debug("Property found in data, deleting");
self['node:properties'][name] = undefined;
delete self['node:properties'][name];
self.ismodified = true;
}
if (name in self['properties']) {
- _.debug("Property found in instances, deleting");
+ self.logger.debug("Property found in instances, deleting");
self['properties'][name] = undefined;
delete self['properties'][name];
self.ismodified = true;
@@ -176,7 +177,7 @@ nodeproto = {
'path': parent.getPath() + childName + '/', // Implementation data, Index
'node:type': 'nt:unstructured' // implementation reference
}, self.session);
- //_.debug(_.inspect(node));
+ self.logger.trace(_.inspect(node));
// parent node by name index
parent['childrens'][childName] = node;
@@ -188,7 +189,7 @@ nodeproto = {
'property:type': 'NAME'
})
);
- //_.debug(_.inspect(node));
+ self.logger.trace(_.inspect(node));
} else {
throw new Error("Integrity problem, Operation addNode can't be performed");
}
@@ -240,7 +241,6 @@ nodeproto = {
function Node(data, session) {
var self = this,
workspace = session.getWorkspace();
- //_.debug("Initializing Node :" + _.inspect(data));
self['properties'] = {}; // data structure for properties instance (lazy load)
self['childrens'] = {}; //data structure for nodes instances (lazy load)
if (!'node:properties' in data || data['node:properties'] === undefined) {
@@ -252,6 +252,8 @@ function Node(data, session) {
self['node:properties'] = data['node:properties'];
self['node:childrens'] = data['node:childrens'];
Item.call(self, data, session);
+ self.logger.info("Initializing Node");
+ self.logger.trace(_.inspect(data));
if (data['node:properties:' + workspace.getName()] !== undefined) {
for (k in data['node:properties:' + workspace.getName()]) {
self['node:properties'][k] = data['node:properties:' + workspace.getName()][k];
View
@@ -1,5 +1,6 @@
var nocr = require("NoCR"),
_ = require('util'),
+ log4js = require('log4js')(),
wrapper = require('./wrapper.js'),
Item = require('./Item.js'),
Value = require('./Value.js'),
View
@@ -51,7 +51,7 @@ function Repository(config, callback) {
});
}
}
-
+ this.getItemsCollection = getItemsCollection;
this.login = function(credentials, workspaceName, callback) {
var
session = new Session(self,credentials, function(err,sess) {
View
@@ -61,7 +61,8 @@ Session = function(repository, credentials, callback) {
if(err) {
callback(err, null);
} else if(user) {
- self.logger.debug("user found :" + _.inspect(users));
+ self.logger.debug("user found");
+ self.logger.trace(_.inspect(users));
if (user.password === credentials.password) {
self.user = {username:user.username, id: user.userid, workspace:user.workspace};
setUserContext();
@@ -86,9 +87,11 @@ Session = function(repository, credentials, callback) {
setAnonymous();
callback(null, self);
} else {
- self.logger.debug("credentials != null :" + _.inspect(credentials));
+ self.logger.debug("credentials != null :");
+ self.logger.trace(_.inspect(credentials));
if (credentials.username !== undefined || credentials.username !== null) {
- self.logger.debug("credentials provided :" + _.inspect(credentials));
+ self.logger.debug("credentials provided :");
+ self.logger.trace(_.inspect(credentials));
usersCollection.find({username: credentials.username}).limit(1).
toArray(checkUserAuth);
} else {
View
@@ -1,5 +1,7 @@
var nocr = require("NoCR"),
_ = require('util'),
+ log4js = require('log4js')(),
+ logger = log4js.getLogger("nocr-mongo.Value"),
wrapper = require('./wrapper.js'),
Value, valueproto;
@@ -54,7 +56,7 @@ function Value(data) {
function checkIntegrity(data) {
var guess = guessType(data['property:value']),
compatibility = require('./utils/itemslookup.js').valueCompatibility;
- _.debug("Checking types integrity : " + data['property:type'] + " vs " + guess);
+ logger.debug("Checking types integrity : " + data['property:type'] + " vs " + guess);
if (compatibility[guess].indexOf(data['property:type']) === -1 ) {
throw new Error("Incompatible type/value found");
}
Oops, something went wrong.

0 comments on commit 1bcbbe0

Please sign in to comment.